summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Momjian2004-08-08 06:44:36 +0000
committerBruce Momjian2004-08-08 06:44:36 +0000
commit7ee3c351522694dc6f8f0d6578394bdf5dec0b59 (patch)
treeca89b755bf06e58f99c44a2dee918b6c4bc23038
parent881ea47d248069a9597c292ca76891a67b1a6d6f (diff)
Allow libpgport to call memory allocation routines even though
CurrentMemoryContext is DLLIMPORT on Win32. Work around that by creating stubs in the backend for palloc/pstrdup. Also fix pg_dumpall to do proper quoting on Win32.
-rw-r--r--src/backend/utils/mmgr/mcxt.c37
-rw-r--r--src/bin/pg_dump/pg_dumpall.c22
-rw-r--r--src/include/port.h3
-rw-r--r--src/include/utils/palloc.h7
-rw-r--r--src/port/dirmod.c9
5 files changed, 72 insertions, 6 deletions
diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c
index 96ffb1a8e1c..28e9d26a2f9 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 d260f2c0b22..a79cf836b27 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 c2bcea78bfb..e7ffdce362e 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 b0a6760f5ed..8dfa98bf978 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 5413253efdd..7c87c0fff0c 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
*/