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

Commit2dd06b0

Browse files
committed
Make sure leading/trailing/multiple consecutive space/tab in db/user/group
names are handled OK.
1 parent902a6a0 commit2dd06b0

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

‎src/bin/pg_dump/pg_dumpall.sh‎

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
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.18 2002/04/1119:23:36 momjian Exp $
9+
# $Header: /cvsroot/pgsql/src/bin/pg_dump/Attic/pg_dumpall.sh,v 1.19 2002/04/1121:16:28 momjian Exp $
1010

1111
CMDNAME="`basename$0`"
1212

@@ -15,6 +15,11 @@ VERSION='@VERSION@'
1515
MULTIBYTE='@MULTIBYTE@'
1616
bindir='@bindir@'
1717

18+
# These handle spaces/tabs in identifiers
19+
_IFS="$IFS"
20+
NL="
21+
"
22+
1823
#
1924
# Find out where we're located
2025
#
@@ -25,7 +30,10 @@ if echo "$0" | grep '/' > /dev/null 2>&1 ; then
2530
else
2631
# look for it in PATH ('which' command is not portable)
2732
echo"$PATH"| sed's/:/\
28-
/g'|whileread dir;do
33+
/g'|while:;do
34+
IFS="$NL"
35+
read dir||break
36+
IFS="$_IFS"
2937
# empty entry in path means current dir
3038
[ x"$dir"= x ]&& dir='.'
3139
if [-f"$dir/$CMDNAME" ];then
@@ -197,9 +205,12 @@ echo
197205

198206
$PSQL -d template1 -At -F'
199207
' -c'SELECT groname,grosysid,grolist FROM pg_group;'| \
200-
whileread GRONAME;do
201-
read GROSYSID
202-
read GROLIST
208+
while:;do
209+
IFS="$NL"
210+
read GRONAME||break
211+
read GROSYSID||break
212+
read GROLIST||break
213+
IFS="$_IFS"
203214
echo"CREATE GROUP\"$GRONAME\" WITH SYSID${GROSYSID};"
204215
echo"$GROLIST"| sed's/^{\(.*\)}$/\1/'| tr',''\n'|
205216
whileread userid;do
@@ -224,10 +235,12 @@ exec 4<&0
224235
$PSQL -d template1 -At -F'
225236
' -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;"| \
226237
whileread DATABASE;do
238+
IFS="$NL"
227239
read DBOWNER
228240
read ENCODING
229241
read ISTEMPLATE
230242
read DBPATH
243+
IFS="$_IFS"
231244
if ["$DATABASE"!= template1 ];then
232245
echo
233246

@@ -251,7 +264,10 @@ done
251264

252265
$PSQL -d template1 -At -F'
253266
' -c"SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1;"| \
254-
whileread DATABASE;do
267+
while:;do
268+
IFS="$NL"
269+
read DATABASE||break
270+
IFS="$_IFS"
255271
echo"dumping database\"$DATABASE\"..."1>&2
256272
echo
257273
echo"--"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp