mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Quote database name properly when invoking pg_dump. Per report from
Christopher Kings-Lynne.
This commit is contained in:
parent
fadcb01177
commit
1f79360907
@ -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
|
|||||||
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)
|
|||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
|
||||||
ret = system(cmd->data);
|
ret = system(cmd->data);
|
||||||
|
|
||||||
destroyPQExpBuffer(cmd);
|
destroyPQExpBuffer(cmd);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user