python cleanup

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: python cleanup
Date: 2011-07-24 23:46:31
Message-ID: 4E2CAED7.5000804@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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<mail(at)joeconway(dot)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

Attachment Content-Type Size
pythonh.patch text/x-patch 1.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2011-07-24 23:49:53 Re: libpq SSL with non-blocking sockets
Previous Message Joey Adams 2011-07-24 22:48:12 Re: Initial Review: JSON contrib modul was: Re: Another swing at JSON