diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-02-18 17:53:55 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-02-18 17:53:55 +0000 |
| commit | c3b00e7e291cd9884bbdf768cfccb5dab8f142e8 (patch) | |
| tree | 7ee5fb5ea89399fbcf28d4259849703404672fc8 /src/bin | |
| parent | 48d03278a27b9a148c3cf9c895ad1c6289ca1c29 (diff) | |
| download | postgresql-c3b00e7e291cd9884bbdf768cfccb5dab8f142e8.tar.gz | |
Add --template option to createdb script to allow access to WITH TEMPLATE
option of CREATE DATABASE. In pg_regress, create regression database
from template0 to ensure that any installation-local cruft in template1
will not mess up the tests.
Diffstat (limited to 'src/bin')
| -rw-r--r-- | src/bin/scripts/createdb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/bin/scripts/createdb b/src/bin/scripts/createdb index 037566a528..4a695a1590 100644 --- a/src/bin/scripts/createdb +++ b/src/bin/scripts/createdb @@ -7,11 +7,12 @@ # This program runs psql with the "-c" option to create # the requested database. # -# Copyright (c) 1994, Regents of the University of California +# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group +# Portions Copyright (c) 1994, Regents of the University of California # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.13 2001/01/21 05:16:45 momjian Exp $ +# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.14 2001/02/18 17:53:54 tgl Exp $ # #------------------------------------------------------------------------- @@ -19,6 +20,7 @@ CMDNAME=`basename $0` PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"` MB= +TEMPLATE= PSQLOPT= dbname= dbcomment= @@ -78,6 +80,15 @@ do --location=*) dbpath=`echo "$1" | sed 's/^--location=//'` ;; + --template|-T) + TEMPLATE="$2" + shift;; + -T*) + TEMPLATE=`echo "$1" | sed 's/^-T//'` + ;; + --template=*) + TEMPLATE=`echo "$1" | sed 's/^--template=//'` + ;; --encoding|-E) MB="$2" shift;; @@ -111,6 +122,7 @@ if [ "$usage" ]; then echo echo "Options:" echo " -D, --location=PATH Alternative place to store the database" + echo " -T, --template=TEMPLATE Template database to copy" echo " -E, --encoding=ENCODING Multibyte encoding for the database" echo " -h, --host=HOSTNAME Database server host" echo " -p, --port=PORT Database server port" @@ -149,10 +161,12 @@ fi # escape the quotes dbpath=`echo "$dbpath" | sed "s/'/\\\\\'/g"` dbname=`echo "$dbname" | sed 's/\"/\\\"/g'` +TEMPLATE=`echo "$TEMPLATE" | sed 's/\"/\"\"/g'` withstring= [ "$dbpath" ] && withstring="$withstring LOCATION = '$dbpath'" [ "$MB" ] && withstring="$withstring ENCODING = '$MB'" +[ "$TEMPLATE" ] && withstring="$withstring TEMPLATE = \"$TEMPLATE\"" [ "$withstring" ] && withstring=" WITH$withstring" ${PATHNAME}psql $PSQLOPT -d template1 -c "CREATE DATABASE \"$dbname\"$withstring" |
