Default argument for createdb
authorPeter Eisentraut
Thu, 10 Feb 2000 20:08:58 +0000 (20:08 +0000)
committerPeter Eisentraut
Thu, 10 Feb 2000 20:08:58 +0000 (20:08 +0000)
Changed EXIT_ON_ERROR to ON_ERROR_STOP in psql

doc/src/sgml/ref/createdb.sgml
doc/src/sgml/ref/psql-ref.sgml
src/bin/psql/help.c
src/bin/psql/mainloop.c
src/bin/scripts/createdb

index bdb1e189a0cf42838aa5273842da3055eb394a69..15b9c14bde6f9f2e45f185861e4ac12edd413fd2 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -121,6 +121,8 @@ createdb [ options ] 
        
    Specifies the name of the database to be created.  The name must be
    unique among all PostgreSQL databases in this installation.
+        The default is to create a database with the same name as the
+        current system user.
        
       
      
index 4d0bf428c0a8e3665fae43f78186fcb16dad5dc9..4d31f426d9e92853bf2453458c40469662b075b1 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -1644,24 +1644,6 @@ bar
    
       
 
-      
-        EXIT_ON_ERROR
-   
-   
-   By default, if non-interactive scripts encounter an error, such as a
-   malformed SQL query or internal meta-command,
-   processing continues. This is has been the traditional behaviour of
-        psqlbut is often less than desirable. If this variable
-   is set, script processing will immediately terminate. If the script was
-   called from another script it will terminate in the same fashion.
-   If the outermost script was not called from an interactive psql
-   session but rather using the  option, psql
-   will return error code 3, to distinguish this case from fatal
-   error conditions (error code 1).
-   
-   
-      
-
       
         HISTCONTROL
    
@@ -1766,6 +1748,24 @@ bar
    
       
 
+      
+        ON_ERROR_STOP
+   
+   
+   By default, if non-interactive scripts encounter an error, such as a
+   malformed SQL query or internal meta-command,
+   processing continues. This is has been the traditional behaviour of
+        psql but it is sometimes not desirable. If this variable
+   is set, script processing will immediately terminate. If the script was
+   called from another script it will terminate in the same fashion.
+   If the outermost script was not called from an interactive psql
+   session but rather using the  option, psql
+   will return error code 3, to distinguish this case from fatal
+   error conditions (error code 1).
+   
+   
+      
+
       
         PORT
    
@@ -1886,7 +1886,7 @@ testdb=> \set content `sed -e "s/'/\\\\\\'/g" < my_file.txt`
 
     
     Since colons may legally appear in queries, the following rule applies: If the variable
-    is not set, the character sequence colon name is not changed. In any
+    is not set, the character sequence colon+name is not changed. In any
     case you can escape a colon with a backslash to protect it from interpretation.
     (The colon syntax for variables is standard SQL for embedded
     query languages, such as ecpg. The colon syntax for
@@ -1987,8 +1987,8 @@ testdb=> \set content `sed -e "s/'/\\\\\\'/g" < my_file.txt`
       
         %:name:
    
-   The value of the psqlmagic, or environment
-   variable  class="parameter">name. See the section
+   The value of the psqlvariable 
+        class="parameter">name. See the section
    
    for details.
    
@@ -2024,7 +2024,7 @@ testdb=> \set content `sed -e "s/'/\\\\\\'/g" < my_file.txt`
     psql returns 0 to the shell if it finished normally,
     1 if a fatal error of its own (out of memory, file not found) occurs, 2 if the
     connection to the backend went bad and the session is not interactive, and 3 if
-    an error occurred in a script and the variable EXIT_ON_ERROR was
+    an error occurred in a script and the variable ON_ERROR_STOP was
     set.
     
 
index 261f134420364bbc1101c05fe9157f210a397e0b..fe1d76bc76c94da1f4d4e8070ab5c7d70df4e9a0 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.16 2000/02/07 23:10:06 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.17 2000/02/10 20:08:56 petere Exp $
  */
 #include 
 #include "help.h"
@@ -54,7 +54,7 @@ usage(void)
    if (!user)
    {
 #ifndef WIN32
-       pw = getpwuid(getuid());
+       pw = getpwuid(geteuid());
        if (pw)
            user = pw->pw_name;
        else
index 325a6b5ed85931b3b9eb8aba884c12494563a840..e16bf782f3b667c72bdd9354fde7a24b7cdc6d1b 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  *
- * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.17 2000/02/07 23:10:06 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/mainloop.c,v 1.18 2000/02/10 20:08:56 petere Exp $
  */
 #include 
 #include "mainloop.h"
@@ -138,7 +138,7 @@ MainLoop(FILE *source)
 
 
        /* Setting this will not have effect until next line. */
-       die_on_error = GetVariableBool(pset.vars, "EXIT_ON_ERROR");
+       die_on_error = GetVariableBool(pset.vars, "ON_ERROR_STOP");
 
        /*
         * query_buf holds query already accumulated.  line is the
index 3fba2ae0e59626e0600efdd44aeb7f9dd9f58c64..fd07e27292a8764fde0b353b4e237cc5395fd40c 100644 (file)
@@ -11,7 +11,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.7 2000/01/19 20:08:35 petere Exp $
+#    $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.8 2000/02/10 20:08:58 petere Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -126,7 +126,7 @@ fi
 
 if [ -n "$MB" ]
 then
-        mbcode=`pg_encoding "$MB"`
+        mbcode=`${PATHNAME}pg_encoding "$MB"`
         if [ -z "$mbcode" ]
    then
        echo "$CMDNAME: \"$MB\" is not a valid encoding name"
@@ -135,9 +135,12 @@ then
 fi
 
 if [ -z "$dbname" ]; then
-   echo "$CMDNAME: missing required argument database name"
-        echo "Try -? for help."
-   exit 1
+        if [ "$PGUSER" ]; then
+                dbname=$PGUSER
+        else
+                dbname=`${PATHNAME}pg_id -u -n`
+        fi
+        [ $? -ne 0 ] && exit 1
 fi