summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrmilosz <milosz@milosz.ca>2014-05-29 05:09:09 -0400
committermrmilosz <milosz@milosz.ca>2015-12-12 17:49:44 -0500
commit37a80e9de8d6df13d9e43e4106b62cf74308c5d9 (patch)
tree65a87388265ee0ca878b044b4da3b8565e916291
parent3948e909e46bab420d0c40bda21a32bfa501bd19 (diff)
downloadpsycopg2-37a80e9de8d6df13d9e43e4106b62cf74308c5d9.tar.gz
callproc: checking for libpq 9.0+ on compile. yes: use PQescapeIdentifier. no: error
-rw-r--r--psycopg/cursor_type.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/psycopg/cursor_type.c b/psycopg/cursor_type.c
index d6875a7..3dbdbdc 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,
&parameters)) {
@@ -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;