Thread: BUG: compiling PL/Python - Semi-SOLVED

BUG: compiling PL/Python - Semi-SOLVED

From
"Nikola Milutinovic"
Date:
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.