BUG: compiling PL/Python - Semi-SOLVED - Mailing list pgsql-general

From Nikola Milutinovic
Subject BUG: compiling PL/Python - Semi-SOLVED
Date
Msg-id 000901c3d148$cc84eda0$c53da8c0@home
Whole thread Raw
List pgsql-general
Hi all.
 
OS: Tru64 UNIX 4.0d
PG: PostgreSQL v7.4.1
PY: Python v2.3.3
 
I just ran into a minor bug while compiling PL/Python module. It bombed out on lines 153 and 160 of ./src/pl/plpython/plpython.c complaining on incomplete type "PyObject_HEAD".
 
The source of the problem were these two typedefs:
 
typedef struct PLyPlanObject
{
        PyObject_HEAD;
        void       *plan;                       /* return of an SPI_saveplan */
        int                     nargs;
        Oid                *types;
        Datum      *values;
        PLyTypeInfo *args;
}       PLyPlanObject;
 
typedef struct PLyResultObject
{
        PyObject_HEAD;
        /* HeapTuple *tuples; */
        PyObject   *nrows;                      /* number of rows returned by query */
        PyObject   *rows;                       /* data rows, or None if no data returned */
        PyObject   *status;                     /* query status, SPI_OK_*, or SPI_ERR_* */
}       PLyResultObject;
The problem is in ";" following "PyObject_HEAD". "PyObject_HEAD" is a macro defined as:
 
#define PyObject_HEAD                   \
        _PyObject_HEAD_EXTRA            \
        int ob_refcnt;                  \
        struct _typeobject *ob_type;
So, that in turn expanded to this:
 
typedef struct PLyResultObject
{
        int ob_refcnt ; struct _typeobject * ob_type ; ;
        PyObject   *nrows;
        PyObject   *rows;
        PyObject   *status;
}       PLyResultObject;
 
The problem is in that extra semicolon - it is an excess and when removed everything compiles OK. Using this in a regular local variable declaration will not cause problems, since an extra ";" will just be swallowed as an NoOp.
 
Nix.

pgsql-general by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: Re: postgresql.org server problems
Next
From: Michael Glaesemann
Date:
Subject: Re: Bug and/or feature? Complex data types in tables...