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

Commit1f79360

Browse files
committed
Quote database name properly when invoking pg_dump. Per report from
Christopher Kings-Lynne.
1 parentfadcb01 commit1f79360

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.9 2002/10/18 22:05:36 petere Exp $
9+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.10 2002/11/22 03:09:43 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -589,17 +589,31 @@ static int
589589
runPgDump(constchar*dbname)
590590
{
591591
PQExpBuffercmd=createPQExpBuffer();
592+
constchar*p;
592593
intret;
593594

594-
appendPQExpBuffer(cmd,"%s %s -X use-set-session-authorization -Fp %s",
595-
pgdumploc,pgdumpopts->data,dbname);
595+
appendPQExpBuffer(cmd,"%s %s -X use-set-session-authorization -Fp '",
596+
pgdumploc,pgdumpopts->data);
597+
598+
/* Shell quoting is not quite like SQL quoting, so can't use fmtId */
599+
for (p=dbname;*p;p++)
600+
{
601+
if (*p=='\'')
602+
appendPQExpBuffer(cmd,"'\"'\"'");
603+
else
604+
appendPQExpBufferChar(cmd,*p);
605+
}
606+
607+
appendPQExpBufferChar(cmd,'\'');
608+
596609
if (verbose)
597610
fprintf(stderr,_("%s: running %s\n"),progname,cmd->data);
598611

599612
fflush(stdout);
600613
fflush(stderr);
601614

602615
ret=system(cmd->data);
616+
603617
destroyPQExpBuffer(cmd);
604618

605619
returnret;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp