diff options
| author | Bruce Momjian | 1999-12-07 22:41:44 +0000 |
|---|---|---|
| committer | Bruce Momjian | 1999-12-07 22:41:44 +0000 |
| commit | a0aab48fcd86e3a167c5bd16bb8a16b8a85e9332 (patch) | |
| tree | 5020cec37ddbef4dcd594f069e1c71fc4b1d6e94 /src/bin/scripts/createdb | |
| parent | 54847b25d4fe268cd46d9a9a166dbe6e971e5373 (diff) | |
Okay, that should put us back in sync. These two patches (src & doc) are
against the sources from one hour ago and contain all the portable and
up
to date stuff.
A few other CVS "householding" things you might want to take care of:
* Remove the src/bin/cleardbdir directory
* Remove the file src/bin/psql/sql_help.h from the repository, as it is
a derived file and is build by the release_prep.
Peter Eisentraut
Diffstat (limited to 'src/bin/scripts/createdb')
| -rw-r--r-- | src/bin/scripts/createdb | 71 |
1 files changed, 55 insertions, 16 deletions
diff --git a/src/bin/scripts/createdb b/src/bin/scripts/createdb index 43533a30ff4..bed7c3bec7d 100644 --- a/src/bin/scripts/createdb +++ b/src/bin/scripts/createdb @@ -1,7 +1,7 @@ #!/bin/sh #------------------------------------------------------------------------- # -# createdb.sh-- +# createdb-- # create a postgres database # # This program runs psql with the "-c" option to create @@ -11,7 +11,7 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.1 1999/12/04 04:53:21 momjian Exp $ +# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.2 1999/12/07 22:41:44 momjian Exp $ # #------------------------------------------------------------------------- @@ -21,6 +21,7 @@ MB= PSQLOPT= dbname= dbcomment= +dbpath= while [ $# -gt 0 ] do @@ -33,12 +34,33 @@ do --host|-h) PSQLOPT="$PSQLOPT -h $2" shift;; + -h*) + PSQLOPT="$PSQLOPT $1" + ;; + --host=*) + PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'` + ;; --port|-p) PSQLOPT="$PSQLOPT -p $2" shift;; + -p*) + PSQLOPT="$PSQLOPT $1" + ;; + --port=*) + PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'` + ;; --user|--username|-U) - PSQLOPT="$PSQLOPT -U $2" + PSQLOPT="$PSQLOPT -U '$2'" shift;; + -U*) + PSQLOPT="$PSQLOPT $1" + ;; + --user=*) + PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--user=//'` + ;; + --username=*) + PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'` + ;; --password|-W) PSQLOPT="$PSQLOPT -W" ;; @@ -49,18 +71,24 @@ do PSQLOPT="$PSQLOPT -o /dev/null" ;; # options converted into SQL command - --dbpath|-D) + --location|-D) dbpath="$2" shift;; + -D*) + dbpath=`echo $1 | sed 's/^-D//'` + ;; + --location=*) + dbpath=`echo $1 | sed 's/^--location=//'` + ;; --encoding|-E) MB=$2 - shift - if [ -z `pg_encoding $MB` ]; then - echo "$CMDNAME: $MB is not a valid encoding name" - exit 1 - fi - ;; - + shift;; + -E*) + MB=`echo $1 | sed 's/^-E//'` + ;; + --encoding=*) + MB=`echo $1 | sed 's/^--encoding=//'` + ;; -*) echo "$CMDNAME: Unrecognized option: $1. Try -? for help." exit 1 @@ -78,17 +106,26 @@ done if [ "$usage" ]; then - echo "Usage: $CMDNAME [-h <server>] [-p <port>] [-D <path>] \\" - echo " [-E <encoding>] [-U <username>] [-W] dbname [description]" + echo "Usage: $CMDNAME [-h server] [-p port] [-D path] \\" + echo " [-E encoding] [-U username] dbname [description]" exit 0 fi + +if [ "$MB" -a -z "`pg_encoding '$MB'`" ]; then + echo "$CMDNAME: \"$MB\" is not a valid encoding name." + exit 1 +fi + if [ -z "$dbname" ]; then echo "$CMDNAME: Missing required argument database name. Try -? for help." exit 1 fi +dbpath=`echo $dbpath | sed "s/'/\\\\\'/g"` +dbname=`echo $dbname | sed 's/\"/\\\"/g'` + withstring= [ "$dbpath" ] && withstring="$withstring LOCATION = '$dbpath'" [ "$MB" ] && withstring="$withstring ENCODING = '$MB'" @@ -103,10 +140,12 @@ fi # Insert comment as well, if requested [ -z "$dbcomment" ] && exit 0 -psql $PSQLOPT -d template1 -c "COMMENT ON DATABASE \"$dbname\" IS \'$dbcomment\'" +dbcomment=`echo $dbcomment | sed "s/'/\\\\\'/g"` + +psql $PSQLOPT -d template1 -c "COMMENT ON DATABASE \"$dbname\" IS '$dbcomment'" if [ $? -ne 0 ]; then - echo "$CMDNAME: Comment creation failed." + echo "$CMDNAME: Comment creation failed. (Database was created.)" exit 1 fi -exit 0
\ No newline at end of file +exit 0 |
