[pywin32-checkins] pywin32/win32/src odbc.cpp,1.25,1.26
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2008-10-21 11:08:40
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18690 Modified Files: odbc.cpp Log Message: Fix truncation of seconds with Sql Server Use SQLLEN in place of int for 64-bit compat Index: odbc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/odbc.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** odbc.cpp 20 Oct 2008 03:22:25 -0000 1.25 --- odbc.cpp 21 Oct 2008 11:08:28 -0000 1.26 *************** *** 64,68 **** } ! typedef PyObject * (* CopyFcn)(const void *, int); typedef struct _out --- 64,68 ---- } ! typedef PyObject * (* CopyFcn)(const void *, SQLLEN); typedef struct _out *************** *** 550,554 **** CopyFcn fcn, short vtype, ! long vsize, int pos, bool bUseGet --- 550,554 ---- CopyFcn fcn, short vtype, ! SQLLEN vsize, int pos, bool bUseGet *************** *** 610,629 **** } ! static PyObject *wcharCopy(const void *v, int sz) { return PyWinObject_FromWCHAR((WCHAR *)v, sz/sizeof(WCHAR)); } ! static PyObject *stringCopy(const void *v, int sz) { return PyString_FromStringAndSize((char *)v, sz); } ! static PyObject *longCopy(const void *v, int sz) { return PyInt_FromLong(*(unsigned long *)v); } ! static PyObject *doubleCopy(const void *v, int sz) { double d = *(double *)v; --- 610,629 ---- } ! static PyObject *wcharCopy(const void *v, SQLLEN sz) { return PyWinObject_FromWCHAR((WCHAR *)v, sz/sizeof(WCHAR)); } ! static PyObject *stringCopy(const void *v, SQLLEN sz) { return PyString_FromStringAndSize((char *)v, sz); } ! static PyObject *longCopy(const void *v, SQLLEN sz) { return PyInt_FromLong(*(unsigned long *)v); } ! static PyObject *doubleCopy(const void *v, SQLLEN sz) { double d = *(double *)v; *************** *** 632,636 **** } ! static PyObject *dateCopy(const void *v, int sz) { const TIMESTAMP_STRUCT *dt = (const TIMESTAMP_STRUCT *) v; --- 632,636 ---- } ! static PyObject *dateCopy(const void *v, SQLLEN sz) { const TIMESTAMP_STRUCT *dt = (const TIMESTAMP_STRUCT *) v; *************** *** 642,646 **** } ! static PyObject *rawCopy(const void *v, int sz) { PyObject *ret = PyBuffer_New(sz); --- 642,646 ---- } ! static PyObject *rawCopy(const void *v, SQLLEN sz) { PyObject *ret = PyBuffer_New(sz); *************** *** 850,854 **** static int ibindDate(cursorObject*cur, int column, PyObject *item) { ! int len = sizeof(TIMESTAMP_STRUCT); InputBinding *ib = initInputBinding(cur, len); if (!ib) --- 850,866 ---- static int ibindDate(cursorObject*cur, int column, PyObject *item) { ! /* Sql server apparently determines the precision and type of date based ! on length of input, according to the character size required for column ! storage. This is completely bogus when passing a TIMESTAMP_STRUCT, whose ! length is always 16. This apparently causes Sql Server to treat it as a ! SMALLDATETIME, and truncates seconds as well as fraction of second, and ! also limits the range of acceptable dates. ! Tell it we have enough room for 3 decimals, since this is all that ! SYSTEMTIME affords, and all that Sql Server 2005 will accept. ! Sql Server 2008 has a datetime2 with up to 7 decimals. ! Might need to use SqlDescribeCol to get length and precision to support this. ! */ ! SQLLEN len = 23; // length of character storage for yyyy-mm-dd hh:mm:ss.ddd ! assert(len >= sizeof(TIMESTAMP_STRUCT)); InputBinding *ib = initInputBinding(cur, len); if (!ib) *************** *** 911,915 **** SQL_TIMESTAMP, len, ! 9, // Decimal digits of precision, appears to be ignored for datetime ib->bind_area, len, --- 923,927 ---- SQL_TIMESTAMP, len, ! 3, // Decimal digits of precision, appears to be ignored for datetime ib->bind_area, len, |