mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-11 11:36:37 +03:00
callproc: checking for libpq 9.0+ on compile. yes: use PQescapeIdentifier. no: error
This commit is contained in:
parent
3948e909e4
commit
37a80e9de8
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue
Block a user