Bug #48310 MyODBC driver can't perform bulk operations on queries that use parameters
Submitted: 26 Oct 2009 13:56 Modified: 24 Mar 2010 16:30
Reporter: Tonci Grgin Email Updates:
Status: Closed Impact on me:
Category:Connector / ODBC Severity:S4 (Feature request)
Version:5.1.5 OS:Any
Assigned to: Lawrenty Novitsky CPU Architecture:Any

[26 Oct 2009 13:56] Tonci Grgin

How to repeat:
[13 Nov 2009 10:38] Bogdan Degtyariov
Driver returns MYERR_01S02, "Param arrays not supported"
[25 Nov 2009 4:50] Bogdan Degtyariov
SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMSET_SIZE, (void *)paramset_size, 0); returns "not supported" error. Feature request is sent to developers.
[2 Dec 2009 17:03] Lawrenty Novitsky
This is duplicate of the Bug#32978
[18 Dec 2009 0:28] Lawrenty Novitsky
paramsets array support diff

Attachment: patch48310.diff (text/x-diff), 29.44 KiB.

[18 Dec 2009 0:34] Lawrenty Novitsky
Since patch is relatively big, I'll probably create tomorrow a separate branch for it on the lp.

did many last minute changes for "code beauty". So, i hop nothing is broken. at least all tests pass.

I probably commented excessively. That was more for myself, but i hope they will help you to review.
[18 Dec 2009 10:09] Lawrenty Novitsky
Created branch on launchpad lp:~myodbc-developers/myodbc/paramarrays

btw, in the patch I changed do_query to use mysql_real_query instead of mysql_query.
Wanted first to make it in a separate patch, but then changed that in this one. but the patch should be fine without that. so i can remove that on demand. it was just convenient to add since i needed to get query length from insert_params anyway.
[22 Dec 2009 10:04] Bogdan Degtyariov
Test case that fails with the patched driver

Attachment: bug48699.c (text/plain), 2.24 KiB.

[22 Dec 2009 10:21] Bogdan Degtyariov
Small suggestion on how to fix this problem:

=== modified file 'driver/execute.c'
--- driver/execute.c	2009-12-18 09:46:17 +0000
+++ driver/execute.c	2009-12-22 10:18:45 +0000
@@ -270,7 +270,7 @@
       octet_length_ptr= ptr_offset_adjust(aprec->octet_length_ptr,
-                                          apd->bind_type,
+                                          apd->array_size > 1 ? SQL_BIND_BY_COLUMN : apd->bind_type,
                                           sizeof(SQLLEN), row);
       length= *octet_length_ptr;
[22 Dec 2009 15:16] Lawrenty Novitsky
Bogdan, I don't think your testcase is valid. You are using there some hybrid row/column binding - you set attribute to row binding and bind parameters values this way, but length pointers are bound by column. And they should be part of data structure, size of which one passes as SQL_ATTR_PARAM_BIND_TYPE.
Look at my row-binding testcase or better look here http://msdn.microsoft.com/en-us/library/ms709287%28VS.85%29.aspx - there is explanation it should be this way besides the code example.
[2 Feb 2010 6:25] Bogdan Degtyariov

I spotted one little problem with gcc compiler in Linux.

execute.c: In function `insert_params':
execute.c:204: error: invalid operands to binary -

this line 

*finalquery_length= to - net->buff - 1;

has to be replaced with the following (the char* type cast must be added):

*finalquery_length= to - (char*)net->buff - 1;

[8 Mar 2010 12:25] Lawrenty Novitsky
Patch has been merged and pushed to the main tree. rev#864. Goes to 5.1.7
[11 Mar 2010 14:36] Lawrenty Novitsky
I re-merged this bug patch in different way so log doesn't look ugly - and now it rev#868.
[24 Mar 2010 16:30] Tony Bedford
An entry has been added to the 5.1.7 changelog:

Bulk upload operations did not work for queries that used parameters.