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.
This commit is contained in:
parent
881ea47d24
commit
7ee3c35152
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user