mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-26 02:43:43 +03:00
Appliced callproc patch.
This commit is contained in:
parent
67720de497
commit
8920c2662b
|
@ -1,3 +1,9 @@
|
|||
2005-10-02 Federico Di Gregorio <fog@debian.org>
|
||||
|
||||
* psycopg/cursor_type.c (psyco_curs_callproc): applied callproc
|
||||
patch from Matt Goodall (added a check on _psyco_curs_execute
|
||||
return value and substituted malloc/free with PyMem versions.)
|
||||
|
||||
2005-10-01 Federico Di Gregorio <fog@debian.org>
|
||||
|
||||
* psycopg/connection_int.c: fixed segfault by moving PyErr_Format
|
||||
|
|
|
@ -803,27 +803,55 @@ psyco_curs_fetchall(cursorObject *self, PyObject *args)
|
|||
|
||||
|
||||
|
||||
/* callproc method - execute a stored procedure (not YET supported) */
|
||||
/* callproc method - execute a stored procedure */
|
||||
|
||||
#define psyco_curs_callproc_doc \
|
||||
"callproc(procname, [parameters]) -> execute stored procedure\n\n" \
|
||||
"This method is not (yet) impelemented and calling it raise an exception."
|
||||
"callproc(procname, [parameters]) -> execute stored procedure"
|
||||
|
||||
static PyObject *
|
||||
psyco_curs_callproc(cursorObject *self, PyObject *args)
|
||||
psyco_curs_callproc(cursorObject *self, PyObject *args, PyObject *kwargs)
|
||||
{
|
||||
PyObject *procname, *procargs;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O|O", &procname, &procargs))
|
||||
char *procname = NULL, *sql = NULL;
|
||||
long int async = 0;
|
||||
int i, nparameters = 0, sl = 0;
|
||||
PyObject *parameters = NULL;
|
||||
PyObject *operation = NULL;
|
||||
PyObject *res = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|Oi", &procname, ¶meters, &async)) {
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
EXC_IF_CURS_CLOSED(self);
|
||||
|
||||
PyErr_SetString(NotSupportedError, "not yet implemented");
|
||||
return NULL;
|
||||
if(parameters && parameters != Py_None) {
|
||||
nparameters = PyObject_Length(parameters);
|
||||
}
|
||||
|
||||
/* allocate some memory, build the SQL and create a PyString from it */
|
||||
sl = strlen(procname) + 10 + nparameters*3;
|
||||
sql = (char*)PyMem_Malloc(sl);
|
||||
if (sql == NULL) return NULL;
|
||||
|
||||
sprintf(sql, "SELECT %s(", procname);
|
||||
for(i=0; i<nparameters; i++) {
|
||||
strcat(sql, "%s,");
|
||||
}
|
||||
sql[sl-2] = ')';
|
||||
sql[sl-1] = '\0';
|
||||
|
||||
operation = PyString_FromString(sql);
|
||||
PyMem_Free((void*)sql);
|
||||
|
||||
if (_psyco_curs_execute(self, operation, parameters, async)) {
|
||||
Py_INCREF(Py_None);
|
||||
res = Py_None;
|
||||
}
|
||||
|
||||
Py_DECREF(operation);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* nextset method - return the next set of data (not supported) */
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user