Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7ee3c35

Browse files
committed
Allow libpgport to call memory allocation routines even though
CurrentMemoryContext is DLLIMPORT on Win32. Work around that bycreating stubs in the backend for palloc/pstrdup.Also fix pg_dumpall to do proper quoting on Win32.
1 parent881ea47 commit7ee3c35

File tree

5 files changed

+72
-6
lines changed

5 files changed

+72
-6
lines changed

‎src/backend/utils/mmgr/mcxt.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.46 2004/07/01 00:51:29 tgl Exp $
17+
* $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.47 2004/08/08 06:44:32 momjian Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -629,3 +629,38 @@ MemoryContextStrdup(MemoryContext context, const char *string)
629629

630630
returnnstr;
631631
}
632+
633+
634+
#ifdefWIN32
635+
/*
636+
*Memory support routines for libpgport on Win32
637+
*
638+
*Win32 can't load a library that DLLIMPORTs a variable
639+
*if the link object files also DLLIMPORT the same variable.
640+
*For this reason, libpgport can't reference CurrentMemoryContext
641+
*in the palloc macro calls.
642+
*
643+
*To fix this, we create several functions here that allow us to
644+
*manage memory without doing the inline in libpgport.
645+
*/
646+
void*
647+
pgport_palloc(Sizesz)
648+
{
649+
returnpalloc(sz);
650+
}
651+
652+
char*
653+
pgport_pstrdup(constchar*str)
654+
{
655+
returnpstrdup(str);
656+
}
657+
658+
659+
/* Doesn't reference a DLLIMPORT variable, but here for completeness. */
660+
void
661+
pgport_pfree(void*pointer)
662+
{
663+
pfree(pointer);
664+
return;
665+
}
666+
#endif

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.46 2004/08/04 21:34:12 tgl Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.47 2004/08/08 06:44:33 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -840,21 +840,39 @@ runPgDump(const char *dbname)
840840
constchar*p;
841841
intret;
842842

843+
/*
844+
*Win32 has to use double-quotes for args, rather than single quotes.
845+
*Strangely enough, this is the only place we pass a database name
846+
*on the command line, except template1 that doesn't need quoting.
847+
*/
848+
#ifndefWIN32
843849
appendPQExpBuffer(cmd,"%s\"%s\" %s -Fp '",SYSTEMQUOTE,pg_dump_bin,
850+
#else
851+
appendPQExpBuffer(cmd,"%s\"%s\" %s -Fp \"",SYSTEMQUOTE,pg_dump_bin,
852+
#endif
844853
pgdumpopts->data);
845854

846855
/* Shell quoting is not quite like SQL quoting, so can't use fmtId */
847856
for (p=dbname;*p;p++)
848857
{
858+
#ifndefWIN32
849859
if (*p=='\'')
850860
appendPQExpBuffer(cmd,"'\"'\"'");
851861
else
862+
#endif
863+
/* not needed on Win32 */
852864
appendPQExpBufferChar(cmd,*p);
853865
}
854866

867+
#ifndefWIN32
855868
appendPQExpBufferChar(cmd,'\'');
856-
appendStringLiteral(cmd,SYSTEMQUOTE, false);
869+
#else
870+
appendPQExpBufferChar(cmd,'"');
871+
#endif
857872

873+
if (strlen(SYSTEMQUOTE)>0)
874+
appendPQExpBuffer(cmd,SYSTEMQUOTE);
875+
858876
if (verbose)
859877
fprintf(stderr,_("%s: running \"%s\"\n"),progname,cmd->data);
860878

‎src/include/port.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.49 2004/08/0801:43:33 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.50 2004/08/0806:44:33 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -151,6 +151,7 @@ extern intpgsymlink(const char *oldpath, const char *newpath);
151151
#definerename(from,to)pgrename(from, to)
152152
#defineunlink(path)pgunlink(path)
153153
#definesymlink(oldpath,newpath)pgsymlink(oldpath, newpath)
154+
154155
#endif
155156

156157
externboolrmtree(char*path,boolrmtopdir);

‎src/include/utils/palloc.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
2222
* Portions Copyright (c) 1994, Regents of the University of California
2323
*
24-
* $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.27 2003/11/29 22:41:15 pgsql Exp $
24+
* $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.28 2004/08/08 06:44:35 momjian Exp $
2525
*
2626
*-------------------------------------------------------------------------
2727
*/
@@ -80,4 +80,9 @@ extern char *MemoryContextStrdup(MemoryContext context, const char *string);
8080

8181
#definepstrdup(str) MemoryContextStrdup(CurrentMemoryContext, (str))
8282

83+
/* Used for Win32 */
84+
void*pgport_palloc(Sizesz);
85+
char*pgport_pstrdup(constchar*str);
86+
voidpgport_pfree(void*pointer);
87+
8388
#endif/* PALLOC_H */

‎src/port/dirmod.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*Win32 (NT, Win2k, XP).replace() doesn't work on Win95/98/Me.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.17 2004/08/0805:04:41 momjian Exp $
13+
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.18 2004/08/0806:44:36 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -38,6 +38,13 @@
3838
#undef rename
3939
#undef unlink
4040

41+
#ifndefFRONTEND
42+
#definepalloc(sz)pgport_palloc(sz)
43+
#definepstrdup(str)pgport_pstrdup(str)
44+
#definepfree(pointer)pgport_pfree(pointer)
45+
#endif
46+
47+
4148
/*
4249
*pgrename
4350
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp