Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita62f43a

Browse files
committed
Fix problem with invalid database name assignment in while loop.
Properly warn of invalid pg_dumpall options; minor quoting cleanups.
1 parent5c1f31d commita62f43a

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

‎src/bin/pg_dump/pg_dumpall.sh

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
# and "pg_group" tables, which belong to the whole installation rather
77
# than any one individual database.
88
#
9-
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_dumpall.sh,v 1.16 2002/02/24 21:57:23 tgl Exp $
9+
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_dumpall.sh,v 1.17 2002/04/11 04:56:21 momjian Exp $
1010

11-
CMDNAME=`basename$0`
11+
CMDNAME="`basename$0`"
1212

1313
# substituted at build
1414
VERSION='@VERSION@'
@@ -21,7 +21,7 @@ bindir='@bindir@'
2121
PGPATH=
2222
ifecho"$0"| grep'/'> /dev/null2>&1;then
2323
# explicit dir name given
24-
PGPATH=`echo$0| sed's,/[^/]*$,,'`# (dirname command is not portable)
24+
PGPATH=`echo"$0"| sed's,/[^/]*$,,'`# (dirname command is not portable)
2525
else
2626
# look for it in PATH ('which' command is not portable)
2727
fordirin`echo"$PATH"| sed's/:/ /g'`;do
@@ -78,7 +78,7 @@ globals_only=
7878

7979

8080
while ["$#"-gt 0 ];do
81-
case$1in
81+
case"$1"in
8282
--help)
8383
usage=t
8484
break
@@ -94,7 +94,7 @@ while [ "$#" -gt 0 ] ; do
9494
connectopts="$connectopts$1"
9595
;;
9696
--host=*)
97-
connectopts="$connectopts -h"`echo$1| sed's/^--host=//'`
97+
connectopts="$connectopts -h`echo$1| sed's/^--host=//'`"
9898
;;
9999
--port|-p)
100100
connectopts="$connectopts -p$2"
@@ -103,7 +103,7 @@ while [ "$#" -gt 0 ] ; do
103103
connectopts="$connectopts$1"
104104
;;
105105
--port=*)
106-
connectopts="$connectopts -p"`echo$1| sed's/^--port=//'`
106+
connectopts="$connectopts -p`echo$1| sed's/^--port=//'`"
107107
;;
108108
--user|--username|-U)
109109
connectopts="$connectopts -U$2"
@@ -112,7 +112,7 @@ while [ "$#" -gt 0 ] ; do
112112
connectopts="$connectopts$1"
113113
;;
114114
--user=*|--username=*)
115-
connectopts="$connectopts -U"`echo$1| sed's/^--user[^=]*=//'`
115+
connectopts="$connectopts -U`echo$1| sed's/^--user[^=]*=//'`"
116116
;;
117117
-W|--password)
118118
connectopts="$connectopts -W"
@@ -125,6 +125,10 @@ while [ "$#" -gt 0 ] ; do
125125
-g|--globals-only)
126126
globals_only=yes
127127
;;
128+
-F*|--format=*|-f|--file=*|-t|--table=*)
129+
echo"pg_dump can not process option$1, exiting"1>&2
130+
exit 1
131+
;;
128132
*)
129133
pgdumpextraopts="$pgdumpextraopts$1"
130134
;;
@@ -214,12 +218,9 @@ exec 4<&0
214218
# We skip databases marked not datallowconn, since we'd be unable to
215219
# connect to them anyway (and besides, we don't want to dump template0).
216220

217-
DATABASES=""
218-
219221
$PSQL -d template1 -At -F'' \
220222
-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;"| \
221223
whileread DATABASE DBOWNER ENCODING ISTEMPLATE DBPATH;do
222-
DATABASES="$DATABASES$DATABASE"
223224

224225
if ["$DATABASE"!= template1 ];then
225226
echo
@@ -242,7 +243,9 @@ while read DATABASE DBOWNER ENCODING ISTEMPLATE DBPATH; do
242243
fi
243244
done
244245

245-
forDATABASEin$DATABASES;do
246+
$PSQL -d template1 -At -F'' \
247+
-c"SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;"| \
248+
whileread DATABASE;do
246249
echo"dumping database\"$DATABASE\"..."1>&2
247250
echo
248251
echo"--"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp