diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c index d6875a79..3dbdbdc4 100644 --- a/psycopg/cursor_type.c +++ b/psycopg/cursor_type.c @@ -1026,11 +1026,13 @@ psyco_curs_callproc(cursorObject *self, PyObject *args) PyObject *res = NULL; int using_dict; +#if PG_VERSION_HEX >= 0x090000 PyObject *pname = NULL; PyObject *bpname = NULL; PyObject *pnames = NULL; char *cpname = NULL; char **scpnames = NULL; +#endif if (!PyArg_ParseTuple(args, "s#|O", &procname, &procname_len, ¶meters)) { @@ -1055,6 +1057,7 @@ psyco_curs_callproc(cursorObject *self, PyObject *args) /* A Dict is complicated. The parameter names go into the query */ if (using_dict) { +#if PG_VERSION_HEX >= 0x090000 if (!(pnames = PyDict_Keys(parameters))) { PyErr_SetString(PyExc_RuntimeError, "built-in 'keys' failed on a Dict!"); @@ -1119,6 +1122,11 @@ psyco_curs_callproc(cursorObject *self, PyObject *args) "built-in 'values' failed on a Dict!"); goto exit; } +#else + PyErr_SetString(PyExc_NotImplementedError, + "named parameters require psycopg2 compiled against libpq 9.0+"); + goto exit; +#endif } /* a list (or None, or empty data structure) is a little bit simpler */ @@ -1153,6 +1161,7 @@ psyco_curs_callproc(cursorObject *self, PyObject *args) } exit: +#if PG_VERSION_HEX >= 0x090000 if (scpnames != NULL) { for (i = 0; i < nparameters; i++) { if (scpnames[i] != NULL) { @@ -1162,6 +1171,7 @@ exit: } PyMem_Del(scpnames); Py_XDECREF(pnames); +#endif Py_XDECREF(operation); PyMem_Free((void*)sql); return res;