Commit 1f793609 authored by Tom Lane's avatar Tom Lane

Quote database name properly when invoking pg_dump. Per report from

Christopher Kings-Lynne.
parent fadcb011
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * 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 ...@@ -589,10 +589,23 @@ static int
runPgDump(const char *dbname) runPgDump(const char *dbname)
{ {
PQExpBuffer cmd = createPQExpBuffer(); PQExpBuffer cmd = createPQExpBuffer();
const char *p;
int ret; int ret;
appendPQExpBuffer(cmd, "%s %s -X use-set-session-authorization -Fp %s", appendPQExpBuffer(cmd, "%s %s -X use-set-session-authorization -Fp '",
pgdumploc, pgdumpopts->data, dbname); 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) if (verbose)
fprintf(stderr, _("%s: running %s\n"), progname, cmd->data); fprintf(stderr, _("%s: running %s\n"), progname, cmd->data);
...@@ -600,6 +613,7 @@ runPgDump(const char *dbname) ...@@ -600,6 +613,7 @@ runPgDump(const char *dbname)
fflush(stderr); fflush(stderr);
ret = system(cmd->data); ret = system(cmd->data);
destroyPQExpBuffer(cmd); destroyPQExpBuffer(cmd);
return ret; return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment