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 @@
# and "pg_group" tables, which belong to the whole installation rather
# 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`"
......@@ -42,6 +42,7 @@ else
fi
done
fi
IFS="$_IFS"
# 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
......@@ -218,6 +219,7 @@ while : ; do
echo " ALTER GROUP \"$GRONAME\" ADD USER \"$username\";"
done
done
IFS="$_IFS"
test "$globals_only" = yes && exit 0
......@@ -234,12 +236,13 @@ exec 4<&0
$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;" | \
while read DATABASE ; do
while : ; do
IFS="$NL"
read DBOWNER
read ENCODING
read ISTEMPLATE
read DBPATH
read DATABASE || break
read DBOWNER || break
read ENCODING || break
read ISTEMPLATE || break
read DBPATH || break
IFS="$_IFS"
if [ "$DATABASE" != template1 ] ; then
echo
......@@ -261,6 +264,7 @@ while read DATABASE ; do
fi
fi
done
IFS="$_IFS"
$PSQL -d template1 -At -F "$NL" \
-c "SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;" | \
......
......@@ -12,12 +12,12 @@
#
#
# 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"`
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`
MB=
TEMPLATE=
......@@ -42,7 +42,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
......@@ -51,7 +51,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
PSQLOPT="$PSQLOPT -p `echo \"$1\" | sed 's/^--port=//'`"
;;
--username|-U)
PSQLOPT="$PSQLOPT -U $2"
......@@ -60,7 +60,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
;;
--password|-W)
PSQLOPT="$PSQLOPT -W"
......
......@@ -7,12 +7,12 @@
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
# 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"`
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`
PSQLOPT=
dbname=
......@@ -55,7 +55,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
......@@ -64,7 +64,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
PSQLOPT="$PSQLOPT -p `echo \"$1\" | sed 's/^--port=//'`"
;;
--username|-U)
PSQLOPT="$PSQLOPT -U $2"
......@@ -73,7 +73,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
;;
--password|-W)
PSQLOPT="$PSQLOPT -W"
......
......@@ -9,14 +9,14 @@
#
#
# 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.
#
#-------------------------------------------------------------------------
CMDNAME=`basename "$0"`
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`
NewUser=
SysID=
......@@ -54,7 +54,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
......@@ -63,7 +63,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--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),
# not the user you're creating.
......@@ -74,7 +74,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
;;
--password|-W)
PSQLOPT="$PSQLOPT -W"
......
......@@ -11,12 +11,12 @@
#
#
# 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"`
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`
PSQLOPT=
dbname=
......@@ -49,7 +49,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
......@@ -58,7 +58,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
PSQLOPT="$PSQLOPT -p `echo \"$1\" | sed 's/^--port=//'`"
;;
--username|-U)
PSQLOPT="$PSQLOPT -U $2"
......@@ -67,7 +67,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
;;
--password|-W)
PSQLOPT="$PSQLOPT -W"
......@@ -136,7 +136,7 @@ if [ "$forcedel" = f ]; then
fi
dbname=`echo $dbname | sed 's/\"/\\\"/g'`
dbname=`echo "$dbname" | sed 's/\"/\\\"/g'`
${PATHNAME}psql $PSQLOPT -d template1 -c "DROP DATABASE \"$dbname\""
if [ "$?" -ne 0 ]; then
......
......@@ -7,12 +7,12 @@
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
# 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"`
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`
PSQLOPT=
dbname=
......@@ -54,7 +54,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
......@@ -63,7 +63,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
PSQLOPT="$PSQLOPT -p `echo \"$1\" | sed 's/^--port=//'`"
;;
--username|-U)
PSQLOPT="$PSQLOPT -U $2"
......@@ -72,7 +72,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
;;
--password|-W)
PSQLOPT="$PSQLOPT -W"
......
......@@ -9,14 +9,14 @@
#
#
# 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.
#
#-------------------------------------------------------------------------
CMDNAME=`basename "$0"`
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`
PSQLOPT=
forcedel=t
......@@ -49,7 +49,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
......@@ -58,7 +58,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--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),
# not the user you're dropping.
......@@ -69,7 +69,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
;;
--password|-W)
PSQLOPT="$PSQLOPT -W"
......
......@@ -12,12 +12,12 @@
#
#
# 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"`
PATHNAME=`echo $0 | sed "s,$CMDNAME\$,,"`
PATHNAME=`echo "$0" | sed "s,$CMDNAME\$,,"`
PSQLOPT=
full=
......@@ -43,7 +43,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--host=*)
PSQLOPT="$PSQLOPT -h "`echo $1 | sed 's/^--host=//'`
PSQLOPT="$PSQLOPT -h `echo \"$1\" | sed 's/^--host=//'`"
;;
--port|-p)
PSQLOPT="$PSQLOPT -p $2"
......@@ -52,7 +52,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--port=*)
PSQLOPT="$PSQLOPT -p "`echo $1 | sed 's/^--port=//'`
PSQLOPT="$PSQLOPT -p `echo \"$1\" | sed 's/^--port=//'`"
;;
--username|-U)
PSQLOPT="$PSQLOPT -U $2"
......@@ -61,7 +61,7 @@ do
PSQLOPT="$PSQLOPT $1"
;;
--username=*)
PSQLOPT="$PSQLOPT -U "`echo $1 | sed 's/^--username=//'`
PSQLOPT="$PSQLOPT -U `echo \"$1\" | sed 's/^--username=//'`"
;;
--password|-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