Quote database name properly when invoking pg_dump. Per report from

Christopher Kings-Lynne.
This commit is contained in:
Tom Lane 2002-11-22 03:09:43 +00:00
parent fadcb01177
commit 1f79360907

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.9 2002/10/18 22:05:36 petere Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.10 2002/11/22 03:09:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -589,10 +589,23 @@ static int
runPgDump(const char *dbname)
{
PQExpBuffer cmd = createPQExpBuffer();
const char *p;
int ret;
appendPQExpBuffer(cmd, "%s %s -X use-set-session-authorization -Fp %s",
pgdumploc, pgdumpopts->data, dbname);
appendPQExpBuffer(cmd, "%s %s -X use-set-session-authorization -Fp '",
pgdumploc, pgdumpopts->data);
/* Shell quoting is not quite like SQL quoting, so can't use fmtId */
for (p = dbname; *p; p++)
{
if (*p == '\'')
appendPQExpBuffer(cmd, "'\"'\"'");
else
appendPQExpBufferChar(cmd, *p);
}
appendPQExpBufferChar(cmd, '\'');
if (verbose)
fprintf(stderr, _("%s: running %s\n"), progname, cmd->data);
@ -600,6 +613,7 @@ runPgDump(const char *dbname)
fflush(stderr);
ret = system(cmd->data);
destroyPQExpBuffer(cmd);
return ret;