At least with the Amazon Redshift ODBC driver, it seems that SQLFreeHandle, SQLCloseCursor, or SQLCancel must not be called concurrently with executing a query on another statement handle.
This pull requests delays the actual de-allocation from Haskells GC to the next call of sqlAllocStmt or freeDbcIfNotAlready, thereby moving the call to the de-allocation functions into the same thread as the 'usual' program execution.
The first commit introduces an abstraction to ensure that column buffers have size reported to the driver. This commit is not strictly necessary, but during debugging I noticed column bind buffers for SQLBIGINT were sized to CInt instead of #{type SQLBIGINT}.
At least with the Amazon Redshift ODBC driver, it seems that
SQLFreeHandle
,SQLCloseCursor
, orSQLCancel
must not be called concurrently with executing a query on another statement handle.This pull requests delays the actual de-allocation from Haskells GC to the next call of
sqlAllocStmt
orfreeDbcIfNotAlready
, thereby moving the call to the de-allocation functions into the same thread as the 'usual' program execution.The first commit introduces an abstraction to ensure that column buffers have size reported to the driver. This commit is not strictly necessary, but during debugging I noticed column bind buffers for
SQLBIGINT
were sized toCInt
instead of#{type SQLBIGINT}
.