[pywin32-checkins] pywin32/win32/src odbc.cpp,1.20.2.3,1.20.2.4
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2008-09-15 07:46:28
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1747 Modified Files: Tag: py3k odbc.cpp Log Message: Bind long with SQL_C_LONG if it fits in 32 bits Index: odbc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/odbc.cpp,v retrieving revision 1.20.2.3 retrieving revision 1.20.2.4 diff -C2 -d -r1.20.2.3 -r1.20.2.4 *** odbc.cpp 14 Sep 2008 15:53:44 -0000 1.20.2.3 --- odbc.cpp 15 Sep 2008 07:46:37 -0000 1.20.2.4 *************** *** 688,696 **** - static void OutOfMemory() - { - PyErr_SetString(odbcError, "out of memory"); - } - static SQLLEN NTS = SQL_NTS; --- 688,691 ---- *************** *** 707,711 **** else { ! OutOfMemory(); } return ib; --- 702,706 ---- else { ! PyErr_NoMemory(); } return ib; *************** *** 743,764 **** } ! static int ibindLong(cursorObject*cur,int column, PyObject *item) { ! int len = sizeof(long long); ! long long val = PyLong_AsLongLong(item); ! if (val == -1 && PyErr_Occurred()) ! return 0; ! InputBinding *ib = initInputBinding(cur, len); ! if (!ib) ! return 0; ! ! memcpy(ib->bind_area, &val, len); if (unsuccessful(SQLBindParameter( cur->hstmt, column, ! SQL_PARAM_INPUT, ! SQL_C_SBIGINT, ! SQL_BIGINT, len, 0, --- 738,777 ---- } ! static int ibindLong(cursorObject*cur,int column, PyObject *item) { ! /* This will always be called in Py3k, so differentiate between an int ! that fits in a long, and one that requires a 64=bit datatype. */ ! int len; ! InputBinding *ib; ! SQLSMALLINT ParamType=SQL_PARAM_INPUT, CType, SqlType; ! long longval = PyLong_AsLong(item); ! if (longval != -1 || !PyErr_Occurred()){ ! CType = SQL_C_LONG; ! SqlType = SQL_INTEGER; ! len = sizeof(long); ! ib = initInputBinding(cur, len); ! if (!ib) ! return 0; ! memcpy(ib->bind_area, &longval, len); ! } ! else{ ! long long longlongval = PyLong_AsLongLong(item); ! if (longlongval == -1 && PyErr_Occurred()) ! return 0; ! CType = SQL_C_SBIGINT; ! SqlType = SQL_BIGINT; ! len = sizeof(long long); ! ib = initInputBinding(cur, len); ! if (!ib) ! return 0; ! memcpy(ib->bind_area, &longlongval, len); ! } if (unsuccessful(SQLBindParameter( cur->hstmt, column, ! ParamType, ! CType, ! SqlType, len, 0, *************** *** 1374,1379 **** cur->description = NULL; PyWinObject_FreeTCHAR(sql); ! OutOfMemory(); ! return NULL; } --- 1387,1391 ---- cur->description = NULL; PyWinObject_FreeTCHAR(sql); ! return PyErr_NoMemory(); } |