On 04/24/2011 07:31 PM, Peter Eisentraut wrote:
On sön, 2011-04-24 at 12:25 -0400, Tom Lane wrote:
This file is in fundamental violation of the first commandment of
Postgres #includes, which is "thou shalt have no other gods before c.h".
We need to put postgres.h *before* the Python.h include. I don't know
what issues led to the current arrangement but it is fraught with
portability gotchas. In particular it's just about guaranteed to fail
on platforms where<stdio.h> reacts to _FILE_OFFSET_BITS --- plpython.c
is going to get compiled expecting a different stdio library than the
rest of the backend.
Here is where this happened:
commit ab6ee1f9fc7039b1e8d8ebf939da3fd55e73efad
Author: Joe Conway<m...@joeconway.com>
Date: Thu Aug 5 03:10:29 2004 +0000
Move include for Python.h above postgres.h to eliminate compiler warning.
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index 76ea031..07eed86 100644
--- a/src/pl/plpython/plpython.c
+++ b/src/pl/plpython/plpython.c
@@ -29,11 +29,12 @@
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.52 2004/08/04 21:34:29
tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.53 2004/08/05 03:10:29
joe Exp $
*
*********************************************************************
*/
+#include<Python.h>
#include "postgres.h"
/* system stuff */
@@ -54,7 +55,6 @@
#include "utils/syscache.h"
#include "utils/typcache.h"
-#include<Python.h>
#include<compile.h>
#include<eval.h>
If you switch it back around, you indeed get a bunch of annoying
warnings. This will need some playing around it get right.
On my Linux system the attached compiles without warnings. If this seems
like the way to go I'll investigate more on Windows.
cheers
andrew
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index e03d7ce..cfe7f78 100644
--- a/src/pl/plpython/plpython.c
+++ b/src/pl/plpython/plpython.c
@@ -6,6 +6,21 @@
*********************************************************************
*/
+#include "postgres.h"
+
+/*
+ * Save settings the Python headers might override
+ */
+#ifdef _POSIX_C_SOURCE
+#define _PGSAVE_POSIX_C_SOURCE _POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#endif
+
+#ifdef _XOPEN_SOURCE
+#define _PGSAVE_XOPEN_SOURCE _XOPEN_SOURCE
+#undef _XOPEN_SOURCE
+#endif
+
#if defined(_MSC_VER) && defined(_DEBUG)
/* Python uses #pragma to bring in a non-default libpython on VC++ if
* _DEBUG is defined */
@@ -84,7 +99,20 @@ typedef int Py_ssize_t;
PyObject_HEAD_INIT(type) size,
#endif
-#include "postgres.h"
+/*
+ * Restore settings the Python headers might have overridden.
+ */
+#ifdef _PGSAVE_POSIX_C_SOURCE
+#undef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE _PGSAVE_POSIX_C_SOURCE
+#undef _PGSAVE_POSIX_C_SOURCE
+#endif
+
+#ifdef _PGSAVE_XOPEN_SOURCE
+#undef _XOPEN_SOURCE
+#define _XOPEN_SOURCE _PGSAVE_XOPEN_SOURCE
+#undef _PGSAVE_XOPEN_SOURCE
+#endif
/* system stuff */
#include <unistd.h>
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers