ODBC Bulk Insert of Blobs using SQLPrepare/SQLBindParameter/SQLExecute
ClaudioMuselli90 opened this issue · 1 comments
I want to signal a possible bug in the odbc driver for SQLite 3 in the bulk insert of data in a SQLITE_BLOB column.
I am using this driver under Windows and Linux and I have the same results.
By inserting 100 lines of binaries values using the query
INSERT INTO "table" ("column_data") VALUES (?)
and using SQLBindParameter to pass the binary buffer and the vector of different length, I am resulting with an insert of my blobs all truncated to the length of the first entry. I have used SQLSetStmtAttr to set SQL_ATTR_PARAMSET_SIZE to 100 to insert 100 lines together for performance reason.
The column is defined as BLOB type on the db and the last len entry of SQLBindParameter is a vector containing all the correct 100 sizes. Unfortunately it seems that this last vector is ignored by the routine. Same code works well with null terminated string if SQL_NTS value is used instead of the precise number of bytes.
Moreover I used another version of ODBC driver for SQLite (not open-source unfortunately) and with the same code the insert proceed correctly.
Just to complete my comment... I have digged into the code and I suppose the issue is due to the line 5111 of file sqlite3odbc.c... The variable need of the binary param is putted as -1 (meaning no more information are requested to setup this params) at the first iteration of the loop on paramset_size. However for a binary it is not true the variable len can not change between one iteration and the other. I suppose the variable need should remain 0 in case of paramset_seize > 1 or the check on p-> need at line 5092 should be moved after len set.