Fixed issue 91 - handling of decimals was incorrect (off by 1). Added lots of SQL Server unit tests. To properly fix this, reworked and simplified parameter binding. Instead of separating the memory requirement and the actual memory preparation, it is now performed in 1 step and stored in the new ParamInfo structures. I added a lot of optional malloc calls (not usually used), so I added a PYODBC_LEAK_CHECK parameter which causes pyodbc_malloc and pyodbc_free to track allocations. This is not thread safe and is intended only for troubleshooting.
Fixes found with UCS4 Python and UCS2 SQLWCHAR (Fedora 13 64-bit). Connection code now uses common SQLWChar class too. Added pyodbc.UNICODE_SIZE and pyodbc.SQLWCHAR_SIZE to help troubleshoot problems. Fixed some printfs 64-bit problems.
Reworked Unicode support, properly differentiating between SQLWCHAR on the different platforms. This should fix a lot of the OS/X problems and perhaps Linux UCS4 build problems. Version format now includes the branch name if not 'master' or v<version>, allowing custom builds to be identified, such as v2unicode-2.1.8-beta03. Also tested with 64-bit Windows builds, so more Py_ssize_t warnings were found and corrected. Created TRACE macro to replace the #ifdefs sprinkled through the code.
Updated calculation of buffer size needed for binding decimals. This shouldn't have any affect other than assertions - generally the old calculation added an extra character or two. The previous varchar/longvarchar fix used varchar max with Unicode instead of wvarchar. Also updated unit tests.
As reported by Andy Hochhaus in the pyodbc group, SQL Server fails if you compare a SQL_LONGVARCHAR parameter with a varchar field. Had been using a hardcoded 255 to determine when to switch from VARCHAR to LONGVARCHAR. Now uses SQLGetTypeInfo to determine the maximum varchar and binary widths. This will also help performance for programs that bind a lot of strings greater than 255 but less than their db's max varchar size.
Crash due to using HSTMT while cleaning up parameters after the connection is closed. Unfortunately I wasn't able to put together an easy test case without using the with statement like the reporter did.
SQL Server 2008 doesn't allow SQLDescribeParam calls once parameters have been bound. This error caused the varchar default to be used instead of raising an error, which works for all columns except binary. SS won't convert char to binary automatically. Fix is to call describe for all NULL parameters before binding. Added test_none_param to SQL Server unit tests.
The close was incorrectly bundled with the rollback, which only happens if autocommit is not turned on (ensuring a rollback if an exception occurs). This probably occurred when adding the begin/end allow threads macros everywhere.
I'm trying to get this to build with only Visual Studio C++ Express, which does not come with rc.exe. The rc file was really to get the versioninfo block into the Windows DLL, but since the extension is .pyd, it really isn't used anyway. (Installers may use it, though?) In the near future, I'll add the version manually using ctypes.
This may break backwards compatibility! During the transition to 2.1.x, I was supposed to change Cursor.execute's return value, but I forgot. Fixed and added unit tests.