informixdb-cvs Mailing List for InformixDB (Page 5)
Brought to you by:
chaese,
f-apolloner
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(36) |
Nov
(40) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(1) |
Feb
|
Mar
(6) |
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(13) |
Oct
(12) |
Nov
(10) |
Dec
(8) |
2007 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
(5) |
Jul
|
Aug
(1) |
Sep
(4) |
Oct
(15) |
Nov
|
Dec
(1) |
2008 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
(5) |
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(4) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Carsten H. <ch...@us...> - 2005-12-01 11:51:05
|
Update of /cvsroot/informixdb/informixdb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23575 Modified Files: setup.py Log Message: Cut through the increasingly unmaintainable ifdef clutter for backwards compatibility of Informix features and use a simple ESQL/C version check instead, in a fashion very similar to how PHP handles this. Index: setup.py =================================================================== RCS file: /cvsroot/informixdb/informixdb/setup.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** setup.py 29 Nov 2005 02:39:21 -0000 1.10 --- setup.py 1 Dec 2005 11:50:51 -0000 1.11 *************** *** 2,5 **** --- 2,6 ---- import os import shlex + import re from distutils.core import setup, Extension from distutils.spawn import find_executable *************** *** 60,63 **** --- 61,85 ---- self.esql_parts.append('-static') + # determine esql version + esqlver = re.compile(r"(IBM)?.*ESQL Version (\d+)\.(\d+)") + cout = os.popen(' '.join(self.esql_parts[0:1] + [ '-V' ]),'r') + esqlversion = None + for line in cout: + matchobj = esqlver.match(line) + if matchobj: + matchgroups = matchobj.groups() + esqlversion = int(matchgroups[1] + matchgroups[2]) + if matchgroups[0]=="IBM": + # IBM Informix CSDK 2.90 reports the ESQL version as 2.90 + # even though it's ESQL 9.xx + if esqlversion == 290: esqlversion = 960 + if esqlversion==None: + esqlversion = 850 + if esqlversion >= 900: + if get_platform()=="win32": + self.esql_parts.append("-edHAVE_ESQL9") + else: + self.esql_parts.append("-EDHAVE_ESQL9") + # find esql libs/objects cout = os.popen(' '.join(self.esql_parts + [ '-libs' ]),'r') |
From: Carsten H. <ch...@us...> - 2005-12-01 11:51:05
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23575/ext Modified Files: _informixdb.ec Log Message: Cut through the increasingly unmaintainable ifdef clutter for backwards compatibility of Informix features and use a simple ESQL/C version check instead, in a fashion very similar to how PHP handles this. Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** _informixdb.ec 30 Nov 2005 15:05:43 -0000 1.54 --- _informixdb.ec 1 Dec 2005 11:50:52 -0000 1.55 *************** *** 52,82 **** #include <datetime.h> ! #ifndef mint ! typedef int mint; ! #endif ! #ifndef int4 ! typedef int int4; ! #endif ! ! /* Use LO_RDWR to determine if the CSDK supports Smart Blobs */ ! #ifdef LO_RDWR ! #define HAVE_SBLOB #define SBLOB_TYPE_BLOB 0 #define SBLOB_TYPE_CLOB 1 ! #else ! #undef HAVE_SBLOB ! #endif ! ! #ifdef SQLUDTVAR ! #define HAVE_UDT ! #else ! #undef HAVE_UDT ! #endif ! ! #if defined(HAVE_UDT) || defined(HAVE_SLOB) ! #define HAVE_XSQLVAR /* extendend sqlvarstruct with xid */ ! #else ! #undef HAVE_XSQLVAR ! #endif #if HAVE_C_DATETIME == 1 --- 52,62 ---- #include <datetime.h> ! $ifdef HAVE_ESQL9; #define SBLOB_TYPE_BLOB 0 #define SBLOB_TYPE_CLOB 1 ! $else; ! typedef int mint; ! typedef long int4; ! $endif; #if HAVE_C_DATETIME == 1 *************** *** 235,239 **** } while(0) ! #ifdef HAVE_SBLOB /************************* Smart Blobs *************************/ typedef struct Sblob_t --- 215,219 ---- } while(0) ! $ifdef HAVE_ESQL9; /************************* Smart Blobs *************************/ typedef struct Sblob_t *************** *** 405,409 **** _PyObject_Del /* tp_free */ }; ! #endif /************************* Cursors *************************/ --- 385,389 ---- _PyObject_Del /* tp_free */ }; ! $endif; /************************* Cursors *************************/ *************** *** 702,708 **** static PyObject *Connection_rollback(Connection *self); static PyObject *Connection_close(Connection *self); ! #ifdef HAVE_SBLOB static PyObject *Connection_Sblob(Connection *self, PyObject *args, PyObject *kwds); ! #endif PyDoc_STRVAR(Connection_cursor_doc, --- 682,688 ---- static PyObject *Connection_rollback(Connection *self); static PyObject *Connection_close(Connection *self); ! $ifdef HAVE_ESQL9; static PyObject *Connection_Sblob(Connection *self, PyObject *args, PyObject *kwds); ! $endif; PyDoc_STRVAR(Connection_cursor_doc, *************** *** 748,752 **** commit any outstanding operations before closing a Connection."); ! #ifdef HAVE_SBLOB PyDoc_STRVAR(Connection_Sblob_doc, "\ Sblob(...) -> Sblob object\n\n\ --- 728,732 ---- commit any outstanding operations before closing a Connection."); ! $ifdef HAVE_ESQL9; PyDoc_STRVAR(Connection_Sblob_doc, "\ Sblob(...) -> Sblob object\n\n\ *************** *** 772,776 **** with database defined or col_info derived default values for storage\n\ characteristics that are not given."); ! #endif static PyMethodDef Connection_methods[] = { --- 752,756 ---- with database defined or col_info derived default values for storage\n\ characteristics that are not given."); ! $endif; static PyMethodDef Connection_methods[] = { *************** *** 783,790 **** { "close", (PyCFunction)Connection_close, METH_NOARGS, Connection_close_doc }, ! #ifdef HAVE_SBLOB { "Sblob", (PyCFunction)Connection_Sblob, METH_VARARGS|METH_KEYWORDS, Connection_Sblob_doc }, ! #endif { NULL } }; --- 763,770 ---- { "close", (PyCFunction)Connection_close, METH_NOARGS, Connection_close_doc }, ! $ifdef HAVE_ESQL9; { "Sblob", (PyCFunction)Connection_Sblob, METH_VARARGS|METH_KEYWORDS, Connection_Sblob_doc }, ! $endif; { NULL } }; *************** *** 1232,1236 **** } #endif ! #ifdef SQLBOOL if ((var->sqltype&SQLTYPE)==SQLBOOL || LIKEBOOLEANXTYPE(var->sqltype, var->sqlxid) ) { --- 1212,1216 ---- } #endif ! $ifdef HAVE_ESQL9; if ((var->sqltype&SQLTYPE)==SQLBOOL || LIKEBOOLEANXTYPE(var->sqltype, var->sqlxid) ) { *************** *** 1243,1252 **** return 1; } ! #endif sitem = PyObject_Str(item); val = PyString_AS_STRING((PyStringObject*)sitem); n = strlen(val); ! EXEC SQL ifdef SQLLVARCHAR; ! #ifdef HAVE_UDT if (n >= 32768) { /* use lvarchar* instead */ --- 1223,1231 ---- return 1; } ! $endif; sitem = PyObject_Str(item); val = PyString_AS_STRING((PyStringObject*)sitem); n = strlen(val); ! $ifdef HAVE_ESQL9; if (n >= 32768) { /* use lvarchar* instead */ *************** *** 1268,1273 **** } else ! #endif ! EXEC SQL endif; { var->sqltype = CSTRINGTYPE; --- 1247,1251 ---- } else ! $endif; { var->sqltype = CSTRINGTYPE; *************** *** 1306,1310 **** } ! #ifdef HAVE_SBLOB static int ibindSblob(struct sqlvar_struct *var, PyObject *item) { --- 1284,1288 ---- } ! $ifdef HAVE_ESQL9; static int ibindSblob(struct sqlvar_struct *var, PyObject *item) { *************** *** 1322,1326 **** return 1; } ! #endif static int ibindNone(struct sqlvar_struct *var, PyObject *item) --- 1300,1304 ---- return 1; } ! $endif; static int ibindNone(struct sqlvar_struct *var, PyObject *item) *************** *** 1337,1345 **** static ibindFptr ibindFcn(PyObject* item) { ! #ifdef HAVE_SBLOB if (PyObject_IsInstance(item, (PyObject*)&Sblob_type)) { return ibindSblob; } else ! #endif if (PyObject_IsInstance(item, IntervalY2MType) || PyObject_IsInstance(item, IntervalD2FType)) { --- 1315,1323 ---- static ibindFptr ibindFcn(PyObject* item) { ! $ifdef HAVE_ESQL9; if (PyObject_IsInstance(item, (PyObject*)&Sblob_type)) { return ibindSblob; } else ! $endif; if (PyObject_IsInstance(item, IntervalY2MType) || PyObject_IsInstance(item, IntervalD2FType)) { *************** *** 1441,1445 **** static inline PyObject* gettypename(struct sqlvar_struct *var) { ! #ifdef HAVE_UDT if (ISCOMPLEXTYPE(var->sqltype)||ISUDTTYPE(var->sqltype)) { return PyString_FromFormat("%s '%s'", rtypname(var->sqltype), --- 1419,1423 ---- static inline PyObject* gettypename(struct sqlvar_struct *var) { ! $ifdef HAVE_ESQL9; if (ISCOMPLEXTYPE(var->sqltype)||ISUDTTYPE(var->sqltype)) { return PyString_FromFormat("%s '%s'", rtypname(var->sqltype), *************** *** 1447,1453 **** } else return PyString_FromString(rtypname(var->sqltype)); ! #else return PyString_FromString(rtypname(var->sqltype)); ! #endif } --- 1425,1431 ---- } else return PyString_FromString(rtypname(var->sqltype)); ! $else; return PyString_FromString(rtypname(var->sqltype)); ! $endif; } *************** *** 1484,1492 **** var->sqlind = &cur->indOut[pos]; cur->originalType[pos] = var->sqltype; ! #ifdef HAVE_XSQLVAR cur->originalXid[pos] = var->sqlxid; ! #else cur->originalXid[pos] = 0; ! #endif cur->originalLen[pos] = var->sqllen; var->sqldata = NULL; --- 1462,1470 ---- var->sqlind = &cur->indOut[pos]; cur->originalType[pos] = var->sqltype; ! $ifdef HAVE_ESQL9; cur->originalXid[pos] = var->sqlxid; ! $else; cur->originalXid[pos] = 0; ! $endif; cur->originalLen[pos] = var->sqllen; var->sqldata = NULL; *************** *** 1520,1524 **** var->sqltype = CLONGTYPE; break; ! #ifdef SQLINT8 case SQLINT8: case SQLSERIAL8: --- 1498,1502 ---- var->sqltype = CLONGTYPE; break; ! $ifdef HAVE_ESQL9; case SQLINT8: case SQLSERIAL8: *************** *** 1526,1530 **** var->sqllen = 20; break; ! #endif case SQLDTIME: var->sqltype = CDTIMETYPE; --- 1504,1508 ---- var->sqllen = 20; break; ! $endif; case SQLDTIME: var->sqltype = CDTIMETYPE; *************** *** 1535,1539 **** default: { int known_type = 0; ! #ifdef SQLBOOL if (!known_type && ((var->sqltype&SQLTYPE)==SQLBOOL --- 1513,1517 ---- default: { int known_type = 0; ! $ifdef HAVE_ESQL9; if (!known_type && ((var->sqltype&SQLTYPE)==SQLBOOL *************** *** 1542,1547 **** known_type = 1; } - #endif - #ifdef HAVE_SBLOB if (!known_type && ISSMARTBLOB(var->sqltype, var->sqlxid)) { /* Smart large object: allocate space for its LO handle */ --- 1520,1523 ---- *************** *** 1549,1555 **** known_type = 1; } - #endif - EXEC SQL ifdef SQLLVARCHAR; - #if defined(HAVE_UDT) if (!known_type&& (ISCOMPLEXTYPE(var->sqltype)||ISUDTTYPE(var->sqltype))) { --- 1525,1528 ---- *************** *** 1572,1577 **** known_type = 1; } ! #endif ! EXEC SQL endif; /* fall back to character string */ if (!known_type) --- 1545,1549 ---- known_type = 1; } ! $endif; /* fall back to character string */ if (!known_type) *************** *** 1633,1639 **** varDest->sqltype = varSrc->sqltype; varDest->sqllen = varSrc->sqllen; ! #ifdef XSQLVAR varDest->sqlxid = varSrc->sqlxid; ! #endif varSrc++; varDest++; --- 1605,1611 ---- varDest->sqltype = varSrc->sqltype; varDest->sqllen = varSrc->sqllen; ! $ifdef HAVE_ESQL9; varDest->sqlxid = varSrc->sqlxid; ! $endif; varSrc++; varDest++; *************** *** 2029,2035 **** case SQLNCHAR: case SQLNVCHAR: ! #ifdef SQLLVARCHAR case SQLLVARCHAR: ! #endif { /* clip trailing spaces */ --- 2001,2007 ---- case SQLNCHAR: case SQLNVCHAR: ! $ifdef HAVE_ESQL9; case SQLLVARCHAR: ! $endif; { /* clip trailing spaces */ *************** *** 2075,2083 **** case SQLSERIAL: return PyInt_FromLong(*(long*)data); ! #ifdef SQLINT8 case SQLINT8: case SQLSERIAL8: return PyLong_FromString((char *)data, NULL, 10); ! #endif case SQLBYTES: case SQLTEXT: --- 2047,2055 ---- case SQLSERIAL: return PyInt_FromLong(*(long*)data); ! $ifdef HAVE_ESQL9; case SQLINT8: case SQLSERIAL8: return PyLong_FromString((char *)data, NULL, 10); ! $endif; case SQLBYTES: case SQLTEXT: *************** *** 2100,2104 **** } /* case SQLTEXT */ } /* switch */ ! #ifdef SQLBOOL if ((type&SQLTYPE)==SQLBOOL||LIKEBOOLEANXTYPE(type,xid) ) { PyObject *result = (*(char*)data)?Py_True:Py_False; --- 2072,2076 ---- } /* case SQLTEXT */ } /* switch */ ! $ifdef HAVE_ESQL9; if ((type&SQLTYPE)==SQLBOOL||LIKEBOOLEANXTYPE(type,xid) ) { PyObject *result = (*(char*)data)?Py_True:Py_False; *************** *** 2106,2111 **** return result; } - #endif - #ifdef HAVE_SBLOB if (ISSMARTBLOB(type,xid)) { Sblob *new_sblob; --- 2078,2081 ---- *************** *** 2119,2124 **** return (PyObject*)new_sblob; } - #endif - #ifdef HAVE_UDT if (ISCOMPLEXTYPE(type)||ISUDTTYPE(type)) { PyObject *result; --- 2089,2092 ---- *************** *** 2128,2132 **** return result; } ! #endif { /* Unknown type. bindOutput falls back to binding to a character string. --- 2096,2100 ---- return result; } ! $endif; { /* Unknown type. bindOutput falls back to binding to a character string. *************** *** 2202,2206 **** } ! #ifdef HAVE_SBLOB static PyObject *Connection_Sblob(Connection *self, PyObject *args, PyObject *kwds) { --- 2170,2174 ---- } ! $ifdef HAVE_ESQL9; static PyObject *Connection_Sblob(Connection *self, PyObject *args, PyObject *kwds) { *************** *** 2224,2228 **** return slob; } ! #endif static void cleanInputBinding(Cursor *cur) --- 2192,2196 ---- return slob; } ! $endif; static void cleanInputBinding(Cursor *cur) *************** *** 2240,2248 **** } } ! #ifdef HAVE_UDT if (da->sqlvar[i].sqltype == SQLUDTVAR) { ifx_var_dealloc((void**)&(da->sqlvar[i].sqldata)); } ! #endif free(da->sqlvar[i].sqldata); } --- 2208,2216 ---- } } ! $ifdef HAVE_ESQL9; if (da->sqlvar[i].sqltype == SQLUDTVAR) { ifx_var_dealloc((void**)&(da->sqlvar[i].sqldata)); } ! $endif; free(da->sqlvar[i].sqldata); } *************** *** 2281,2289 **** free(loc->loc_buffer); } ! #ifdef HAVE_SBLOB if (ISSMARTBLOB(da->sqlvar[i].sqltype,da->sqlvar[i].sqlxid)) { free(da->sqlvar[i].sqldata); } ! #endif free(cur->daOut); cur->daOut = 0; --- 2249,2257 ---- free(loc->loc_buffer); } ! $ifdef HAVE_ESQL9; if (ISSMARTBLOB(da->sqlvar[i].sqltype,da->sqlvar[i].sqlxid)) { free(da->sqlvar[i].sqldata); } ! $endif; free(cur->daOut); cur->daOut = 0; *************** *** 3281,3285 **** }; ! #ifdef HAVE_SBLOB static int makeint8(PyObject *in, ifx_int8_t *out) { --- 3249,3253 ---- }; ! $ifdef HAVE_ESQL9; static int makeint8(PyObject *in, ifx_int8_t *out) { *************** *** 3739,3743 **** return 0; } ! #endif PyDoc_STRVAR(_informixdb_doc, --- 3707,3711 ---- return 0; } ! $endif; PyDoc_STRVAR(_informixdb_doc, *************** *** 3803,3811 **** PyType_Ready(&DBAPIType_type); ! #ifdef HAVE_SBLOB Sblob_type.ob_type = &PyType_Type; PyType_Ready(&Sblob_type); Py_INCREF(&Sblob_type); ! #endif #ifdef IFX_THREAD --- 3771,3779 ---- PyType_Ready(&DBAPIType_type); ! $ifdef HAVE_ESQL9; Sblob_type.ob_type = &PyType_Type; PyType_Ready(&Sblob_type); Py_INCREF(&Sblob_type); ! $endif; #ifdef IFX_THREAD *************** *** 3828,3832 **** PyModule_AddIntConstant(m, "ROW_AS_OBJECT", CURSOR_ROWFORMAT_ROWOBJ); ! #ifdef HAVE_SBLOB #define ExposeIntConstant(x) PyModule_AddIntConstant(m, #x, x) ExposeIntConstant(SBLOB_TYPE_BLOB); --- 3796,3800 ---- PyModule_AddIntConstant(m, "ROW_AS_OBJECT", CURSOR_ROWFORMAT_ROWOBJ); ! $ifdef HAVE_ESQL9; #define ExposeIntConstant(x) PyModule_AddIntConstant(m, #x, x) ExposeIntConstant(SBLOB_TYPE_BLOB); *************** *** 3859,3863 **** Py_INCREF(&Sblob_type); PyModule_AddObject(m, "Sblob", (PyObject*)&Sblob_type); ! #endif Py_INCREF(&Connection_type); --- 3827,3831 ---- Py_INCREF(&Sblob_type); PyModule_AddObject(m, "Sblob", (PyObject*)&Sblob_type); ! $endif; Py_INCREF(&Connection_type); |
From: Daniel S. <da...@us...> - 2005-11-30 15:05:54
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10780 Modified Files: _informixdb.ec Log Message: Make InformixDB compile for older Informix-Versions (7.xx-ish) Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** _informixdb.ec 29 Nov 2005 14:11:31 -0000 1.53 --- _informixdb.ec 30 Nov 2005 15:05:43 -0000 1.54 *************** *** 52,55 **** --- 52,62 ---- #include <datetime.h> + #ifndef mint + typedef int mint; + #endif + #ifndef int4 + typedef int int4; + #endif + /* Use LO_RDWR to determine if the CSDK supports Smart Blobs */ #ifdef LO_RDWR *************** *** 67,70 **** --- 74,83 ---- #endif + #if defined(HAVE_UDT) || defined(HAVE_SLOB) + #define HAVE_XSQLVAR /* extendend sqlvarstruct with xid */ + #else + #undef HAVE_XSQLVAR + #endif + #if HAVE_C_DATETIME == 1 /* Python and Informix both have a datetime.h, the Informix header is *************** *** 1234,1237 **** --- 1247,1251 ---- val = PyString_AS_STRING((PyStringObject*)sitem); n = strlen(val); + EXEC SQL ifdef SQLLVARCHAR; #ifdef HAVE_UDT if (n >= 32768) { *************** *** 1255,1258 **** --- 1269,1273 ---- else #endif + EXEC SQL endif; { var->sqltype = CSTRINGTYPE; *************** *** 1469,1473 **** --- 1484,1492 ---- var->sqlind = &cur->indOut[pos]; cur->originalType[pos] = var->sqltype; + #ifdef HAVE_XSQLVAR cur->originalXid[pos] = var->sqlxid; + #else + cur->originalXid[pos] = 0; + #endif cur->originalLen[pos] = var->sqllen; var->sqldata = NULL; *************** *** 1531,1535 **** } #endif ! #ifdef HAVE_UDT if (!known_type&& (ISCOMPLEXTYPE(var->sqltype)||ISUDTTYPE(var->sqltype))) { --- 1550,1555 ---- } #endif ! EXEC SQL ifdef SQLLVARCHAR; ! #if defined(HAVE_UDT) if (!known_type&& (ISCOMPLEXTYPE(var->sqltype)||ISUDTTYPE(var->sqltype))) { *************** *** 1553,1556 **** --- 1573,1577 ---- } #endif + EXEC SQL endif; /* fall back to character string */ if (!known_type) *************** *** 1612,1616 **** --- 1633,1639 ---- varDest->sqltype = varSrc->sqltype; varDest->sqllen = varSrc->sqllen; + #ifdef XSQLVAR varDest->sqlxid = varSrc->sqlxid; + #endif varSrc++; varDest++; |
From: Carsten H. <ch...@us...> - 2005-11-29 14:11:42
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25368/ext Modified Files: _informixdb.ec Log Message: Replace BuildValue/PyObject_Call combos with the more concise PyObject_CallFunction where no kwargs are involved. Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** _informixdb.ec 29 Nov 2005 13:58:08 -0000 1.52 --- _informixdb.ec 29 Nov 2005 14:11:31 -0000 1.53 *************** *** 2992,3001 **** if (handler) { ! PyObject *args, *hret; ! args = Py_BuildValue("(OOON)", (PyObject*)connection, cursor ? (PyObject*)cursor : Py_None, type, value); - hret = PyObject_Call(handler, args, NULL); - Py_DECREF(args); if (hret) { Py_DECREF(hret); --- 2992,2999 ---- if (handler) { ! PyObject *hret; ! hret = PyObject_CallFunction(handler, "OOON", (PyObject*)connection, cursor ? (PyObject*)cursor : Py_None, type, value); if (hret) { Py_DECREF(hret); *************** *** 3130,3134 **** { char** tp; ! PyObject *dbtp, *l, *a, *s; l = PyList_New(0); for (tp = types; *tp != NULL; ++tp) { --- 3128,3132 ---- { char** tp; ! PyObject *l, *s; l = PyList_New(0); for (tp = types; *tp != NULL; ++tp) { *************** *** 3137,3144 **** Py_DECREF(s); } ! a = Py_BuildValue("(N)", l); ! dbtp = PyObject_Call((PyObject*)&DBAPIType_type, a, NULL); ! Py_DECREF(a); ! return dbtp; } --- 3135,3139 ---- Py_DECREF(s); } ! return PyObject_CallFunction((PyObject*)&DBAPIType_type, "N", l); } |
From: Carsten H. <ch...@us...> - 2005-11-29 13:58:32
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21430/ext Modified Files: _informixdb.ec Log Message: Apparently I sort of reinvented PyObject_CallFunction when I wrapped the CallObject/BuildValue idiom to be refcount neutral. Dump my hideously named wrapper in favor of the existing API function. Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** _informixdb.ec 29 Nov 2005 02:39:22 -0000 1.51 --- _informixdb.ec 29 Nov 2005 13:58:08 -0000 1.52 *************** *** 1888,1899 **** } - static PyObject *CallObjectAndDiscardArgs(PyObject *t, PyObject *a) - { - PyObject *result; - result = PyObject_CallObject(t, a); - Py_DECREF(a); - return result; - } - static PyObject *doCopy(/* const */ void *data, int type, int4 xid, int4 sqllen, struct Cursor_t *cur) --- 1888,1891 ---- *************** *** 1982,1987 **** pos--; } ! return CallObjectAndDiscardArgs(IntervalY2MType, ! Py_BuildValue("(ii)",sign*year,sign*month) ); } else { --- 1974,1979 ---- pos--; } ! return PyObject_CallFunction(IntervalY2MType, ! "ii", sign*year, sign*month); } else { *************** *** 2006,2012 **** pos--; } ! return CallObjectAndDiscardArgs(IntervalD2FType, ! Py_BuildValue("(iii)", sign*day, ! sign*(3600*hour+60*minute+second), sign*usec) ); } } --- 1998,2003 ---- pos--; } ! return PyObject_CallFunction(IntervalD2FType, ! "iii", sign*day, sign*(3600*hour+60*minute+second), sign*usec); } } *************** *** 2042,2047 **** if (result==0) { dbuf[34] = 0; ! retval = CallObjectAndDiscardArgs(DecimalType, ! Py_BuildValue("(s#)",dbuf,byleng(dbuf,34)) ); } if (!retval) { --- 2033,2038 ---- if (result==0) { dbuf[34] = 0; ! retval = PyObject_CallFunction(DecimalType, ! "s#",dbuf,byleng(dbuf,34)); } if (!retval) { *************** *** 2096,2101 **** if (ISSMARTBLOB(type,xid)) { Sblob *new_sblob; ! new_sblob = (Sblob*)CallObjectAndDiscardArgs((PyObject*)&Sblob_type, ! Py_BuildValue("(Oi)", cur->conn, 0) ); memcpy(&new_sblob->lo, data, sizeof(ifx_lo_t)); if (xid==XID_CLOB) --- 2087,2092 ---- if (ISSMARTBLOB(type,xid)) { Sblob *new_sblob; ! new_sblob = (Sblob*)PyObject_CallFunction((PyObject*)&Sblob_type, ! "Oi", cur->conn, 0); memcpy(&new_sblob->lo, data, sizeof(ifx_lo_t)); if (xid==XID_CLOB) *************** *** 2162,2166 **** } if (cur->rowformat == CURSOR_ROWFORMAT_ROWOBJ) { ! row = CallObjectAndDiscardArgs(DataRowType, Py_BuildValue("(N)", row) ); } return row; --- 2153,2157 ---- } if (cur->rowformat == CURSOR_ROWFORMAT_ROWOBJ) { ! row = PyObject_CallFunction(DataRowType, "N", row); } return row; |
From: Carsten H. <ch...@us...> - 2005-11-29 02:39:29
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26354/ext Modified Files: _informixdb.ec Log Message: add optional mapping of DECIMAL/MONEY to decimal.Decimal if the decimal module is available. Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** _informixdb.ec 28 Nov 2005 01:42:07 -0000 1.50 --- _informixdb.ec 29 Nov 2005 02:39:22 -0000 1.51 *************** *** 118,121 **** --- 118,124 ---- static PyObject *IntervalD2FType; static PyObject *DataRowType; + #if HAVE_DECIMAL == 1 + static PyObject *DecimalType; + #endif PyDoc_STRVAR(ExcWarning_doc, *************** *** 411,414 **** --- 414,418 ---- int *originalType; int4 *originalXid; + int4 *originalLen; char *outputBuffer; short *indIn; *************** *** 425,428 **** --- 429,435 ---- int pending_scroll; int scroll_value; + #if HAVE_DECIMAL == 1 + int use_decimal; + #endif PyObject *messages; PyObject *errorhandler; *************** *** 1440,1443 **** --- 1447,1451 ---- cur->originalType = calloc(cur->daOut->sqld, sizeof(int)); cur->originalXid = calloc(cur->daOut->sqld, sizeof(int4)); + cur->originalLen = calloc(cur->daOut->sqld, sizeof(int4)); Py_DECREF(cur->description); *************** *** 1462,1465 **** --- 1470,1474 ---- cur->originalType[pos] = var->sqltype; cur->originalXid[pos] = var->sqlxid; + cur->originalLen[pos] = var->sqllen; var->sqldata = NULL; *************** *** 1887,1892 **** } ! static PyObject *doCopy(/* const */ void *data, int type, int4 xid, ! struct Connection_t *conn) { switch(type & SQLTYPE){ --- 1896,1901 ---- } ! static PyObject *doCopy(/* const */ void *data, ! int type, int4 xid, int4 sqllen, struct Cursor_t *cur) { switch(type & SQLTYPE){ *************** *** 2022,2025 **** --- 2031,2054 ---- case SQLDECIMAL: case SQLMONEY: + #if HAVE_DECIMAL == 1 + if (cur->use_decimal) { + char dbuf[35]; + mint result; + mint right; + PyObject *retval = NULL; + right = PRECDEC(sqllen); + if (right==255) right = -1; + result = dectoasc((dec_t*)data, dbuf, 34, right); + if (result==0) { + dbuf[34] = 0; + retval = CallObjectAndDiscardArgs(DecimalType, + Py_BuildValue("(s#)",dbuf,byleng(dbuf,34)) ); + } + if (!retval) { + PyErr_SetString(ExcInterfaceError, "Decimal conversion failed."); + } + return retval; + } else + #endif { double dval; *************** *** 2068,2072 **** Sblob *new_sblob; new_sblob = (Sblob*)CallObjectAndDiscardArgs((PyObject*)&Sblob_type, ! Py_BuildValue("(Oi)", conn, 0) ); memcpy(&new_sblob->lo, data, sizeof(ifx_lo_t)); if (xid==XID_CLOB) --- 2097,2101 ---- Sblob *new_sblob; new_sblob = (Sblob*)CallObjectAndDiscardArgs((PyObject*)&Sblob_type, ! Py_BuildValue("(Oi)", cur->conn, 0) ); memcpy(&new_sblob->lo, data, sizeof(ifx_lo_t)); if (xid==XID_CLOB) *************** *** 2119,2125 **** } else { v = doCopy(var->sqldata, cur->originalType[pos], cur->originalXid[pos], ! cur->conn); } if (cur->rowformat==CURSOR_ROWFORMAT_DICT || cur->rowformat==CURSOR_ROWFORMAT_ROWOBJ) { --- 2148,2156 ---- } else { v = doCopy(var->sqldata, cur->originalType[pos], cur->originalXid[pos], ! cur->originalLen[pos], cur); } + if (PyErr_Occurred()) return NULL; + if (cur->rowformat==CURSOR_ROWFORMAT_DICT || cur->rowformat==CURSOR_ROWFORMAT_ROWOBJ) { *************** *** 2256,2259 **** --- 2287,2294 ---- cur->originalXid = 0; } + if (cur->originalLen) { + free(cur->originalLen); + cur->originalLen = 0; + } if (cur->outputBuffer) { free(cur->outputBuffer); *************** *** 2346,2355 **** int is_scroll = 0; int is_hold = 0; static char* kwdlist[] = { "connection", "name", "rowformat", "scroll", "hold", 0 }; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|siii", kwdlist, &Connection_type, &conn, &name, &rowformat, &is_scroll, &is_hold)) return -1; Py_INCREF(Py_None); --- 2381,2400 ---- int is_scroll = 0; int is_hold = 0; + #if HAVE_DECIMAL == 1 + int use_decimal = 1; + static char* kwdlist[] = { "connection", "name", "rowformat", + "scroll", "hold", "use_decimal", 0 }; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|siiii", kwdlist, + &Connection_type, &conn, &name, &rowformat, &is_scroll, &is_hold, + &use_decimal)) + return -1; + self->use_decimal = (use_decimal)?1:0; + #else static char* kwdlist[] = { "connection", "name", "rowformat", "scroll", "hold", 0 }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|siii", kwdlist, &Connection_type, &conn, &name, &rowformat, &is_scroll, &is_hold)) return -1; + #endif Py_INCREF(Py_None); *************** *** 2362,2365 **** --- 2407,2411 ---- self->originalType = 0; self->originalXid = 0; + self->originalLen = 0; self->outputBuffer = 0; self->indIn = 0; *************** *** 3703,3708 **** PyObject *m = Py_InitModule3("_informixdb", globalMethods, _informixdb_doc); ! PyObject *informixdbmodule; ! PyObject *informixdbmdict; #define defException(name, base) \ --- 3749,3754 ---- PyObject *m = Py_InitModule3("_informixdb", globalMethods, _informixdb_doc); ! PyObject *module; ! PyObject *mdict; #define defException(name, base) \ *************** *** 3812,3822 **** /* obtain the type objects for the Interval classes */ ! informixdbmodule = PyImport_ImportModule("informixdb"); ! informixdbmdict = PyModule_GetDict(informixdbmodule); IntervalY2MType = PyDict_GetItemString( ! informixdbmdict, "IntervalYearToMonth"); IntervalD2FType = PyDict_GetItemString( ! informixdbmdict, "IntervalDayToFraction"); ! DataRowType = PyDict_GetItemString(informixdbmdict, "Row"); Py_INCREF(IntervalY2MType); Py_INCREF(IntervalD2FType); --- 3858,3868 ---- /* obtain the type objects for the Interval classes */ ! module = PyImport_ImportModule("informixdb"); ! mdict = PyModule_GetDict(module); IntervalY2MType = PyDict_GetItemString( ! mdict, "IntervalYearToMonth"); IntervalD2FType = PyDict_GetItemString( ! mdict, "IntervalDayToFraction"); ! DataRowType = PyDict_GetItemString(mdict, "Row"); Py_INCREF(IntervalY2MType); Py_INCREF(IntervalD2FType); *************** *** 3825,3828 **** --- 3871,3890 ---- PyDateTime_IMPORT; + #if HAVE_DECIMAL + DecimalType = NULL; + module = PyImport_ImportModule("decimal"); + if (module) { + mdict = PyModule_GetDict(module); + if (mdict) { + DecimalType = PyDict_GetItemString(mdict, "Decimal"); + } + } + if (!DecimalType) { + DecimalType = Py_None; + PyErr_SetString(PyExc_ImportError, "can't find decimal.Decimal"); + } + Py_INCREF(DecimalType); + #endif + #ifndef _WIN32 /* when using a connection mode with forking (i.e. Informix SE) |
From: Carsten H. <ch...@us...> - 2005-11-29 02:39:29
|
Update of /cvsroot/informixdb/informixdb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26354 Modified Files: setup.py Log Message: add optional mapping of DECIMAL/MONEY to decimal.Decimal if the decimal module is available. Index: setup.py =================================================================== RCS file: /cvsroot/informixdb/informixdb/setup.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** setup.py 20 Nov 2005 05:46:28 -0000 1.9 --- setup.py 29 Nov 2005 02:39:21 -0000 1.10 *************** *** 157,163 **** return 0 extra_macros = [('PYTHON_INCLUDE', get_python_inc(plat_specific=1)), ('HAVE_C_DATETIME', have_c_datetime()), ! ('HAVE_PY_BOOL', have_py_bool()) ] modules = [ 'informixdb' ] --- 157,171 ---- return 0 + def have_decimal(): + try: + import decimal + return 1 + except: + return 0 + extra_macros = [('PYTHON_INCLUDE', get_python_inc(plat_specific=1)), ('HAVE_C_DATETIME', have_c_datetime()), ! ('HAVE_PY_BOOL', have_py_bool()), ! ('HAVE_DECIMAL', have_decimal()) ] modules = [ 'informixdb' ] |
From: Carsten H. <ch...@us...> - 2005-11-28 01:42:18
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19529/ext Modified Files: _informixdb.ec Log Message: Having an autocommit feature might be useful, so here it is. Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** _informixdb.ec 26 Nov 2005 06:34:27 -0000 1.49 --- _informixdb.ec 28 Nov 2005 01:42:07 -0000 1.50 *************** *** 668,671 **** --- 668,672 ---- PyObject *messages; PyObject *errorhandler; + int autocommit; } Connection; *************** *** 673,676 **** --- 674,680 ---- static int Connection_init(Connection *self, PyObject *args, PyObject* kwds); + static PyObject *Connection_getautocommit(Connection* self, void* closure); + static int Connection_setautocommit(Connection *self, PyObject *value, + void *closure); static void Connection_dealloc(Connection *self); static PyObject *Connection_cursor(Connection *self, PyObject *args, PyObject *kwds); *************** *** 798,801 **** --- 802,811 ---- } + PyDoc_STRVAR(Connection_autocommit_doc, "\ + Controls whether operations are automatically committed.\n\n\ + If autocommit is true, the connection operates without transactions\n\ + and all operations are committed immediately. By default, autocommit\n\ + is false."); + static PyGetSetDef Connection_getseters[] = { { "Warning", (getter)Connection_getexception, NULL, *************** *** 819,822 **** --- 829,834 ---- { "NotSupportedError", (getter)Connection_getexception, NULL, ExcNotSupportedError_doc, DEFERRED_ADDRESS(ExcNotSupportedError) }, + { "autocommit", (getter)Connection_getautocommit, + (setter)Connection_setautocommit, Connection_autocommit_doc, NULL }, { NULL } }; *************** *** 951,955 **** require_open(self); ! if (self->has_commit) { if (setConnection(self)) return NULL; EXEC SQL ROLLBACK WORK; --- 963,967 ---- require_open(self); ! if (self->has_commit && !self->autocommit) { if (setConnection(self)) return NULL; EXEC SQL ROLLBACK WORK; *************** *** 991,995 **** require_open(self); ! if (self->has_commit) { if (setConnection(self)) return NULL; EXEC SQL COMMIT WORK; --- 1003,1007 ---- require_open(self); ! if (self->has_commit && !self->autocommit) { if (setConnection(self)) return NULL; EXEC SQL COMMIT WORK; *************** *** 1017,1022 **** if (self->has_commit) { ! EXEC SQL ROLLBACK WORK; ! ret_on_dberror(self, NULL, "ROLLBACK"); } else { error_handle(self, NULL, --- 1029,1036 ---- if (self->has_commit) { ! if (!self->autocommit) { ! EXEC SQL ROLLBACK WORK; ! ret_on_dberror(self, NULL, "ROLLBACK"); ! } } else { error_handle(self, NULL, *************** *** 1025,1030 **** } ! EXEC SQL BEGIN WORK; ! ret_on_dberror(self, NULL, "BEGIN"); Py_INCREF(Py_None); --- 1039,1046 ---- } ! if (!self->autocommit) { ! EXEC SQL BEGIN WORK; ! ret_on_dberror(self, NULL, "BEGIN"); ! } Py_INCREF(Py_None); *************** *** 1749,1753 **** cleanInputBinding(self); useInsertCursor = ! (self->conn->has_commit && self->stype==SQ_INSERT); } else { doCloseCursor(self, 1); --- 1765,1769 ---- cleanInputBinding(self); useInsertCursor = ! (self->conn->has_commit&&!self->conn->autocommit&&self->stype==SQ_INSERT); } else { doCloseCursor(self, 1); *************** *** 1787,1791 **** useInsertCursor = ! (self->conn->has_commit && self->stype==SQ_INSERT); if (useInsertCursor) { --- 1803,1807 ---- useInsertCursor = ! (self->conn->has_commit&&!self->conn->autocommit&&self->stype==SQ_INSERT); if (useInsertCursor) { *************** *** 2646,2654 **** char *dbPass = NULL; EXEC SQL END DECLARE SECTION; ! static char* kwd_list[] = { "dsn", "user", "password", 0 }; ! if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|ss", kwd_list, ! &connectionString, &dbUser, &dbPass)) { return -1; } --- 2662,2671 ---- char *dbPass = NULL; EXEC SQL END DECLARE SECTION; + int autocommit = 0; ! static char* kwd_list[] = { "dsn", "user", "password", "autocommit", 0 }; ! if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|ssi", kwd_list, ! &connectionString, &dbUser, &dbPass, &autocommit)) { return -1; } *************** *** 2675,2680 **** self->is_open = 1; self->has_commit = (sqlca.sqlwarn.sqlwarn1 == 'W'); ! if (self->has_commit) { EXEC SQL BEGIN WORK; if (is_dberror(self, NULL, "BEGIN")) { --- 2692,2699 ---- self->is_open = 1; self->has_commit = (sqlca.sqlwarn.sqlwarn1 == 'W'); + self->autocommit = 0; + if (autocommit) self->autocommit = 1; ! if (self->has_commit && !self->autocommit) { EXEC SQL BEGIN WORK; if (is_dberror(self, NULL, "BEGIN")) { *************** *** 2688,2691 **** --- 2707,2742 ---- } + static PyObject *Connection_getautocommit(Connection* self, void* closure) + { + if (self->autocommit) { + Py_INCREF(Py_True); + return Py_True; + } + else { + Py_INCREF(Py_False); + return Py_False; + } + } + + static int Connection_setautocommit(Connection *self, PyObject *value, + void *closure) + { + int newautocommit = 0; + if (PyObject_IsTrue(value)==1) { newautocommit = 1; } + if (setConnection(self)) return 1; + if (self->autocommit != newautocommit && self->has_commit) { + if (newautocommit) { + EXEC SQL COMMIT WORK; + if (is_dberror(self, NULL, "COMMIT")) { return 1; } + } + else { + EXEC SQL BEGIN WORK; + if (is_dberror(self, NULL, "BEGIN")) { return 1; } + } + } + self->autocommit = newautocommit; + return 0; + } + static PyObject* DatabaseError_init(PyObject* self, PyObject* args, PyObject* kwds) { *************** *** 3107,3111 **** PyDoc_STRVAR(db_connect_doc, ! "connect(dsn[,user,password]) -> Connection\n\n\ Establish a connection to a database.\n\n\ 'dsn' identifies a database environment as accepted by the CONNECT\n\ --- 3158,3162 ---- PyDoc_STRVAR(db_connect_doc, ! "connect(dsn[,user,password,autocommit]) -> Connection\n\n\ Establish a connection to a database.\n\n\ 'dsn' identifies a database environment as accepted by the CONNECT\n\ |
From: Carsten H. <ch...@us...> - 2005-11-26 06:34:36
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26964/ext Modified Files: _informixdb.ec Log Message: include detailed type name for UDTs in Cursor.description Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** _informixdb.ec 24 Nov 2005 06:56:16 -0000 1.48 --- _informixdb.ec 26 Nov 2005 06:34:27 -0000 1.49 *************** *** 1401,1404 **** --- 1401,1417 ---- } + static inline PyObject* gettypename(struct sqlvar_struct *var) + { + #ifdef HAVE_UDT + if (ISCOMPLEXTYPE(var->sqltype)||ISUDTTYPE(var->sqltype)) { + return PyString_FromFormat("%s '%s'", rtypname(var->sqltype), + var->sqltypename); + } + else return PyString_FromString(rtypname(var->sqltype)); + #else + return PyString_FromString(rtypname(var->sqltype)); + #endif + } + static void bindOutput(Cursor *cur) { *************** *** 1423,1427 **** PyObject *new_tuple = Py_BuildValue("(sNiiOOi)", var->sqlname, ! PyString_FromString(rtypname(var->sqltype)), var->sqllen, var->sqllen, --- 1436,1440 ---- PyObject *new_tuple = Py_BuildValue("(sNiiOOi)", var->sqlname, ! gettypename(var), var->sqllen, var->sqllen, |
From: Carsten H. <ch...@us...> - 2005-11-26 00:51:43
|
Update of /cvsroot/informixdb/informixdb/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28475 Modified Files: manual.txt Log Message: spelling corrections Index: manual.txt =================================================================== RCS file: /cvsroot/informixdb/informixdb/doc/manual.txt,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** manual.txt 24 Nov 2005 21:01:07 -0000 1.8 --- manual.txt 26 Nov 2005 00:51:34 -0000 1.9 *************** *** 98,105 **** InformixDB will catch most of these errors since it requires the number of ! actual paramaters to match the number of parameters which are referenced by the SQL statement exactly. ! Calling stored procedures with arguments is supported in a similiar way, except that no placeholders have to be specified:: --- 98,105 ---- InformixDB will catch most of these errors since it requires the number of ! actual parameters to match the number of parameters which are referenced by the SQL statement exactly. ! Calling stored procedures with arguments is supported in a similar way, except that no placeholders have to be specified:: *************** *** 321,325 **** ``DATE`` ! `datettime.date`; ``informixdb.Date(year,month,day)`` or ``informixdb.DateFromTicks(ticks)`` should be used to create database independent date values. --- 321,325 ---- ``DATE`` ! `datetime.date`; ``informixdb.Date(year,month,day)`` or ``informixdb.DateFromTicks(ticks)`` should be used to create database independent date values. *************** *** 417,421 **** Base and catch-all for errors reported by the database. `DatabaseError` or subclasses of it are raised whenever a database ! oparations fails. When it's possible to determine the class of an error via ``SQLSTATE``, the more specific error types are raised. --- 417,421 ---- Base and catch-all for errors reported by the database. `DatabaseError` or subclasses of it are raised whenever a database ! operation fails. When it's possible to determine the class of an error via ``SQLSTATE``, the more specific error types are raised. |
From: Daniel S. <da...@us...> - 2005-11-24 21:01:18
|
Update of /cvsroot/informixdb/informixdb/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22634 Modified Files: manual.txt Log Message: small documentation fix Index: manual.txt =================================================================== RCS file: /cvsroot/informixdb/informixdb/doc/manual.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** manual.txt 20 Nov 2005 05:34:34 -0000 1.7 --- manual.txt 24 Nov 2005 21:01:07 -0000 1.8 *************** *** 98,102 **** InformixDB will catch most of these errors since it requires the number of ! arguments to match the number of parameters exactly. Calling stored procedures with arguments is supported in a similiar way, --- 98,103 ---- InformixDB will catch most of these errors since it requires the number of ! actual paramaters to match the number of parameters which are referenced by the ! SQL statement exactly. Calling stored procedures with arguments is supported in a similiar way, *************** *** 109,113 **** To retrieve the results of a previously executed SQL statement or stored ! procedure `Cursor` objects provide tho `fetchone`, `fetchmany` and `fetchall` methods: --- 110,114 ---- To retrieve the results of a previously executed SQL statement or stored ! procedure `Cursor` objects provide the `fetchone`, `fetchmany` and `fetchall` methods: |
From: Carsten H. <ch...@us...> - 2005-11-24 06:56:27
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7735/ext Modified Files: _informixdb.ec Log Message: Add support for SQL-side booleans and make logic for handling extra types a tiny bit less weird. Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** _informixdb.ec 21 Nov 2005 03:50:38 -0000 1.47 --- _informixdb.ec 24 Nov 2005 06:56:16 -0000 1.48 *************** *** 1196,1199 **** --- 1196,1211 ---- } #endif + #ifdef SQLBOOL + if ((var->sqltype&SQLTYPE)==SQLBOOL + || LIKEBOOLEANXTYPE(var->sqltype, var->sqlxid) ) { + var->sqltype = CBOOLTYPE; + var->sqldata = malloc(1); + var->sqllen = 1; + *var->sqlind = 0; + *var->sqldata = 0; + if (PyObject_IsTrue(item)==1) { *var->sqldata = 1; } + return 1; + } + #endif sitem = PyObject_Str(item); val = PyString_AS_STRING((PyStringObject*)sitem); *************** *** 1464,1476 **** var->sqltype = CINVTYPE; break; ! default: #ifdef HAVE_SBLOB ! if (ISSMARTBLOB(var->sqltype, var->sqlxid)) { /* Smart large object: allocate space for its LO handle */ var->sqldata = malloc(sizeof(ifx_lo_t)); ! } else #endif #ifdef HAVE_UDT ! if (ISCOMPLEXTYPE(var->sqltype) || ISUDTTYPE(var->sqltype)) { /* Other UDT: allocate an lvarchar pointer for the string representation. Note that smart large objects are UDTs, too, --- 1476,1499 ---- var->sqltype = CINVTYPE; break; ! default: { ! int known_type = 0; ! #ifdef SQLBOOL ! if (!known_type && ! ((var->sqltype&SQLTYPE)==SQLBOOL ! || LIKEBOOLEANXTYPE(var->sqltype, var->sqlxid))) { ! var->sqltype = CBOOLTYPE; ! known_type = 1; ! } ! #endif #ifdef HAVE_SBLOB ! if (!known_type && ISSMARTBLOB(var->sqltype, var->sqlxid)) { /* Smart large object: allocate space for its LO handle */ var->sqldata = malloc(sizeof(ifx_lo_t)); ! known_type = 1; ! } #endif #ifdef HAVE_UDT ! if (!known_type&& ! (ISCOMPLEXTYPE(var->sqltype)||ISUDTTYPE(var->sqltype))) { /* Other UDT: allocate an lvarchar pointer for the string representation. Note that smart large objects are UDTs, too, *************** *** 1489,1497 **** var->sqldata = *currentlvarcharptr; var->sqllen = sizeof(void *); ! } else #endif var->sqltype = CCHARTYPE; ! break; ! } if (!var->sqldata) { --- 1512,1523 ---- var->sqldata = *currentlvarcharptr; var->sqllen = sizeof(void *); ! known_type = 1; ! } #endif + /* fall back to character string */ + if (!known_type) var->sqltype = CCHARTYPE; ! break; ! } } if (!var->sqldata) { *************** *** 1539,1542 **** --- 1565,1583 ---- } + static void copyDescr(struct sqlda *tdaDest, struct sqlda *tdaSrc) + { + int i; + struct sqlvar_struct *varDest, *varSrc; + varDest = tdaDest->sqlvar; + varSrc = tdaSrc->sqlvar; + for (i=0; i<tdaSrc->sqld; i++) { + varDest->sqltype = varSrc->sqltype; + varDest->sqllen = varSrc->sqllen; + varDest->sqlxid = varSrc->sqlxid; + varSrc++; + varDest++; + } + } + static PyObject *Cursor_execute(Cursor *self, PyObject *args, PyObject *kwds) { *************** *** 1608,1611 **** --- 1649,1654 ---- self->scroll_value = 0; } else { + /* If available, copy information about input parameters into daIn */ + copyDescr(tdaIn, tdaOut); free(self->daOut); self->daOut = NULL; *************** *** 1724,1727 **** --- 1767,1772 ---- self->state = 2; } else { + /* If available, copy information about input parameters into daIn */ + copyDescr(tdaIn, tdaOut); free(self->daOut); self->daOut = NULL; *************** *** 1983,1986 **** --- 2028,2038 ---- } /* case SQLTEXT */ } /* switch */ + #ifdef SQLBOOL + if ((type&SQLTYPE)==SQLBOOL||LIKEBOOLEANXTYPE(type,xid) ) { + PyObject *result = (*(char*)data)?Py_True:Py_False; + Py_INCREF(result); + return result; + } + #endif #ifdef HAVE_SBLOB if (ISSMARTBLOB(type,xid)) { *************** *** 1994,1998 **** new_sblob->sblob_type = SBLOB_TYPE_BLOB; return (PyObject*)new_sblob; ! } else #endif #ifdef HAVE_UDT --- 2046,2050 ---- new_sblob->sblob_type = SBLOB_TYPE_BLOB; return (PyObject*)new_sblob; ! } #endif #ifdef HAVE_UDT *************** *** 2005,2010 **** } #endif ! Py_INCREF(Py_None); ! return Py_None; } --- 2057,2069 ---- } #endif ! { ! /* Unknown type. bindOutput falls back to binding to a character string. ! If Informix actually managed to read this unknown type into that string, ! we might as well return it instead of returning None. */ ! register size_t len = strlen((char*)data); ! register size_t clipped_len = byleng(data, len); ! ((char*)data)[clipped_len] = 0; ! return Py_BuildValue("s", (char*)data); ! } } |
From: Carsten H. <ch...@us...> - 2005-11-21 04:26:05
|
Update of /cvsroot/informixdb/informixdb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5124 Modified Files: README Log Message: update 2.1 release date Index: README =================================================================== RCS file: /cvsroot/informixdb/informixdb/README,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** README 20 Nov 2005 05:57:07 -0000 1.9 --- README 21 Nov 2005 04:25:56 -0000 1.10 *************** *** 245,249 **** 1.5 2005-09-18 Carsten Haese 2.0 2005-10-22 Carsten Haese ! 2.1 TBD Carsten Haese -- --- 245,249 ---- 1.5 2005-09-18 Carsten Haese 2.0 2005-10-22 Carsten Haese ! 2.1 2005-11-21 Carsten Haese -- |
From: Carsten H. <ch...@us...> - 2005-11-21 03:50:45
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30602/ext Modified Files: _informixdb.ec Log Message: sqlsignal() doesn't seem to exist on Windows. Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** _informixdb.ec 20 Nov 2005 05:03:35 -0000 1.46 --- _informixdb.ec 21 Nov 2005 03:50:38 -0000 1.47 *************** *** 3702,3708 **** --- 3702,3710 ---- PyDateTime_IMPORT; + #ifndef _WIN32 /* when using a connection mode with forking (i.e. Informix SE) child processes might stay around as <defunct> unless SIGCHLD is handled */ sqlsignal(-1, (void*)NULL, 0); + #endif } |
From: Carsten H. <ch...@us...> - 2005-11-20 05:57:14
|
Update of /cvsroot/informixdb/informixdb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6805 Modified Files: README Log Message: Another README update for version 2.1 Index: README =================================================================== RCS file: /cvsroot/informixdb/informixdb/README,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** README 20 Nov 2005 05:46:28 -0000 1.8 --- README 20 Nov 2005 05:57:07 -0000 1.9 *************** *** 210,216 **** ====== ! - Implement useful optional DB-API extensions if there are any that Daniel ! hasn't already implemented. ;) ! - Low priority unless people ask for it: support SLOBs and UDTs. MAINTAINER --- 210,214 ---- ====== ! - Nothing planned at the moment. Let me know if you think a feature is missing. MAINTAINER |
From: Carsten H. <ch...@us...> - 2005-11-20 05:46:36
|
Update of /cvsroot/informixdb/informixdb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4636 Modified Files: README setup.py Log Message: prepare for version 2.1 Index: README =================================================================== RCS file: /cvsroot/informixdb/informixdb/README,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** README 23 Oct 2005 02:33:27 -0000 1.7 --- README 20 Nov 2005 05:46:28 -0000 1.8 *************** *** 2,6 **** ============ ! This is informixdb 2.0, an Informix implementation of the Python Database API. This release implements version 2.0 of the DB-API: --- 2,6 ---- ============ ! This is informixdb 2.1, an Informix implementation of the Python Database API. This release implements version 2.0 of the DB-API: *************** *** 11,15 **** - `_informixdb', a Python C extension that interfaces with INFORMIX-ESQL/C and implements the DB-API. ! - `informixdb', a very thin Python wrapper around _informixdb It is released under a BSD-like license. See the COPYRIGHT file --- 11,16 ---- - `_informixdb', a Python C extension that interfaces with INFORMIX-ESQL/C and implements the DB-API. ! - `informixdb', a Python module that wraps around _informixdb and implements ! various helper classes. It is released under a BSD-like license. See the COPYRIGHT file *************** *** 76,79 **** --- 77,85 ---- ==== + From 2.0 to 2.1: + - INTERVAL support + - Scroll cursor and cursor with hold + - Support for Smart Large Objects and User Defined Types + From 1.5 to 2.0: *************** *** 241,244 **** --- 247,251 ---- 1.5 2005-09-18 Carsten Haese 2.0 2005-10-22 Carsten Haese + 2.1 TBD Carsten Haese -- Index: setup.py =================================================================== RCS file: /cvsroot/informixdb/informixdb/setup.py,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** setup.py 27 Oct 2005 15:22:20 -0000 1.8 --- setup.py 20 Nov 2005 05:46:28 -0000 1.9 *************** *** 190,195 **** setup (name = 'InformixDB', ! version = '2.0', ! description = 'InformixDB v2.0', long_description = \ "InformixDB is a DB-API 2.0 compliant interface for IBM Informix\n" --- 190,195 ---- setup (name = 'InformixDB', ! version = '2.1', ! description = 'InformixDB v2.1', long_description = \ "InformixDB is a DB-API 2.0 compliant interface for IBM Informix\n" |
From: Carsten H. <ch...@us...> - 2005-11-20 05:34:41
|
Update of /cvsroot/informixdb/informixdb/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2571 Modified Files: manual.txt Log Message: Add new features to the manual Index: manual.txt =================================================================== RCS file: /cvsroot/informixdb/informixdb/doc/manual.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** manual.txt 18 Nov 2005 04:45:57 -0000 1.6 --- manual.txt 20 Nov 2005 05:34:34 -0000 1.7 *************** *** 5,9 **** :Authors: Daniel Smertnig :Version: informixdb 2.1 ! :Date: 2005-11-17 :Homepage: `InformixDB on Sourceforge`_ --- 5,9 ---- :Authors: Daniel Smertnig :Version: informixdb 2.1 ! :Date: 2005-11-20 :Homepage: `InformixDB on Sourceforge`_ *************** *** 267,270 **** --- 267,289 ---- See `Advanced error handling`_ on how to use `errorhandler` and `messages`. + Scroll Cursors and Cursors with Hold + ------------------------------------ + `(new in version 2.1)` + + InformixDB allows you to use scroll cursors and cursors with hold. To + create a scroll cursor, pass the argument ``scroll=True`` to the + `Connection.cursor()` call. To create a cursor with hold, pass the argument + ``hold=True``. Both arguments may be given together to create a scroll cursor + with hold. + + If a cursor was created as a scroll cursor, you may use its `scroll()` + method to navigate through the result set. `scroll()` takes up to two + arguments, a mandatory `value` argument and an optional `mode` argument. + If given, `mode` must be either ``'absolute'`` or ``'relative'``, + and it defaults to ``'relative'`` if not given. In absolute mode, `value` + is the result row number to which you want to scroll. In relative mode, + `value` is the number of rows by which you want to scroll from the current + row. + Transactions ============ |
From: Carsten H. <ch...@us...> - 2005-11-20 05:03:44
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30421/ext Modified Files: _informixdb.ec Log Message: Add doc strings for new features. Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** _informixdb.ec 20 Nov 2005 02:26:18 -0000 1.45 --- _informixdb.ec 20 Nov 2005 05:03:35 -0000 1.46 *************** *** 231,234 **** --- 231,286 ---- } Sblob; + PyDoc_STRVAR(Sblob_doc, "\ + Smart Large Object for input and output binding of BLOB and CLOB\n\ + columns.\n\n\ + To create an Sblob object, call Connection.Sblob()."); + + PyDoc_STRVAR(Sblob_close_doc, "\ + close()\n\n\ + Close the Sblob."); + + PyDoc_STRVAR(Sblob_open_doc, "\ + open([flags])\n\n\ + Open the Sblob using the given access flags."); + + PyDoc_STRVAR(Sblob_read_doc, "\ + read(nbytes) -> string\n\n\ + Read up to nbytes bytes from the current file position and returns\n\ + the contents in a string."); + + PyDoc_STRVAR(Sblob_write_doc, "\ + write(buf) -> int\n\n\ + Writes the contents of buf at the current file position and returns\n\ + the number of bytes written."); + + PyDoc_STRVAR(Sblob_seek_doc, "\ + seek(offset, whence) -> long\n\n\ + Sets the file position to the specified 'offset' relative to\n\ + 'whence'.\n\n\ + 'whence' can be LO_SEEK_SET, LO_SEEK_CUR, or LO_SEEK_END, indicating\n\ + that the offset is relative to the beginning, the current file\n\ + position, or the end of the smart large object, respectively.\n\ + \n\ + The return value is the resulting file position."); + + PyDoc_STRVAR(Sblob_tell_doc, "\ + tell() -> long\n\n\ + Returns the current file position."); + + PyDoc_STRVAR(Sblob_stat_doc, "\ + stat() -> dict\n\n\ + Returns file status information in a dictionary with the following\n\ + keys:\n\n\ + size = content size in bytes\n\ + atime = last access time\n\ + ctime = last change-in-status time\n\ + mtime = last modification time\n\ + refcnt = reference count"); + + PyDoc_STRVAR(Sblob_truncate_doc, "\ + truncate(offset)\n\n\ + Truncates or expands the smart large object such that the given\n\ + offset is at the end of the smart large object."); + static int Sblob_init(Sblob *self, PyObject *args, PyObject *kwargs); static void Sblob_dealloc(Sblob *self); *************** *** 245,256 **** static PyMethodDef Sblob_methods[] = { ! { "close", (PyCFunction)Sblob_close, METH_NOARGS }, ! { "open", (PyCFunction)Sblob_open, METH_VARARGS|METH_KEYWORDS }, ! { "read", (PyCFunction)Sblob_read, METH_VARARGS|METH_KEYWORDS }, ! { "write", (PyCFunction)Sblob_write, METH_VARARGS|METH_KEYWORDS }, ! { "seek", (PyCFunction)Sblob_seek, METH_VARARGS|METH_KEYWORDS }, ! { "tell", (PyCFunction)Sblob_tell, METH_NOARGS }, ! { "stat", (PyCFunction)Sblob_stat, METH_NOARGS }, ! { "truncate", (PyCFunction)Sblob_truncate, METH_VARARGS|METH_KEYWORDS }, { NULL } }; --- 297,316 ---- static PyMethodDef Sblob_methods[] = { ! { "close", (PyCFunction)Sblob_close, METH_NOARGS, ! Sblob_close_doc }, ! { "open", (PyCFunction)Sblob_open, METH_VARARGS|METH_KEYWORDS, ! Sblob_open_doc }, ! { "read", (PyCFunction)Sblob_read, METH_VARARGS|METH_KEYWORDS, ! Sblob_read_doc }, ! { "write", (PyCFunction)Sblob_write, METH_VARARGS|METH_KEYWORDS, ! Sblob_write_doc }, ! { "seek", (PyCFunction)Sblob_seek, METH_VARARGS|METH_KEYWORDS, ! Sblob_seek_doc }, ! { "tell", (PyCFunction)Sblob_tell, METH_NOARGS, ! Sblob_tell_doc }, ! { "stat", (PyCFunction)Sblob_stat, METH_NOARGS, ! Sblob_stat_doc }, ! { "truncate", (PyCFunction)Sblob_truncate, METH_VARARGS|METH_KEYWORDS, ! Sblob_truncate_doc }, { NULL } }; *************** *** 269,282 **** static PyGetSetDef Sblob_properties[] = { ! { "estbytes", (getter)Sblob_specget, (setter)NULL, "", ! (void*)SBLOB_CSPEC_ESTBYTES }, ! { "extsz", (getter)Sblob_specget, (setter)Sblob_alter, "", ! (void*)SBLOB_CSPEC_EXTSZ }, ! { "flags", (getter)Sblob_specget, (setter)Sblob_alter, "", ! (void*)SBLOB_CSPEC_FLAGS }, ! { "maxbytes", (getter)Sblob_specget, (setter)NULL, "", ! (void*)SBLOB_CSPEC_MAXBYTES }, ! { "sbspace", (getter)Sblob_specget, (setter)NULL, "", ! (void*)SBLOB_CSPEC_SBSPACE }, { NULL } }; --- 329,347 ---- static PyGetSetDef Sblob_properties[] = { ! { "estbytes", (getter)Sblob_specget, (setter)NULL, ! "Gets the Sblob's estimated size.", ! (void*)SBLOB_CSPEC_ESTBYTES }, ! { "extsz", (getter)Sblob_specget, (setter)Sblob_alter, ! "Gets or sets the Sblob's extent size.", ! (void*)SBLOB_CSPEC_EXTSZ }, ! { "flags", (getter)Sblob_specget, (setter)Sblob_alter, ! "Gets or sets the Sblob's storage characteristics flags.", ! (void*)SBLOB_CSPEC_FLAGS }, ! { "maxbytes", (getter)Sblob_specget, (setter)NULL, ! "Gets the Sblob's maximum size.", ! (void*)SBLOB_CSPEC_MAXBYTES }, ! { "sbspace", (getter)Sblob_specget, (setter)NULL, ! "Gets the Sblob's smart blob space name.", ! (void*)SBLOB_CSPEC_SBSPACE }, { NULL } }; *************** *** 304,308 **** 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ ! "", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ --- 369,373 ---- 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ ! Sblob_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ *************** *** 447,450 **** --- 512,526 ---- See also: fetchone()"); + PyDoc_STRVAR(Cursor_scroll_doc, "\ + scroll(value[,mode='relative'])\n\n\ + Scroll the cursor in the result set to a new position according to\n\ + the scroll mode.\n\n\ + scroll() raises a NotSupportedError if the cursor was not created\n\ + as a scroll cursor.\n\ + \n\ + If mode is 'relative', the value is taken as an offset to\n\ + the current position in the result set. If mode is 'absolute',\n\ + the value is taken as an absolute target position."); + PyDoc_STRVAR(Cursor_setinputsizes_doc, "setinputsizes(sizes)\n\n\ *************** *** 480,484 **** { "fetchall", (PyCFunction)Cursor_fetchall, METH_NOARGS, Cursor_fetchall_doc }, ! { "scroll", (PyCFunction)Cursor_scroll, METH_VARARGS|METH_KEYWORDS }, { "setinputsizes", (PyCFunction)Cursor_setinputsizes, METH_VARARGS|METH_KEYWORDS, Cursor_setinputsizes_doc }, --- 556,561 ---- { "fetchall", (PyCFunction)Cursor_fetchall, METH_NOARGS, Cursor_fetchall_doc }, ! { "scroll", (PyCFunction)Cursor_scroll, METH_VARARGS|METH_KEYWORDS, ! Cursor_scroll_doc }, { "setinputsizes", (PyCFunction)Cursor_setinputsizes, METH_VARARGS|METH_KEYWORDS, Cursor_setinputsizes_doc }, *************** *** 606,610 **** PyDoc_STRVAR(Connection_cursor_doc, ! "cursor([name=None,rowformat=_informixdb.ROW_AS_TUPLE]) -> Cursor\n\n\ Return a new Cursor object using the connection.\n\ \n\ --- 683,688 ---- PyDoc_STRVAR(Connection_cursor_doc, ! "cursor([name=None,rowformat=ROW_AS_TUPLE,scroll=False,hold=False])\n\ ! -> Cursor\n\n\ Return a new Cursor object using the connection.\n\ \n\ *************** *** 614,618 **** \n\ 'rowformat' allows you to optionally specify whether the cursor\n\ ! should return fetched result rows as tuples or as dictionaries."); PyDoc_STRVAR(Connection_commit_doc, --- 692,701 ---- \n\ 'rowformat' allows you to optionally specify whether the cursor\n\ ! should return fetched result rows as tuples, as dictionaries,\n\ ! or as Row objects.\n\ ! \n\ ! When 'scroll' is True, the cursor will be a scroll cursor.\n\ ! \n\ ! When 'hold' is True, the cursor will be a cursor with hold."); PyDoc_STRVAR(Connection_commit_doc, *************** *** 641,644 **** --- 724,753 ---- commit any outstanding operations before closing a Connection."); + #ifdef HAVE_SBLOB + PyDoc_STRVAR(Connection_Sblob_doc, "\ + Sblob(...) -> Sblob object\n\n\ + Create and open a Smart Large Object suitable for inserting or\n\ + updating into a BLOB or CLOB column.\n\n\ + This method has the following optional parameters:\n\n\ + type\n\ + SBLOB_TYPE_BLOB or SBLOB_TYPE_CLOB.\n\ + Default is SBLOB_TYPE_BLOB\n\ + create_flags\n\ + creation time storage characteristics (LO_ATTR_*) flags\n\ + open_flags\n\ + opening flags (LO_OPEN_*) for the Smart Large Object.\n\ + Default is LO_OPEN_RDWR\n\ + col_info\n\ + name of a database column in the format\n\ + database@server:table.column whose storage\n\ + characteristics will be used as defaults for this Sblob\n\ + sbspace, extsz, estbytes, maxbytes\n\ + storage characteristics settings\n\ + Any combination of explicit storage characteristics may be present.\n\ + Explicit storage characteristics that are given will be combined\n\ + with database defined or col_info derived default values for storage\n\ + characteristics that are not given."); + #endif + static PyMethodDef Connection_methods[] = { { "cursor", (PyCFunction)Connection_cursor, METH_VARARGS|METH_KEYWORDS, *************** *** 652,656 **** #ifdef HAVE_SBLOB { "Sblob", (PyCFunction)Connection_Sblob, METH_VARARGS|METH_KEYWORDS, ! "" }, #endif { NULL } --- 761,765 ---- #ifdef HAVE_SBLOB { "Sblob", (PyCFunction)Connection_Sblob, METH_VARARGS|METH_KEYWORDS, ! Connection_Sblob_doc }, #endif { NULL } |
From: Carsten H. <ch...@us...> - 2005-11-20 05:03:44
|
Update of /cvsroot/informixdb/informixdb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30421 Modified Files: informixdb.py Log Message: Add doc strings for new features. Index: informixdb.py =================================================================== RCS file: /cvsroot/informixdb/informixdb/informixdb.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** informixdb.py 17 Nov 2005 21:26:23 -0000 1.14 --- informixdb.py 20 Nov 2005 05:03:35 -0000 1.15 *************** *** 48,51 **** --- 48,52 ---- class Row(object): + """Helper class for cursors whose row format is ROW_AS_OBJECT.""" def __init__(self, d): self.__dict__.update(d) def __repr__(self): return repr(self.__dict__) *************** *** 53,56 **** --- 54,66 ---- class IntervalYearToMonth(object): + """\ + This class is used for input and output binding of + INTERVAL columns whose precision is a subset of + YEAR TO MONTH. + + Intervals can be added to dates, datetimes, and other Intervals + that have compatible precision. Intervals can also be multiplied + and divided by scalar factors. + """ def __init__(self, years=0, months=0): self._months = 12*years+months *************** *** 58,70 **** def __repr__(self): return "%s(%d, %d)"%(self.__class__.__name__,self.years,self.months) - # str() returns the Interval in Informix's format def __str__(self): if self._months < 0: return "-%d-%02d" % divmod(-self._months,12) else: return "%d-%02d" % divmod(self._months,12) - # arithmetic operations: analogous to timedelta. Supports adding to - # and subtracting from dates, datetimes, and other IntervalYearToMonths, - # as well as multiplying with and dividing by scalar factors. def __add__(self, other): if isinstance(other, IntervalYearToMonth): --- 68,77 ---- def __repr__(self): return "%s(%d, %d)"%(self.__class__.__name__,self.years,self.months) def __str__(self): + """Returns the interval in Informix's format for input binding.""" if self._months < 0: return "-%d-%02d" % divmod(-self._months,12) else: return "%d-%02d" % divmod(self._months,12) def __add__(self, other): if isinstance(other, IntervalYearToMonth): *************** *** 100,105 **** __rmul__ = __mul__ __floordiv__ = __div__ - # implement comparison to other IntervalYearToMonths def __cmp__(self, other): if isinstance(other, IntervalYearToMonth): return self._months - other._months --- 107,112 ---- __rmul__ = __mul__ __floordiv__ = __div__ def __cmp__(self, other): + """Implements comparisons between intervals.""" if isinstance(other, IntervalYearToMonth): return self._months - other._months *************** *** 110,117 **** import datetime class IntervalDayToFraction(datetime.timedelta): def __init__(self,days=0,seconds=0,microseconds=0): datetime.timedelta.__init__(self, days, seconds, microseconds) - # str() returns the Interval in Informix's format def __str__(self): if self.days<0: neg = IntervalDayToFraction(-self.days, -self.seconds, -self.microseconds) --- 117,133 ---- import datetime class IntervalDayToFraction(datetime.timedelta): + """\ + This class is used for input and output binding of + INTERVAL columns whose precision is a subset of + DAY TO FRACTION. + + Intervals can be added to dates, datetimes, and other Intervals + that have compatible precision. Intervals can also be multiplied + and divided by scalar factors. + """ def __init__(self,days=0,seconds=0,microseconds=0): datetime.timedelta.__init__(self, days, seconds, microseconds) def __str__(self): + """Returns the interval in Informix's format for input binding.""" if self.days<0: neg = IntervalDayToFraction(-self.days, -self.seconds, -self.microseconds) *************** *** 133,140 **** --- 149,158 ---- from _informixdb import Cursor as _Cursor, Connection as _Connection class Cursor(_Cursor): + __doc__ = _Cursor.__doc__ def __new__(self, *args, **kwargs): raise InterfaceError, "Use Connection.cursor() to instantiate a cursor." del _Cursor class Connection(_Connection): + __doc__ = _Connection.__doc__ def __new__(self, *args, **kwargs): raise InterfaceError, "Use connect() to instantiate a connection." *************** *** 144,147 **** --- 162,166 ---- from _informixdb import Sblob as _Sblob class Sblob(_Sblob): + __doc__ = _Sblob.__doc__ def __new__(self, *args, **kwargs): raise InterfaceError, "Use Connection.Sblob() to instantiate an Sblob." |
From: Carsten H. <ch...@us...> - 2005-11-20 02:26:27
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4187/ext Modified Files: _informixdb.ec Log Message: The additions to bindOutput for sblob and udt support lost functionality for simple large objects in a confusing maze of conditional compilation paths. Rearrange the output binding logic to be correct and much cleaner. Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** _informixdb.ec 19 Nov 2005 07:36:44 -0000 1.44 --- _informixdb.ec 20 Nov 2005 02:26:18 -0000 1.45 *************** *** 1293,1296 **** --- 1293,1300 ---- Py_DECREF(cur->description); cur->description = PyTuple_New(cur->daOut->sqld); + /* Objects of simple types will be packed into one combined output buffer. + Complex objects will be allocated individually. In the first loop we + gather the required size of the output buffer for the simple types, and + we allocate the individual space for the complex types here. */ for (pos = 0, var = cur->daOut->sqlvar; pos < cur->daOut->sqld; *************** *** 1308,1311 **** --- 1312,1316 ---- cur->originalType[pos] = var->sqltype; cur->originalXid[pos] = var->sqlxid; + var->sqldata = NULL; switch(var->sqltype & SQLTYPE){ *************** *** 1352,1363 **** default: #ifdef HAVE_SBLOB ! if (ISSMARTBLOB(var->sqltype, var->sqlxid)) ! ; /* do nothing */ ! else #endif #ifdef HAVE_UDT ! if (ISCOMPLEXTYPE(var->sqltype) || ISUDTTYPE(var->sqltype)) var->sqltype = CLVCHARPTRTYPE; ! else #endif var->sqltype = CCHARTYPE; --- 1357,1384 ---- default: #ifdef HAVE_SBLOB ! if (ISSMARTBLOB(var->sqltype, var->sqlxid)) { ! /* Smart large object: allocate space for its LO handle */ ! var->sqldata = malloc(sizeof(ifx_lo_t)); ! } else #endif #ifdef HAVE_UDT ! if (ISCOMPLEXTYPE(var->sqltype) || ISUDTTYPE(var->sqltype)) { ! /* Other UDT: allocate an lvarchar pointer for the string ! representation. Note that smart large objects are UDTs, too, ! so the check for sblobs must come before this one, because ! we're not interested in the string representation of an sblob. */ ! exec sql begin declare section; ! lvarchar **currentlvarcharptr; ! exec sql end declare section; ! var->sqltype = CLVCHARPTRTYPE; ! currentlvarcharptr = malloc(sizeof(void *)); ! *currentlvarcharptr = 0; ! ifx_var_flag(currentlvarcharptr,1); ! ! var->sqlxid = 1; ! var->sqldata = *currentlvarcharptr; ! var->sqllen = sizeof(void *); ! } else #endif var->sqltype = CCHARTYPE; *************** *** 1365,1391 **** } ! #ifdef HAVE_SBLOB ! if (!ISSMARTBLOB(var->sqltype, var->sqlxid)) { ! #endif ! var->sqllen = rtypmsize(var->sqltype, var->sqllen); ! count = rtypalign(count, var->sqltype) + var->sqllen; ! #ifdef HAVE_SBLOB } - #endif } bufp = cur->outputBuffer = malloc(count); for (pos = 0, var = cur->daOut->sqlvar; pos < cur->daOut->sqld; pos++, var++) { bufp = (char *) rtypalign( (int) bufp, var->sqltype); - #ifdef HAVE_SBLOB - if (ISSMARTBLOB(var->sqltype, var->sqlxid)) { - var->sqldata = malloc(sizeof(ifx_lo_t)); - } - else - #endif if (var->sqltype == CLOCATORTYPE) { loc_t *loc = (loc_t*) bufp; --- 1386,1409 ---- } ! if (!var->sqldata) { ! var->sqllen = rtypmsize(var->sqltype, var->sqllen); ! count = rtypalign(count, var->sqltype) + var->sqllen; } } + /* now we know how big the buffer needs to be, allocate it. */ bufp = cur->outputBuffer = malloc(count); + /* the second loop through is for handing out chunks of the output buffer + for the simple types. */ for (pos = 0, var = cur->daOut->sqlvar; pos < cur->daOut->sqld; pos++, var++) { + + /* skip fields that have already been allocated in the first loop */ + if (var->sqldata) continue; + bufp = (char *) rtypalign( (int) bufp, var->sqltype); if (var->sqltype == CLOCATORTYPE) { loc_t *loc = (loc_t*) bufp; *************** *** 1395,1418 **** loc->loc_mflags = 0; } ! #ifdef HAVE_UDT ! else if (var->sqltype == CLVCHARPTRTYPE ) ! { ! exec sql begin declare section; ! lvarchar **currentlvarcharptr; ! exec sql end declare section; ! ! currentlvarcharptr = malloc(sizeof(void *)); ! *currentlvarcharptr = 0; ! ifx_var_flag(currentlvarcharptr,1); ! ! var->sqlxid = 1; ! var->sqldata = *currentlvarcharptr; ! var->sqllen = sizeof(void *); ! } ! #endif ! else { ! var->sqldata = bufp; ! bufp += var->sqllen; ! } if (var->sqltype == CDTIMETYPE || var->sqltype == CINVTYPE) { --- 1413,1418 ---- loc->loc_mflags = 0; } ! var->sqldata = bufp; ! bufp += var->sqllen; if (var->sqltype == CDTIMETYPE || var->sqltype == CINVTYPE) { |
From: Carsten H. <ch...@us...> - 2005-11-19 07:36:53
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23122/ext Modified Files: _informixdb.ec Log Message: add support for WITH HOLD and SCROLL cursors Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** _informixdb.ec 19 Nov 2005 05:13:15 -0000 1.43 --- _informixdb.ec 19 Nov 2005 07:36:44 -0000 1.44 *************** *** 356,359 **** --- 356,363 ---- int arraysize; int rowformat; + int is_hold; + int is_scroll; + int pending_scroll; + int scroll_value; PyObject *messages; PyObject *errorhandler; *************** *** 368,371 **** --- 372,376 ---- static PyObject* Cursor_fetchmany(Cursor *self, PyObject *args, PyObject *kwds); static PyObject* Cursor_fetchall(Cursor *self); + static PyObject* Cursor_scroll(Cursor *self, PyObject *args, PyObject *kwds); static PyObject* Cursor_setinputsizes(Cursor *self, PyObject *args, PyObject *kwds); static PyObject* Cursor_setoutputsize(Cursor *self, PyObject *args, PyObject *kwds); *************** *** 475,478 **** --- 480,484 ---- { "fetchall", (PyCFunction)Cursor_fetchall, METH_NOARGS, Cursor_fetchall_doc }, + { "scroll", (PyCFunction)Cursor_scroll, METH_VARARGS|METH_KEYWORDS }, { "setinputsizes", (PyCFunction)Cursor_setinputsizes, METH_VARARGS|METH_KEYWORDS, Cursor_setinputsizes_doc }, *************** *** 1475,1484 **** if (self->stype == 0 || self->stype == SQ_EXECPROC) { bindOutput(self); ! ! EXEC SQL DECLARE :cursorName CURSOR FOR :queryName; ret_on_dberror_cursor(self, "DECLARE"); EXEC SQL FREE :queryName; ret_on_dberror_cursor(self, "FREE"); self->state = 2; } else { free(self->daOut); --- 1481,1501 ---- if (self->stype == 0 || self->stype == SQ_EXECPROC) { bindOutput(self); ! switch (self->is_hold + 2*self->is_scroll) { ! case 3: ! EXEC SQL DECLARE :cursorName SCROLL CURSOR WITH HOLD FOR :queryName; ! break; ! case 2: ! EXEC SQL DECLARE :cursorName SCROLL CURSOR FOR :queryName; break; ! case 1: ! EXEC SQL DECLARE :cursorName CURSOR WITH HOLD FOR :queryName; break; ! case 0: ! EXEC SQL DECLARE :cursorName CURSOR FOR :queryName; break; ! } ret_on_dberror_cursor(self, "DECLARE"); EXEC SQL FREE :queryName; ret_on_dberror_cursor(self, "FREE"); self->state = 2; + self->pending_scroll = 0; + self->scroll_value = 0; } else { free(self->daOut); *************** *** 2130,2139 **** char *name = NULL; int rowformat = CURSOR_ROWFORMAT_TUPLE; ! static char* kwdlist[] = { "connection", "name", "rowformat", 0 }; ! ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|si", kwdlist, ! &Connection_type, &conn, ! &name, &rowformat)) return -1; --- 2147,2157 ---- char *name = NULL; int rowformat = CURSOR_ROWFORMAT_TUPLE; + int is_scroll = 0; + int is_hold = 0; + static char* kwdlist[] = { "connection", "name", "rowformat", + "scroll", "hold", 0 }; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!|siii", kwdlist, ! &Connection_type, &conn, &name, &rowformat, &is_scroll, &is_hold)) return -1; *************** *** 2153,2156 **** --- 2171,2178 ---- self->stype = -1; self->op = 0; + self->is_hold = 0; + self->is_scroll = 0; + self->pending_scroll = 0; + self->scroll_value = 0; if (name) { self->cursorName = strdup(name); *************** *** 2173,2177 **** self->rowformat = CURSOR_ROWFORMAT_ROWOBJ; } ! return 0; } --- 2195,2200 ---- self->rowformat = CURSOR_ROWFORMAT_ROWOBJ; } ! if (is_scroll) self->is_scroll = 1; ! if (is_hold) self->is_hold = 1; return 0; } *************** *** 2212,2216 **** Py_BEGIN_ALLOW_THREADS; ! EXEC SQL FETCH :cursorName USING DESCRIPTOR tdaOut; Py_END_ALLOW_THREADS; for (i=0; i<6; i++) --- 2235,2260 ---- Py_BEGIN_ALLOW_THREADS; ! if (self->is_scroll) { ! exec sql begin declare section; ! int scroll_val; ! exec sql end declare section; ! scroll_val = self->scroll_value; ! switch (self->pending_scroll) { ! case 0: ! EXEC SQL FETCH NEXT :cursorName USING DESCRIPTOR tdaOut; ! break; ! case 1: ! EXEC SQL FETCH ABSOLUTE :scroll_val :cursorName USING DESCRIPTOR tdaOut; ! break; ! case 2: ! EXEC SQL FETCH RELATIVE :scroll_val :cursorName USING DESCRIPTOR tdaOut; ! break; ! } ! self->pending_scroll = 0; ! self->scroll_value = 0; ! } ! else { ! EXEC SQL FETCH :cursorName USING DESCRIPTOR tdaOut; ! } Py_END_ALLOW_THREADS; for (i=0; i<6; i++) *************** *** 2276,2279 **** --- 2320,2385 ---- } + static PyObject* Cursor_scroll(Cursor *self, PyObject *args, PyObject *kwds) + { + int value; + char *mode_str = NULL; + int mode = 0; + static char* kwdnames[] = { "value", "mode", NULL }; + + require_cursor_open(self); + if (!self->is_scroll) { + /* force error -482, Invalid operation on a non-SCROLL cursor. */ + struct sqlda *tdaOut = self->daOut; + EXEC SQL BEGIN DECLARE SECTION; + char *cursorName; + EXEC SQL END DECLARE SECTION; + cursorName = self->cursorName; + EXEC SQL FETCH CURRENT :cursorName USING DESCRIPTOR tdaOut; + error_handle(self->conn, self, + ExcNotSupportedError, dberror_value("scroll")); + return NULL; + } + if (!PyArg_ParseTupleAndKeywords(args, kwds, "i|s", kwdnames, + &value, &mode_str)) + return NULL; + + if (mode_str==NULL || *mode_str==0) { + mode = 2; + } else if (!strncmp(mode_str, "relative", strlen(mode_str))) { + mode = 2; + } else if (!strncmp(mode_str, "absolute", strlen(mode_str))) { + mode = 1; + } else { + PyErr_Format(ExcInterfaceError,"Unrecognized scroll mode '%s'.", mode_str); + return NULL; + } + /* Actual scrolling on the database side is tied to fetching. We could do + a dummy fetch now and then "fetch current" when the user actually fetches, + but that would waste time on unnecessary fetches. Instead, we'll just + make a note of a pending scroll until the actual fetch. Since the user + may call scroll() in sequence without fetching in between, this scroll + may modify an existing pending scroll. */ + if (self->pending_scroll==0) { + /* No previous scroll pending, straightforward. */ + self->pending_scroll = mode; + self->scroll_value = value; + } + else { + /* Modify pending scroll */ + if (mode==1) { + /* a new absolute scroll overwrites the pending scroll */ + self->pending_scroll = mode; + self->scroll_value = value; + } + else { + /* a new relative scroll gets added to pending scroll, regardless of + whether the pending scoll is absolute or relative */ + self->scroll_value += value; + } + } + Py_INCREF(Py_None); + return Py_None; + } + static PyObject *Cursor_setinputsizes(Cursor *self, PyObject *args, |
From: Carsten H. <ch...@us...> - 2005-11-19 05:13:23
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1671/ext Modified Files: _informixdb.ec Log Message: implement Sblob.truncate(), fix compiler warnings. Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** _informixdb.ec 18 Nov 2005 03:50:59 -0000 1.42 --- _informixdb.ec 19 Nov 2005 05:13:15 -0000 1.43 *************** *** 240,243 **** --- 240,244 ---- static PyObject *Sblob_tell(Sblob *self); static PyObject *Sblob_stat(Sblob *self); + static PyObject *Sblob_truncate(Sblob *self, PyObject *args, PyObject *kwargs); static PyObject *Sblob_specget(Sblob *self, void *closure); static int Sblob_alter(Sblob *self, PyObject *value, void *closure); *************** *** 251,254 **** --- 252,256 ---- { "tell", (PyCFunction)Sblob_tell, METH_NOARGS }, { "stat", (PyCFunction)Sblob_stat, METH_NOARGS }, + { "truncate", (PyCFunction)Sblob_truncate, METH_VARARGS|METH_KEYWORDS }, { NULL } }; *************** *** 3094,3098 **** { static char* kwdlist[] = { "offset", "whence", 0 }; - mint result; PyObject *py_offset; char pos_str[30]; --- 3096,3099 ---- *************** *** 3209,3212 **** --- 3210,3239 ---- } + static PyObject *Sblob_truncate(Sblob *self, PyObject *args, PyObject *kwargs) + { + static char* kwdlist[] = { "offset", 0 }; + PyObject *py_offset; + ifx_int8_t offset; + + if (!self->lofd) { + if (error_handle(self->conn, NULL, ExcInterfaceError, + PyString_FromString("Sblob is not open"))) + return NULL; + } + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", kwdlist, &py_offset)) + return NULL; + + if (makeint8(py_offset, &offset)<0) { + PyErr_SetString(PyExc_TypeError, "non-numeric offset"); + return NULL; + } + if (setConnection(self->conn)) return NULL; + if (ifx_lo_truncate(self->lofd, &offset)<0) { + ret_on_dberror(self->conn, NULL, "ifx_lo_truncate"); + } + Py_INCREF(Py_None); + return Py_None; + } + static PyObject *Sblob_specget(Sblob *self, void *closure) { *************** *** 3214,3218 **** ifx_lo_create_spec_t *lo_spec; ifx_int8_t int8result; ! mint mintresult; char buf[129]; --- 3241,3245 ---- ifx_lo_create_spec_t *lo_spec; ifx_int8_t int8result; ! mint mintresult=0; char buf[129]; |
From: Carsten H. <ch...@us...> - 2005-11-18 04:46:05
|
Update of /cvsroot/informixdb/informixdb/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21595 Modified Files: manual.txt Log Message: update documentation to reflect new features. Index: manual.txt =================================================================== RCS file: /cvsroot/informixdb/informixdb/doc/manual.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** manual.txt 22 Oct 2005 18:35:06 -0000 1.5 --- manual.txt 18 Nov 2005 04:45:57 -0000 1.6 *************** *** 4,9 **** :Authors: Daniel Smertnig ! :Version: informixdb 2.0 ! :Date: 2005-10-22 :Homepage: `InformixDB on Sourceforge`_ --- 4,9 ---- :Authors: Daniel Smertnig ! :Version: informixdb 2.1 ! :Date: 2005-11-17 :Homepage: `InformixDB on Sourceforge`_ *************** *** 16,19 **** --- 16,23 ---- Informix database via Python's Database API 2.0 [#pep249]_. + This document describes versions 2.0 and up of InformixDB. Features that are + not present in version 2.0 are identified by indicating the version in which + they were implemented. + Here's a quick example to get started:: *************** *** 148,151 **** --- 152,164 ---- {'age': 34, 'last': 'duck', 'first': 'donald'} + `New in version 2.1`: Rows can also be returned as objects whose attributes + correspond to column names:: + + >>> objcur = conn.cursor(rowformat = informixdb.ROW_AS_OBJECT) + >>> objcur.execute("SELECT * FROM names") + >>> row = objcur.fetchone() + >>> print row.age + 34 + Describing result sets ,,,,,,,,,,,,,,,,,,,,,, *************** *** 300,303 **** --- 313,337 ---- database independent time or timestamp (i.e. ``DATETIME``) values. + ``INTERVAL`` (`new in version 2.1`) + `informixdb.IntervalYearToMonth` or `informixdb.IntervalDayToFraction` + depending on the interval's precision. Interval instances support certain + arithmetic operations, such as adding to or subtracting from a datetime, + adding to or subtracting from another compatible interval, and scaling by + a factor. + + ``INT8``, ``SERIAL8`` (IDS) (`new in version 2.1`) + `long` + + ``BLOB``, ``CLOB`` (IDS) (`new in version 2.1`) + `informixdb.Sblob`; To insert (or update) a Smart Large Object into a + database column, you need to create an Sblob instance by calling the + Sblob() method of the connection to which the Sblob should belong. + Once an Sblob instance is either created or fetched, it provides a + file-like interface for reading and writing its data. + + extended types, user-defined types (IDS) (`new in version 2.1`) + Complex and opaque types are mapped to their string representation. + Distinct types are mapped like the type from which they are derived. + ``NULL`` SQL ``NULL`` is represented by Python's ``None`` when binding parameters |
From: Carsten H. <ch...@us...> - 2005-11-18 03:51:07
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4769/ext Modified Files: _informixdb.ec Log Message: input binding for complex/opaque types happens via a string representation, so to be consistent use string instead of buffer for output binding. Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** _informixdb.ec 18 Nov 2005 03:40:50 -0000 1.41 --- _informixdb.ec 18 Nov 2005 03:50:59 -0000 1.42 *************** *** 1870,1889 **** #ifdef HAVE_UDT if (ISCOMPLEXTYPE(type)||ISUDTTYPE(type)) { ! PyObject *buffer; ! int lvcharlen = ifx_var_getlen(&data); ! void *lvcharbuf = ifx_var_getdata(&data); ! char *b_mem; ! int b_len; ! ! buffer = PyBuffer_New(lvcharlen); ! ! if (PyObject_AsWriteBuffer(buffer, (void**)&b_mem, &b_len) == -1) { ! Py_DECREF(buffer); ! return NULL; ! } ! ! memcpy(b_mem, lvcharbuf, b_len); ifx_var_dealloc(&data); ! return buffer; } #endif --- 1870,1878 ---- #ifdef HAVE_UDT if (ISCOMPLEXTYPE(type)||ISUDTTYPE(type)) { ! PyObject *result; ! char *lvcharbuf = ifx_var_getdata(&data); ! result = PyString_FromString(lvcharbuf); ifx_var_dealloc(&data); ! return result; } #endif |
From: Carsten H. <ch...@us...> - 2005-11-18 03:40:58
|
Update of /cvsroot/informixdb/informixdb/ext In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2191/ext Modified Files: _informixdb.ec Log Message: Should have checked this sooner, but the conditional compilation for UDT stuff didn't actually work. This works, and I hope it compiles correctly on a CSDK that doesn't know about UDTs. Index: _informixdb.ec =================================================================== RCS file: /cvsroot/informixdb/informixdb/ext/_informixdb.ec,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** _informixdb.ec 17 Nov 2005 23:53:44 -0000 1.40 --- _informixdb.ec 18 Nov 2005 03:40:50 -0000 1.41 *************** *** 61,64 **** --- 61,70 ---- #endif + #ifdef SQLUDTVAR + #define HAVE_UDT + #else + #undef HAVE_UDT + #endif + #if HAVE_C_DATETIME == 1 /* Python and Informix both have a datetime.h, the Informix header is *************** *** 1076,1080 **** val = PyString_AS_STRING((PyStringObject*)sitem); n = strlen(val); ! EXEC SQL ifdef SQLLVARCHAR; if (n >= 32768) { /* use lvarchar* instead */ --- 1082,1086 ---- val = PyString_AS_STRING((PyStringObject*)sitem); n = strlen(val); ! #ifdef HAVE_UDT if (n >= 32768) { /* use lvarchar* instead */ *************** *** 1096,1100 **** } else ! EXEC SQL endif; { var->sqltype = CSTRINGTYPE; --- 1102,1106 ---- } else ! #endif { var->sqltype = CSTRINGTYPE; *************** *** 1342,1346 **** else #endif ! #ifdef CLVCHARPTRTYPE if (ISCOMPLEXTYPE(var->sqltype) || ISUDTTYPE(var->sqltype)) var->sqltype = CLVCHARPTRTYPE; --- 1348,1352 ---- else #endif ! #ifdef HAVE_UDT if (ISCOMPLEXTYPE(var->sqltype) || ISUDTTYPE(var->sqltype)) var->sqltype = CLVCHARPTRTYPE; *************** *** 1381,1385 **** loc->loc_mflags = 0; } ! EXEC SQL ifdef SQLLVARCHAR; else if (var->sqltype == CLVCHARPTRTYPE ) { --- 1387,1391 ---- loc->loc_mflags = 0; } ! #ifdef HAVE_UDT else if (var->sqltype == CLVCHARPTRTYPE ) { *************** *** 1396,1400 **** var->sqllen = sizeof(void *); } ! EXEC SQL endif; else { var->sqldata = bufp; --- 1402,1406 ---- var->sqllen = sizeof(void *); } ! #endif else { var->sqldata = bufp; *************** *** 1862,1866 **** } else #endif ! #ifdef CLVCHARPTRTYPE if (ISCOMPLEXTYPE(type)||ISUDTTYPE(type)) { PyObject *buffer; --- 1868,1872 ---- } else #endif ! #ifdef HAVE_UDT if (ISCOMPLEXTYPE(type)||ISUDTTYPE(type)) { PyObject *buffer; *************** *** 1984,1988 **** } } ! #ifdef SQLUDTVAR if (da->sqlvar[i].sqltype == SQLUDTVAR) { ifx_var_dealloc((void**)&(da->sqlvar[i].sqldata)); --- 1990,1994 ---- } } ! #ifdef HAVE_UDT if (da->sqlvar[i].sqltype == SQLUDTVAR) { ifx_var_dealloc((void**)&(da->sqlvar[i].sqldata)); |