-
Notifications
You must be signed in to change notification settings - Fork 267
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
Broken bulkBind in mysqli driver #806
Comments
@dregad Thank you for your answer. I did not spot that commit in git. Here is a small script that works with 5.21 but does not with 5.22:
|
This has created 2 problems:
|
So there is a problem in determining the data types in the bulkbind if we want to take advantage of the true binding, We look at the data types of each element of the array to determine the bind types: $ar = array('A','B','C',1,2,3); So the bind types would be But if the second line of the bulk bind was like this (because column 4 is actually a string not an integer): $ar = array('A','B','C','D',2,3); but we used the derived version from the first row, then the insert would fail, because the types should be: We have 2 choices I think:
|
True binding feature breaks bulkbinding in mysqli
This restores the bulkbind feature to the mysqli driver and adds a performance feature where the typestring can be pre-defined
I have pushed a fix that attempts to resolve this issue. Please test if possible. In addition, it adds a performance feature that allows you to pre-define the column type string, instead of forcing the driver to iterate over all column of all rows of the bulk insert. So instead of: $db->bulkBind = true; Which is still mandatory with bulk binding, use a string that represents the mysqli bind param type $db->bulkBind = 'ssssii'; The value binding operation will use this format instead of iterating over all rows of the bulkbind, attempting to determine the data type. This will save a little cpu time. If used this way, the bulkBind flag will be immediately reset after the query execution. |
I'm wondering if this is really necessary, depending on the size of the input array this could mean a lot of iterations... IMO it would make sense and be a reasonable requirement to report on the caller, the burden of ensuring that the bind data consistently has the right type for each item across the array's rows. In this case we could derive the bind types from row[0] and just let the bulk operation fail if there is an incorrect type in another row. |
Per my original example. our function guesses the type list from what it sees as data in the first row, so I would say a guess of an integer value that could be a string in the second row would be immediately suspect |
I was experiencing a problem with my prepared statements and bulk bind as well -- 2f4dc1c seems to have resolved this, but now calling |
This is a problem with the mysqli driver. Unlike say, oracle where a bulk insert of 60 records is a single transaction of 60 records, the mysql driver executes a single row 60 times, the affected rows is not cumulative. this article on stackoverflow explains it, |
The fix for issue #806 introduced a regression causing all bound SQL statements to fail in the mysqli driver, when using alphanumeric placeholders. To fix the problem, we ensure that bind array passed to mysqli bind function is numeric. Fixes #838 Signed-off-by: Damien Regad <dregad@mantisbt.org> Changes to original commit: fixed coding guidelines, improved message.
Hi,
with this commit 507466e an Execute method has been added to drivers/adodb-mysqli.inc.php. This broke bulkBind for Execute using the mysqli driver.
I tried to figure out why it has been added but could not find any answers...
The text was updated successfully, but these errors were encountered: