mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Make sure leading/trailing/multiple consecutive space/tab in db/user/group
names are handled OK.
This commit is contained in:
parent
902a6a0a4b
commit
2dd06b0593
@ -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.18 2002/04/11 19:23:36 momjian Exp $
|
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_dumpall.sh,v 1.19 2002/04/11 21:16:28 momjian Exp $
|
||||||
|
|
||||||
CMDNAME="`basename $0`"
|
CMDNAME="`basename $0`"
|
||||||
|
|
||||||
@ -15,6 +15,11 @@ VERSION='@VERSION@'
|
|||||||
MULTIBYTE='@MULTIBYTE@'
|
MULTIBYTE='@MULTIBYTE@'
|
||||||
bindir='@bindir@'
|
bindir='@bindir@'
|
||||||
|
|
||||||
|
# These handle spaces/tabs in identifiers
|
||||||
|
_IFS="$IFS"
|
||||||
|
NL="
|
||||||
|
"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Find out where we're located
|
# Find out where we're located
|
||||||
#
|
#
|
||||||
@ -25,7 +30,10 @@ if echo "$0" | grep '/' > /dev/null 2>&1 ; then
|
|||||||
else
|
else
|
||||||
# look for it in PATH ('which' command is not portable)
|
# look for it in PATH ('which' command is not portable)
|
||||||
echo "$PATH" | sed 's/:/\
|
echo "$PATH" | sed 's/:/\
|
||||||
/g' | while read dir; do
|
/g' | while :; do
|
||||||
|
IFS="$NL"
|
||||||
|
read dir || break
|
||||||
|
IFS="$_IFS"
|
||||||
# empty entry in path means current dir
|
# empty entry in path means current dir
|
||||||
[ x"$dir" = x ] && dir='.'
|
[ x"$dir" = x ] && dir='.'
|
||||||
if [ -f "$dir/$CMDNAME" ] ; then
|
if [ -f "$dir/$CMDNAME" ] ; then
|
||||||
@ -197,9 +205,12 @@ echo
|
|||||||
|
|
||||||
$PSQL -d template1 -At -F '
|
$PSQL -d template1 -At -F '
|
||||||
' -c 'SELECT groname,grosysid,grolist FROM pg_group;' | \
|
' -c 'SELECT groname,grosysid,grolist FROM pg_group;' | \
|
||||||
while read GRONAME ; do
|
while : ; do
|
||||||
read GROSYSID
|
IFS="$NL"
|
||||||
read GROLIST
|
read GRONAME || break
|
||||||
|
read GROSYSID || break
|
||||||
|
read GROLIST || break
|
||||||
|
IFS="$_IFS"
|
||||||
echo "CREATE GROUP \"$GRONAME\" WITH SYSID ${GROSYSID};"
|
echo "CREATE GROUP \"$GRONAME\" WITH SYSID ${GROSYSID};"
|
||||||
echo "$GROLIST" | sed 's/^{\(.*\)}$/\1/' | tr ',' '\n' |
|
echo "$GROLIST" | sed 's/^{\(.*\)}$/\1/' | tr ',' '\n' |
|
||||||
while read userid; do
|
while read userid; do
|
||||||
@ -224,10 +235,12 @@ exec 4<&0
|
|||||||
$PSQL -d template1 -At -F '
|
$PSQL -d template1 -At -F '
|
||||||
' -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 read DATABASE ; do
|
||||||
|
IFS="$NL"
|
||||||
read DBOWNER
|
read DBOWNER
|
||||||
read ENCODING
|
read ENCODING
|
||||||
read ISTEMPLATE
|
read ISTEMPLATE
|
||||||
read DBPATH
|
read DBPATH
|
||||||
|
IFS="$_IFS"
|
||||||
if [ "$DATABASE" != template1 ] ; then
|
if [ "$DATABASE" != template1 ] ; then
|
||||||
echo
|
echo
|
||||||
|
|
||||||
@ -251,7 +264,10 @@ done
|
|||||||
|
|
||||||
$PSQL -d template1 -At -F '
|
$PSQL -d template1 -At -F '
|
||||||
' -c "SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;" | \
|
' -c "SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;" | \
|
||||||
while read DATABASE; do
|
while :; do
|
||||||
|
IFS="$NL"
|
||||||
|
read DATABASE || break
|
||||||
|
IFS="$_IFS"
|
||||||
echo "dumping database \"$DATABASE\"..." 1>&2
|
echo "dumping database \"$DATABASE\"..." 1>&2
|
||||||
echo
|
echo
|
||||||
echo "--"
|
echo "--"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user