diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c index 96ffb1a8e1ccf1f2d3d730cf3114fae2e3475d25..28e9d26a2f902c9f3b141ce1752844de77810ea1 100644 --- a/src/backend/utils/mmgr/mcxt.c +++ b/src/backend/utils/mmgr/mcxt.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.46 2004/07/01 00:51:29 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.47 2004/08/08 06:44:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -629,3 +629,38 @@ MemoryContextStrdup(MemoryContext context, const char *string) return nstr; } + + +#ifdef WIN32 +/* + * Memory support routines for libpgport on Win32 + * + * Win32 can't load a library that DLLIMPORTs a variable + * if the link object files also DLLIMPORT the same variable. + * For this reason, libpgport can't reference CurrentMemoryContext + * in the palloc macro calls. + * + * To fix this, we create several functions here that allow us to + * manage memory without doing the inline in libpgport. + */ +void * +pgport_palloc(Size sz) +{ + return palloc(sz); +} + +char * +pgport_pstrdup(const char *str) +{ + return pstrdup(str); +} + + +/* Doesn't reference a DLLIMPORT variable, but here for completeness. */ +void +pgport_pfree(void *pointer) +{ + pfree(pointer); + return; +} +#endif diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index d260f2c0b222c895482f7e3bae68dcc25278f044..a79cf836b27aab3895650a5a43b75babb71afb5d 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.46 2004/08/04 21:34:12 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.47 2004/08/08 06:44:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -840,21 +840,39 @@ runPgDump(const char *dbname) const char *p; int ret; + /* + * Win32 has to use double-quotes for args, rather than single quotes. + * Strangely enough, this is the only place we pass a database name + * on the command line, except template1 that doesn't need quoting. + */ +#ifndef WIN32 appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp '", SYSTEMQUOTE, pg_dump_bin, +#else + appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp \"", SYSTEMQUOTE, pg_dump_bin, +#endif pgdumpopts->data); /* Shell quoting is not quite like SQL quoting, so can't use fmtId */ for (p = dbname; *p; p++) { +#ifndef WIN32 if (*p == '\'') appendPQExpBuffer(cmd, "'\"'\"'"); else +#endif + /* not needed on Win32 */ appendPQExpBufferChar(cmd, *p); } +#ifndef WIN32 appendPQExpBufferChar(cmd, '\''); - appendStringLiteral(cmd, SYSTEMQUOTE, false); +#else + appendPQExpBufferChar(cmd, '"'); +#endif + if (strlen(SYSTEMQUOTE) > 0) + appendPQExpBuffer(cmd, SYSTEMQUOTE); + if (verbose) fprintf(stderr, _("%s: running \"%s\"\n"), progname, cmd->data); diff --git a/src/include/port.h b/src/include/port.h index c2bcea78bfb4e5c82852491f85eb09dba47a4adc..e7ffdce362ea51a2ddbe90ad1a76cb08f749a409 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/port.h,v 1.49 2004/08/08 01:43:33 momjian Exp $ + * $PostgreSQL: pgsql/src/include/port.h,v 1.50 2004/08/08 06:44:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -151,6 +151,7 @@ extern int pgsymlink(const char *oldpath, const char *newpath); #define rename(from, to) pgrename(from, to) #define unlink(path) pgunlink(path) #define symlink(oldpath, newpath) pgsymlink(oldpath, newpath) + #endif extern bool rmtree(char *path, bool rmtopdir); diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h index b0a6760f5ed86cd5b6303a7ce53afc6c1bfbbc27..8dfa98bf9789a9a77fa032c19b9b3542ce67f823 100644 --- a/src/include/utils/palloc.h +++ b/src/include/utils/palloc.h @@ -21,7 +21,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.27 2003/11/29 22:41:15 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.28 2004/08/08 06:44:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -80,4 +80,9 @@ extern char *MemoryContextStrdup(MemoryContext context, const char *string); #define pstrdup(str) MemoryContextStrdup(CurrentMemoryContext, (str)) +/* Used for Win32 */ +void *pgport_palloc(Size sz); +char *pgport_pstrdup(const char *str); +void pgport_pfree(void *pointer); + #endif /* PALLOC_H */ diff --git a/src/port/dirmod.c b/src/port/dirmod.c index 5413253efdd78b9b93a22e4314a74c29158b5a9a..7c87c0fff0c08faa6544db821e2f386e5e1689af 100644 --- a/src/port/dirmod.c +++ b/src/port/dirmod.c @@ -10,7 +10,7 @@ * Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me. * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/dirmod.c,v 1.17 2004/08/08 05:04:41 momjian Exp $ + * $PostgreSQL: pgsql/src/port/dirmod.c,v 1.18 2004/08/08 06:44:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,6 +38,13 @@ #undef rename #undef unlink +#ifndef FRONTEND +#define palloc(sz) pgport_palloc(sz) +#define pstrdup(str) pgport_pstrdup(str) +#define pfree(pointer) pgport_pfree(pointer) +#endif + + /* * pgrename */