Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODBC Bulk Insert of Blobs using SQLPrepare/SQLBindParameter/SQLExecute #8

Open
ClaudioMuselli90 opened this issue Apr 30, 2021 · 1 comment

Comments

@ClaudioMuselli90
Copy link

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.

@ClaudioMuselli90
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant