[Zope-Checkins] CVS: Products/DCOracle2/src - dco2.c:1.109
Matthew T. Kromer
matt@zope.com
Tue, 14 May 2002 15:16:13 -0400
Update of /cvs-repository/Products/DCOracle2/src
In directory cvs.zope.org:/tmp/cvs-serv9189/src
Modified Files:
dco2.c
Log Message:
Add BLOB/CLOB handing to stored procs, re collector issue #40. Instead of
allocating a BindingArray for the OUT variables which are LOBs, a LobLocator
is allocated instead. This doesn't support array output of LOBs, however.
=== Products/DCOracle2/src/dco2.c 1.108 => 1.109 ===
OCIError *errhp; /* Error handle */
OCILobLocator *lobp; /* LOB Locator */
+ ub2 dty; /* Type of locator */
} LobLocator;
staticforward PyTypeObject LobLocatorType;
@@ -895,6 +896,8 @@
},
{"BindingArray", (PyCFunction) ServerContext_BindingArrayObject,
METH_VARARGS, "allocate a BindingArray(elements, size, type)"},
+ {"LobLocator", (PyCFunction) LobLocator_alloc, METH_VARARGS,
+ "allocate a LobLocator"},
{ NULL, NULL }
};
@@ -975,8 +978,6 @@
};
static struct PyMethodDef dco2_methods[] = {
- {"LobLocator", (PyCFunction) LobLocator_alloc, METH_VARARGS,
- "allocate a LobLocator"},
{"connect", (PyCFunction) Connect, METH_VARARGS,
"connect(userid, password, database) -- connect to the "
"database; userid, password, and database may not be None"},
@@ -2467,6 +2468,16 @@
bind->dty = SQLT_DAT;
bind->valuep = &odate->ocidate;
bind->valuesz = sizeof(odate->ocidate);
+ } else if (object->ob_type == &LobLocatorType) {
+
+ LobLocator *lobp = (LobLocator *) object;
+
+ TRACE(T_INFO,("ss","bindObject","LobLocator"));
+
+ bind->dty = lobp->dty;
+ bind->valuep = &lobp->lobp;
+ bind->valuesz = sizeof(OCILobLocator *);
+
} else if (PyString_Check(object)) {
bind->dty = SQLT_STR;
bind->valuep = PyString_AsString(object);
@@ -4332,6 +4343,7 @@
lob->lobp = NULL;
lob->errhp = NULL;
+ lob->dty = SQLT_BLOB; /* FIXME -- default */
if (alloc == 1) {
@@ -4375,16 +4387,38 @@
*/
static PyObject *LobLocator_alloc(ServerContext *sc, PyObject *args) {
-
- PyObject *obj;
+ PyObject *obj = NULL;
+ PyObject *ctypeo = NULL;
+ ub2 dty = SQLT_BLOB;
+ LobLocator *lob;
+ int crow = -1;
TRACE(T_ENTRY,("sAA", "LobLocator_alloc", sc, args));
- if (!PyArg_ParseTuple(args, "")) return NULL;
+ if (!PyArg_ParseTuple(args, "|O", &ctypeo)) return NULL;
+
+ if (ctypeo != NULL) {
+ if (PyString_Check(ctypeo))
+ crow = typeByName(PyString_AsString(ctypeo));
+ else if (PyInt_Check(ctypeo))
+ crow = typeByType((int) PyInt_AsLong(ctypeo));
+ else if (PyLong_Check(ctypeo))
+ crow = typeByType((int) PyLong_AsLong(ctypeo));
+
+ if (crow == -1) {
+ PyErr_SetString(PyExc_ValueError, "invalid or unknown "
+ "conversion type provided");
+ return NULL;
+ }
+ dty = TypeTable[crow].type;
+ }
+
+ lob = (LobLocator *) _LobLocator_alloc(sc, 1);
+ lob->dty = dty;
- obj = OBJECT(_LobLocator_alloc(sc,1));
+ obj = OBJECT(lob);
- TRACE(T_EXIT,("sA", "LobLocator_alloc", obj));
+ TRACE(T_EXIT,("sAd", "LobLocator_alloc", obj, dty));
return obj;
}