mirror of
https://github.com/postgres/postgres.git
synced 2025-06-23 14:01:44 +03:00
Handle multiple double-quoted strings using Win32's system() call.
Document limitations.
This commit is contained in:
@ -39,7 +39,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
* Portions taken from FreeBSD.
|
* Portions taken from FreeBSD.
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.35 2004/06/03 00:07:36 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.36 2004/06/10 16:35:16 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -812,12 +812,12 @@ test_connections(void)
|
|||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
snprintf(cmd, sizeof(cmd),
|
snprintf(cmd, sizeof(cmd),
|
||||||
"\"%s\" -boot -x0 %s "
|
"%s\"%s\" -boot -x0 %s "
|
||||||
"-c shared_buffers=%d -c max_connections=%d template1 "
|
"-c shared_buffers=%d -c max_connections=%d template1 "
|
||||||
"<%s >%s 2>&1",
|
"< \"%s\" > \"%s\" 2>&1%s",
|
||||||
backend_exec, boot_options,
|
SYSTEMQUOTE, backend_exec, boot_options,
|
||||||
conns[i] * 5, conns[i],
|
conns[i] * 5, conns[i],
|
||||||
DEVNULL, DEVNULL);
|
DEVNULL, DEVNULL, SYSTEMQUOTE);
|
||||||
status = system(cmd);
|
status = system(cmd);
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
break;
|
break;
|
||||||
@ -848,12 +848,12 @@ test_buffers(void)
|
|||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
snprintf(cmd, sizeof(cmd),
|
snprintf(cmd, sizeof(cmd),
|
||||||
"\"%s\" -boot -x0 %s "
|
"%s\"%s\" -boot -x0 %s "
|
||||||
"-c shared_buffers=%d -c max_connections=%d template1 "
|
"-c shared_buffers=%d -c max_connections=%d template1 "
|
||||||
"<%s >%s 2>&1",
|
"< \"%s\" > \"%s\" 2>&1%s",
|
||||||
backend_exec, boot_options,
|
SYSTEMQUOTE, backend_exec, boot_options,
|
||||||
bufs[i], n_connections,
|
bufs[i], n_connections,
|
||||||
DEVNULL, DEVNULL);
|
DEVNULL, DEVNULL, SYSTEMQUOTE);
|
||||||
status = system(cmd);
|
status = system(cmd);
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
break;
|
break;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.8 2004/06/09 17:36:07 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.9 2004/06/10 16:35:17 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -224,11 +224,12 @@ start_postmaster(void)
|
|||||||
|
|
||||||
/* Does '&' work on Win32? */
|
/* Does '&' work on Win32? */
|
||||||
if (log_file != NULL)
|
if (log_file != NULL)
|
||||||
snprintf(cmd, MAXPGPATH, "'%s' %s < %s >> '%s' 2>&1 &",
|
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s < %s >> \"%s\" 2>&1 &%s",
|
||||||
postgres_path, post_opts, DEVNULL, log_file);
|
SYSTEMQUOTE, postgres_path, post_opts, DEVNULL, log_file,
|
||||||
|
SYSTEMQUOTE);
|
||||||
else
|
else
|
||||||
snprintf(cmd, MAXPGPATH, "'%s' %s < %s 2>&1 &",
|
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s < \"%s\" 2>&1 &%s",
|
||||||
postgres_path, post_opts, DEVNULL);
|
SYSTEMQUOTE, postgres_path, post_opts, DEVNULL, SYSTEMQUOTE);
|
||||||
return system(cmd);
|
return system(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.40 2004/06/09 17:37:28 momjian Exp $
|
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.41 2004/06/10 16:35:17 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -690,7 +690,8 @@ runPgDump(const char *dbname)
|
|||||||
const char *p;
|
const char *p;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
appendPQExpBuffer(cmd, "'%s' %s -Fp '", pg_dump_bin, pgdumpopts->data);
|
appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp '", SYSTEMQUOTE, pg_dump_bin,
|
||||||
|
pgdumpopts->data);
|
||||||
|
|
||||||
/* Shell quoting is not quite like SQL quoting, so can't use fmtId */
|
/* Shell quoting is not quite like SQL quoting, so can't use fmtId */
|
||||||
for (p = dbname; *p; p++)
|
for (p = dbname; *p; p++)
|
||||||
@ -702,6 +703,7 @@ runPgDump(const char *dbname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBufferChar(cmd, '\'');
|
appendPQExpBufferChar(cmd, '\'');
|
||||||
|
appendStringLiteral(cmd, SYSTEMQUOTE, false);
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr, _("%s: running \"%s\"\n"), progname, cmd->data);
|
fprintf(stderr, _("%s: running \"%s\"\n"), progname, cmd->data);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/port.h,v 1.40 2004/06/03 00:07:38 momjian Exp $
|
* $PostgreSQL: pgsql/src/include/port.h,v 1.41 2004/06/10 16:35:18 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -72,6 +72,18 @@ extern int find_other_exec(const char *argv0, const char *target,
|
|||||||
#define DEVNULL "/dev/null"
|
#define DEVNULL "/dev/null"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Win32 needs double quotes at the beginning and end of system()
|
||||||
|
* strings. If not, it gets confused with multiple quoted strings.
|
||||||
|
* It also must use double-quotes around the executable name
|
||||||
|
* and any files use for redirection. Other args can use single-quotes.
|
||||||
|
*/
|
||||||
|
#ifdef WIN32
|
||||||
|
#define SYSTEMQUOTE "\""
|
||||||
|
#else
|
||||||
|
#define SYSTEMQUOTE ""
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Portable delay handling */
|
/* Portable delay handling */
|
||||||
extern void pg_usleep(long microsec);
|
extern void pg_usleep(long microsec);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user