Commit 5804a7ce authored by Bruce Momjian's avatar Bruce Momjian

Allow dropdb and others to use identifiers with spaces; IFS cleanup for

pg_dumpall.
parent 5129e1bd
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# and "pg_group" tables, which belong to the whole installation rather # and "pg_group" tables, which belong to the whole installation rather
# than any one individual database. # than any one individual database.
# #
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_dumpall.sh,v 1.20 2002/04/11 21:22:27 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_dumpall.sh,v 1.21 2002/04/12 09:37:10 momjian Exp $
CMDNAME="`basename $0`" CMDNAME="`basename $0`"
...@@ -42,6 +42,7 @@ else ...@@ -42,6 +42,7 @@ else
fi fi
done done
fi fi
IFS="$_IFS"
# As last resort use the installation directory. We don't want to use # As last resort use the installation directory. We don't want to use
# this as first resort because depending on how users do release upgrades # this as first resort because depending on how users do release upgrades
...@@ -218,6 +219,7 @@ while : ; do ...@@ -218,6 +219,7 @@ while : ; do
echo " ALTER GROUP \"$GRONAME\" ADD USER \"$username\";" echo " ALTER GROUP \"$GRONAME\" ADD USER \"$username\";"
done done
done done
IFS="$_IFS"
test "$globals_only" = yes && exit 0 test "$globals_only" = yes && exit 0
...@@ -234,12 +236,13 @@ exec 4<&0 ...@@ -234,12 +236,13 @@ exec 4<&0
$PSQL -d template1 -At -F "$NL" \ $PSQL -d template1 -At -F "$NL" \
-c "SELECT datname, coalesce(usename, (select usename from pg_shadow where usesysid=(select datdba from pg_database where datname='template0'))), pg_encoding_to_char(d.encoding), datistemplate, datpath FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) WHERE datallowconn ORDER BY 1;" | \ -c "SELECT datname, coalesce(usename, (select usename from pg_shadow where usesysid=(select datdba from pg_database where datname='template0'))), pg_encoding_to_char(d.encoding), datistemplate, datpath FROM pg_database d LEFT JOIN pg_shadow u ON (datdba = usesysid) WHERE datallowconn ORDER BY 1;" | \
while read DATABASE ; do while : ; do
IFS="$NL" IFS="$NL"
read DBOWNER read DATABASE || break
read ENCODING read DBOWNER || break
read ISTEMPLATE read ENCODING || break
read DBPATH read ISTEMPLATE || break
read DBPATH || break
IFS="$_IFS" IFS="$_IFS"
if [ "$DATABASE" != template1 ] ; then if [ "$DATABASE" != template1 ] ; then
echo echo
...@@ -261,6 +264,7 @@ while read DATABASE ; do ...@@ -261,6 +264,7 @@ while read DATABASE ; do
fi fi
fi fi
done done
IFS="$_IFS"
$PSQL -d template1 -At -F "$NL" \ $PSQL -d template1 -At -F "$NL" \
-c "SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;" | \ -c "SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;" | \
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.20 2002/02/24 23:27:58 tgl Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createdb,v 1.21 2002/04/12 09:37:10 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
CMDNAME=`basename "$0"` CMDNAME=`basename "$0"`
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"` PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`
MB= MB=
TEMPLATE= TEMPLATE=
...@@ -42,7 +42,7 @@ do ...@@ -42,7 +42,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--host=*) --host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'` PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
;; ;;
--port|-p) --port|-p)
PSQLOPT="$PSQLOPT -p $2" PSQLOPT="$PSQLOPT -p $2"
...@@ -51,7 +51,7 @@ do ...@@ -51,7 +51,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--port=*) --port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'` PSQLOPT="$PSQLOPT -p `echo \"$1\" | sed 's/^--port=//'`"
;; ;;
--username|-U) --username|-U)
PSQLOPT="$PSQLOPT -U $2" PSQLOPT="$PSQLOPT -U $2"
...@@ -60,7 +60,7 @@ do ...@@ -60,7 +60,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--username=*) --username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'` PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
;; ;;
--password|-W) --password|-W)
PSQLOPT="$PSQLOPT -W" PSQLOPT="$PSQLOPT -W"
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group # Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California # Portions Copyright (c) 1994, Regents of the University of California
# #
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.34 2002/02/18 23:11:30 petere Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createlang.sh,v 1.35 2002/04/12 09:37:10 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
CMDNAME=`basename "$0"` CMDNAME=`basename "$0"`
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"` PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`
PSQLOPT= PSQLOPT=
dbname= dbname=
...@@ -55,7 +55,7 @@ do ...@@ -55,7 +55,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--host=*) --host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'` PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
;; ;;
--port|-p) --port|-p)
PSQLOPT="$PSQLOPT -p $2" PSQLOPT="$PSQLOPT -p $2"
...@@ -64,7 +64,7 @@ do ...@@ -64,7 +64,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--port=*) --port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'` PSQLOPT="$PSQLOPT -p `echo \"$1\" | sed 's/^--port=//'`"
;; ;;
--username|-U) --username|-U)
PSQLOPT="$PSQLOPT -U $2" PSQLOPT="$PSQLOPT -U $2"
...@@ -73,7 +73,7 @@ do ...@@ -73,7 +73,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--username=*) --username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'` PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
;; ;;
--password|-W) --password|-W)
PSQLOPT="$PSQLOPT -W" PSQLOPT="$PSQLOPT -W"
......
...@@ -9,14 +9,14 @@ ...@@ -9,14 +9,14 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.23 2002/02/18 05:48:44 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/createuser,v 1.24 2002/04/12 09:37:10 momjian Exp $
# #
# Note - this should NOT be setuid. # Note - this should NOT be setuid.
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
CMDNAME=`basename "$0"` CMDNAME=`basename "$0"`
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"` PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`
NewUser= NewUser=
SysID= SysID=
...@@ -54,7 +54,7 @@ do ...@@ -54,7 +54,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--host=*) --host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'` PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
;; ;;
--port|-p) --port|-p)
PSQLOPT="$PSQLOPT -p $2" PSQLOPT="$PSQLOPT -p $2"
...@@ -63,7 +63,7 @@ do ...@@ -63,7 +63,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--port=*) --port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'` PSQLOPT="$PSQLOPT -p `echo \"$1\" | sed 's/^--port=//'`"
;; ;;
# Note: These two specify the user to connect as (like in psql), # Note: These two specify the user to connect as (like in psql),
# not the user you're creating. # not the user you're creating.
...@@ -74,7 +74,7 @@ do ...@@ -74,7 +74,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--username=*) --username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'` PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
;; ;;
--password|-W) --password|-W)
PSQLOPT="$PSQLOPT -W" PSQLOPT="$PSQLOPT -W"
......
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.14 2002/02/18 05:48:44 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropdb,v 1.15 2002/04/12 09:37:11 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
CMDNAME=`basename "$0"` CMDNAME=`basename "$0"`
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"` PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`
PSQLOPT= PSQLOPT=
dbname= dbname=
...@@ -49,7 +49,7 @@ do ...@@ -49,7 +49,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--host=*) --host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'` PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
;; ;;
--port|-p) --port|-p)
PSQLOPT="$PSQLOPT -p $2" PSQLOPT="$PSQLOPT -p $2"
...@@ -58,7 +58,7 @@ do ...@@ -58,7 +58,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--port=*) --port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'` PSQLOPT="$PSQLOPT -p `echo \"$1\" | sed 's/^--port=//'`"
;; ;;
--username|-U) --username|-U)
PSQLOPT="$PSQLOPT -U $2" PSQLOPT="$PSQLOPT -U $2"
...@@ -67,7 +67,7 @@ do ...@@ -67,7 +67,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--username=*) --username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'` PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
;; ;;
--password|-W) --password|-W)
PSQLOPT="$PSQLOPT -W" PSQLOPT="$PSQLOPT -W"
...@@ -136,7 +136,7 @@ if [ "$forcedel" = f ]; then ...@@ -136,7 +136,7 @@ if [ "$forcedel" = f ]; then
fi fi
dbname=`echo $dbname | sed 's/\"/\\\"/g'` dbname=`echo "$dbname" | sed 's/\"/\\\"/g'`
${PATHNAME}psql $PSQLOPT -d template1 -c "DROP DATABASE \"$dbname\"" ${PATHNAME}psql $PSQLOPT -d template1 -c "DROP DATABASE \"$dbname\""
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group # Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California # Portions Copyright (c) 1994, Regents of the University of California
# #
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.21 2002/02/18 05:48:44 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/droplang,v 1.22 2002/04/12 09:37:11 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
CMDNAME=`basename "$0"` CMDNAME=`basename "$0"`
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"` PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`
PSQLOPT= PSQLOPT=
dbname= dbname=
...@@ -54,7 +54,7 @@ do ...@@ -54,7 +54,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--host=*) --host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'` PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
;; ;;
--port|-p) --port|-p)
PSQLOPT="$PSQLOPT -p $2" PSQLOPT="$PSQLOPT -p $2"
...@@ -63,7 +63,7 @@ do ...@@ -63,7 +63,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--port=*) --port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'` PSQLOPT="$PSQLOPT -p `echo \"$1\" | sed 's/^--port=//'`"
;; ;;
--username|-U) --username|-U)
PSQLOPT="$PSQLOPT -U $2" PSQLOPT="$PSQLOPT -U $2"
...@@ -72,7 +72,7 @@ do ...@@ -72,7 +72,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--username=*) --username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'` PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
;; ;;
--password|-W) --password|-W)
PSQLOPT="$PSQLOPT -W" PSQLOPT="$PSQLOPT -W"
......
...@@ -9,14 +9,14 @@ ...@@ -9,14 +9,14 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.15 2002/02/18 05:48:45 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/dropuser,v 1.16 2002/04/12 09:37:11 momjian Exp $
# #
# Note - this should NOT be setuid. # Note - this should NOT be setuid.
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
CMDNAME=`basename "$0"` CMDNAME=`basename "$0"`
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"` PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`
PSQLOPT= PSQLOPT=
forcedel=t forcedel=t
...@@ -49,7 +49,7 @@ do ...@@ -49,7 +49,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--host=*) --host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'` PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
;; ;;
--port|-p) --port|-p)
PSQLOPT="$PSQLOPT -p $2" PSQLOPT="$PSQLOPT -p $2"
...@@ -58,7 +58,7 @@ do ...@@ -58,7 +58,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--port=*) --port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'` PSQLOPT="$PSQLOPT -p `echo \"$1\" | sed 's/^--port=//'`"
;; ;;
# Note: These two specify the user to connect as (like in psql), # Note: These two specify the user to connect as (like in psql),
# not the user you're dropping. # not the user you're dropping.
...@@ -69,7 +69,7 @@ do ...@@ -69,7 +69,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--username=*) --username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'` PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
;; ;;
--password|-W) --password|-W)
PSQLOPT="$PSQLOPT -W" PSQLOPT="$PSQLOPT -W"
......
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.20 2002/02/18 05:48:45 momjian Exp $ # $Header: /cvsroot/pgsql/src/bin/scripts/Attic/vacuumdb,v 1.21 2002/04/12 09:37:11 momjian Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
CMDNAME=`basename "$0"` CMDNAME=`basename "$0"`
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"` PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`
PSQLOPT= PSQLOPT=
full= full=
...@@ -43,7 +43,7 @@ do ...@@ -43,7 +43,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--host=*) --host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'` PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
;; ;;
--port|-p) --port|-p)
PSQLOPT="$PSQLOPT -p $2" PSQLOPT="$PSQLOPT -p $2"
...@@ -52,7 +52,7 @@ do ...@@ -52,7 +52,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--port=*) --port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'` PSQLOPT="$PSQLOPT -p `echo \"$1\" | sed 's/^--port=//'`"
;; ;;
--username|-U) --username|-U)
PSQLOPT="$PSQLOPT -U $2" PSQLOPT="$PSQLOPT -U $2"
...@@ -61,7 +61,7 @@ do ...@@ -61,7 +61,7 @@ do
PSQLOPT="$PSQLOPT $1" PSQLOPT="$PSQLOPT $1"
;; ;;
--username=*) --username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'` PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
;; ;;
--password|-W) --password|-W)
PSQLOPT="$PSQLOPT -W" PSQLOPT="$PSQLOPT -W"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment