From: Engineering <eng...@as...> - 2009-04-09 18:18:09
|
I did some further tests .. the attached patch seems to fix the selection but not the prepared statement section (driver crashes with a corrupted heap on statement release). It seems to me that the code assumes that sizeof(long) == 8, which in windows it is not true. On SQLDa.cpp, we have: .... offset = ROUNDUP (offset, sizeof (int)); indicatorsOffset = offset; offset += sizeof(long) * numberColumns; buffer = new char [offset]; lengthBufferRows = offset; .... And the part that states sizeof(long) should probably be updated to sizeof(SQLLEN). However I see the usage of long in many places where indicators are used, so I am a bit weary of making a trial & error fix. In any case, I will try to make a new patch that would work on selection as well, although I am not that sure how clean it would be. Andrei -----Original Message----- From: Engineering [mailto:eng...@as...] Sent: Thursday, April 09, 2009 11:24 AM To: fir...@li... Subject: [Firebird-odbc-devel] Firebird ODBC: x64 data length compatibility Hello, I was not sure where to report bugs/fixes, so I hope this is the right location. This is the issue that we encountered: On a x64 Windows 2003 machine, using the ODBC driver we attempted to do a selection from a table containing a DateTime column. MFC CRecordSet uses the data lenth to determine if a field is NULL or not for a date-time, and whenever we had the column as NULL, Firebird ODBC seemed to return the 32-bit value 0xFFFFFFFF (which as a 64-bit value is just a very large number), making our selection invalid (MFC actually complains, because the date/time interpreting is not correct). From what we could tell, the sequence of events is as follows: - MFC Recordset calls ::SQLBindCol with the length parameter as a "LONG_PTR *" (which is a __int64 **) - MFC will call ::SQLExtendedFetch, which fills up the length value, however as a 32-bit number (i.e. will be always positive) I have attached a proposed patch - basically replacing SQLINTEGER with SQLLEN for any index pointers (not sure if this is this the correct term - this is the first time I am messing with this driver). For 32bit this seems to make no difference as the typedefs are the same, however for 64-bit this will change a 32bit value to 64-bit (and would probably need testing). I did test the patch in our environment for date-time columns, however I would appreciate someone more knowledgeable about how the ODBC driver works to take a look. If this can make it into RC2 and/or official release, it would be great. Regards, Andrei Litvin |