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

Commita11cf43

Browse files
committed
Restore the primacy of postgres.h in plpython.c.
To avoid having the python headers hijack various definitions,we now include them after all the system headers we want, havingfirst undefined some of the things they want to define. After that'sdone we restore the things they scribbled on that matter, namely oursnprintf and vsnprintf macros, if we're using them.
1 parent84e3712 commita11cf43

File tree

1 file changed

+67
-28
lines changed

1 file changed

+67
-28
lines changed

‎src/pl/plpython/plpython.c

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,56 @@
66
*********************************************************************
77
*/
88

9+
#include"postgres.h"
10+
11+
/* system stuff */
12+
#include<unistd.h>
13+
#include<fcntl.h>
14+
15+
/* postgreSQL stuff */
16+
#include"catalog/pg_proc.h"
17+
#include"catalog/pg_type.h"
18+
#include"commands/trigger.h"
19+
#include"executor/spi.h"
20+
#include"funcapi.h"
21+
#include"fmgr.h"
22+
#include"mb/pg_wchar.h"
23+
#include"miscadmin.h"
24+
#include"nodes/makefuncs.h"
25+
#include"parser/parse_type.h"
26+
#include"tcop/tcopprot.h"
27+
#include"access/transam.h"
28+
#include"access/xact.h"
29+
#include"utils/builtins.h"
30+
#include"utils/hsearch.h"
31+
#include"utils/lsyscache.h"
32+
#include"utils/memutils.h"
33+
#include"utils/rel.h"
34+
#include"utils/syscache.h"
35+
#include"utils/typcache.h"
36+
37+
/*
38+
* Undefine some things that get (re)defined in the
39+
* Python headers. They aren't used below and we've
40+
* already included all the headers we need, so this
41+
* should be pretty safe.
42+
*/
43+
44+
#undef _POSIX_C_SOURCE
45+
#undef _XOPEN_SOURCE
46+
#undef HAVE_STRERROR
47+
#undef HAVE_TZNAME
48+
49+
/*
50+
* Sometimes python carefully scribbles on our *printf macros.
51+
* So we undefine them here and redefine them after it's done its dirty deed.
52+
*/
53+
54+
#ifdefUSE_REPL_SNPRINTF
55+
#undef snprintf
56+
#undef vsnprintf
57+
#endif
58+
959
#if defined(_MSC_VER)&& defined(_DEBUG)
1060
/* Python uses #pragma to bring in a non-default libpython on VC++ if
1161
* _DEBUG is defined */
@@ -84,41 +134,30 @@ typedef int Py_ssize_t;
84134
PyObject_HEAD_INIT(type) size,
85135
#endif
86136

87-
#include"postgres.h"
88-
89-
/* system stuff */
90-
#include<unistd.h>
91-
#include<fcntl.h>
92-
93-
/* postgreSQL stuff */
94-
#include"catalog/pg_proc.h"
95-
#include"catalog/pg_type.h"
96-
#include"commands/trigger.h"
97-
#include"executor/spi.h"
98-
#include"funcapi.h"
99-
#include"fmgr.h"
100-
#include"mb/pg_wchar.h"
101-
#include"miscadmin.h"
102-
#include"nodes/makefuncs.h"
103-
#include"parser/parse_type.h"
104-
#include"tcop/tcopprot.h"
105-
#include"access/transam.h"
106-
#include"access/xact.h"
107-
#include"utils/builtins.h"
108-
#include"utils/hsearch.h"
109-
#include"utils/lsyscache.h"
110-
#include"utils/memutils.h"
111-
#include"utils/rel.h"
112-
#include"utils/syscache.h"
113-
#include"utils/typcache.h"
114-
115137
/* define our text domain for translations */
116138
#undef TEXTDOMAIN
117139
#defineTEXTDOMAIN PG_TEXTDOMAIN("plpython")
118140

119141
#include<compile.h>
120142
#include<eval.h>
121143

144+
/* put back our snprintf and vsnprintf */
145+
#ifdefUSE_REPL_SNPRINTF
146+
#ifdefsnprintf
147+
#undef snprintf
148+
#endif
149+
#ifdefvsnprintf
150+
#undef vsnprintf
151+
#endif
152+
#ifdef__GNUC__
153+
#definevsnprintf(...) pg_vsnprintf(__VA_ARGS__)
154+
#definesnprintf(...) pg_snprintf(__VA_ARGS__)
155+
#else
156+
#definevsnprintf pg_vsnprintf
157+
#definesnprintf pg_snprintf
158+
#endif/* __GNUC__ */
159+
#endif/* USE_REPL_SNPRINTF */
160+
122161
PG_MODULE_MAGIC;
123162

124163
/* convert Postgresql Datum or tuple into a PyObject.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp