Bug #21659 Multiple Row Insert Fails
Submitted: 15 Aug 2006 19:24 Modified: 17 Aug 2006 17:19
Reporter: Sami Aref Email Updates:
Status: Unsupported Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:3.51.12 OS:Windows (Windows 2000)
Assigned to: CPU Architecture:Any

[15 Aug 2006 19:24] Sami Aref
Description:
While attempting Bulk Inserts with MYODBC 3.51.10 on MYSQL 5.0.22 The program is left hanging

The code should normally return 1 2 3 4 5, but instead it gets stuck in an infinite loop:

The portion of the code that causes this is shown below:

====================================================

cout << "\n<Insertion of Multiple Rows Test>" << endl;

// Allocate memory for the statement handle

rc = SQLAllocStmt (hDbc, &hStmt);
rc = SQLExecDirect(hStmt, (wchar_t*)L"DROP TABLE BULKTEST", SQL_NTS);
rc = SQLExecDirect(hStmt, (wchar_t*)L"CREATE TABLE BULKTEST(COLA INT)", SQL_NTS);

int lpColumn[5] = {1,2,3,4,5};
long lLength = 0;
unsigned long lCurrentrow = 0;

rc = SQLBindParameter(hStmt, 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 4, 0, &lpColumn, 0, &lLength);

rc = SQLParamOptions(hStmt, 5, &lCurrentrow);

// Build a parameterized SQL query
rc = SQLPrepare(hStmt, (wchar_t*)L"INSERT INTO BULKTEST VALUES(?)", SQL_NTS);
rc = SQLExecute(hStmt);

==================================================================
Tracefile for above code
=================================================================

odbctest        bcc-97c	ENTER SQLAllocStmt 
		HDBC                00AC2970
		HSTMT *             004CC088

odbctest        bcc-97c	EXIT  SQLAllocStmt  with return code 0 (SQL_SUCCESS)
		HDBC                00AC2970
		HSTMT *             0x004CC088 ( 0x00ac2e48)

odbctest        bcc-97c	ENTER SQLExecDirectW 
		HSTMT               00AC2E48
		WCHAR *             0x004A4630 [      -3] "DROP TABLE BULKTEST\ 0"
		SDWORD                    -3

odbctest        bcc-97c	EXIT  SQLExecDirectW  with return code 0 (SQL_SUCCESS)
		HSTMT               00AC2E48
		WCHAR *             0x004A4630 [      -3] "DROP TABLE BULKTEST\ 0"
		SDWORD                    -3

odbctest        bcc-97c	ENTER SQLExecDirectW 
		HSTMT               00AC2E48
		WCHAR *             0x004A45BC [      -3] "CREATE TABLE BULKTEST(COLA INT)\ 0"
		SDWORD                    -3

odbctest        bcc-97c	EXIT  SQLExecDirectW  with return code 0 (SQL_SUCCESS)
		HSTMT               00AC2E48
		WCHAR *             0x004A45BC [      -3] "CREATE TABLE BULKTEST(COLA INT)\ 0"
		SDWORD                    -3

odbctest        bcc-97c	ENTER SQLFreeStmt 
		HSTMT               00AC2E48
		UWORD                        1 <SQL_DROP>

odbctest        bcc-97c	EXIT  SQLFreeStmt  with return code 0 (SQL_SUCCESS)
		HSTMT               00AC2E48
		UWORD                        1 <SQL_DROP>

odbctest        bcc-97c	ENTER SQLSetConnectOptionW 
		HDBC                00AC2970
		SQLINTEGER                 102 <SQL_AUTOCOMMIT>
		SQLPOINTER          0x00000000

odbctest        bcc-97c	EXIT  SQLSetConnectOptionW  with return code 0 (SQL_SUCCESS)
		HDBC                00AC2970
		SQLINTEGER                 102 <SQL_AUTOCOMMIT>
		SQLPOINTER          0x00000000

odbctest        bcc-97c	ENTER SQLAllocStmt 
		HDBC                00AC2970
		HSTMT *             004CC088

odbctest        bcc-97c	EXIT  SQLAllocStmt  with return code 0 (SQL_SUCCESS)
		HDBC                00AC2970
		HSTMT *             0x004CC088 ( 0x00ac2e48)

odbctest        bcc-97c	ENTER SQLPrepareW 
		HSTMT               00AC2E48
		WCHAR *             0x004A4538 [      -3] "INSERT INTO BULKTEST VALUES(?)\ 0"
		SDWORD                    -3

odbctest        bcc-97c	EXIT  SQLPrepareW  with return code 0 (SQL_SUCCESS)
		HSTMT               00AC2E48
		WCHAR *             0x004A4538 [      -3] "INSERT INTO BULKTEST VALUES(?)\ 0"
		SDWORD                    -3

odbctest        bcc-97c	ENTER SQLDescribeParam 
		HSTMT               00AC2E48
		UWORD                        1 
		SWORD *             0x0012FDE4
		SQLULEN *           0x0012FDE0
		SWORD *             0x0012FDDC
		SWORD *             0x0012FDD8

odbctest        bcc-97c	EXIT  SQLDescribeParam  with return code 0 (SQL_SUCCESS)
		HSTMT               00AC2E48
		UWORD                        1 
		SWORD *             0x0012FDE4 (12)
		SQLULEN *           0x0012FDE0 (255)
		SWORD *             0x0012FDDC (-13108)
		SWORD *             0x0012FDD8 (2)

odbctest        bcc-97c	ENTER SQLParamOptions 
		HSTMT               00AC2E48
		SQLULEN                    5
		SQLULEN *           0x004CC20C

odbctest        bcc-97c	EXIT  SQLParamOptions  with return code 1 (SQL_SUCCESS_WITH_INFO)
		HSTMT               00AC2E48
		SQLULEN                    5
		SQLULEN *           0x004CC20C (0)

		DIAG [01S02] [MySQL][ODBC 3.51 Driver][mysqld-5.0.22-community-nt]Option value changed to default parameter size (502) 

odbctest        bcc-97c	ENTER SQLBindParameter 
		HSTMT               00AC2E48
		UWORD                        1 
		SWORD                        1 <SQL_PARAM_INPUT>
		SWORD                        4 <SQL_C_LONG>
		SWORD                        4 <SQL_INTEGER>
		SQLULEN                    4
		SWORD                        0 
		PTR                0x0012FDA8
		SQLLEN                     0
		SQLLEN *            0x0012FDA4

odbctest        bcc-97c	EXIT  SQLBindParameter  with return code 0 (SQL_SUCCESS)
		HSTMT               00AC2E48
		UWORD                        1 
		SWORD                        1 <SQL_PARAM_INPUT>
		SWORD                        4 <SQL_C_LONG>
		SWORD                        4 <SQL_INTEGER>
		SQLULEN                    4
		SWORD                        0 
		PTR                0x0012FDA8
		SQLLEN                     0
		SQLLEN *            0x0012FDA4 (0)

odbctest        bcc-97c	ENTER SQLExecute 
		HSTMT               00AC2E48

odbctest        bcc-97c	EXIT  SQLExecute  with return code 0 (SQL_SUCCESS)
		HSTMT               00AC2E48

==================================================================
===============================================================
Repeats infinitley:

odbctest        bcc-97c	ENTER SQLParamOptions 
		HSTMT               00AC2E48
		SQLULEN                    5
		SQLULEN *           0x004CC20C

odbctest        bcc-97c	EXIT  SQLParamOptions  with return code 1 (SQL_SUCCESS_WITH_INFO)
		HSTMT               00AC2E48
		SQLULEN                    5
		SQLULEN *           0x004CC20C (0)

		DIAG [01S02] [MySQL][ODBC 3.51 Driver][mysqld-5.0.22-community-nt]Option value changed to default parameter size (502) 

odbctest        bcc-97c	ENTER SQLBindParameter 
		HSTMT               00AC2E48
		UWORD                        1 
		SWORD                        1 <SQL_PARAM_INPUT>
		SWORD                        4 <SQL_C_LONG>
		SWORD                        4 <SQL_INTEGER>
		SQLULEN                    4
		SWORD                        0 
		PTR                0x0012FDA8
		SQLLEN                     0
		SQLLEN *            0x0012FDA4

odbctest        bcc-97c	EXIT  SQLBindParameter  with return code 0 (SQL_SUCCESS)
		HSTMT               00AC2E48
		UWORD                        1 
		SWORD                        1 <SQL_PARAM_INPUT>
		SWORD                        4 <SQL_C_LONG>
		SWORD                        4 <SQL_INTEGER>
		SQLULEN                    4
		SWORD                        0 
		PTR                0x0012FDA8
		SQLLEN                     0
		SQLLEN *            0x0012FDA4 (0)

odbctest        bcc-97c	ENTER SQLExecute 
		HSTMT               00AC2E48

odbctest        bcc-97c	EXIT  SQLExecute  with return code 0 (SQL_SUCCESS)
		HSTMT               00AC2E48
================================================================================
================================================================================

How to repeat:
In the input.txt file:

modify the portion:
[Data Source Name]
DSN=xxx;UID=xxx;PWD=xxx

to whatever the DSN, username and password  that connect to MYSQL 5.0.22 through MYODBC 3.51.10

(do not modify anything else)

Run odbctest.exe:

select input.txt as the input file
select output.txt (or any name) as the output file

output.txt should hang on:
<Insertion of Multiple Rows Test>
Drop table BULKTEST successfully
Create table BULKTEST(COLA INT) successfully
INSERT INTO BULKTEST VALUES(?)
[15 Aug 2006 19:27] Sami Aref
odbctest executable and input file

Attachment: odbctest.zip (application/x-zip-compressed, text), 157.08 KiB.

[16 Aug 2006 0:24] MySQL Verification Team
Thank you for the bug report. I was able to repeat using your compiled
binary test case, however could you please provide the complete code
of your odbctest.exe for further analyze. Thanks in advance.

C:\tmp>odbctest.exe

        Copyright (C) MicroStrategy Incorporated, 2006
        version: 1.1

Enter the input file (incl. full path):

input.txt

Enter the output file (incl. full path):

out.txt

1. DSN=mytest;UID=root;PWD=;
<Driver Connection Test>
SQLAllocEnv ... ok
SQLAllocConnect ... ok
SQL_QUIET_MODE ... supported
SQL_LOGIN_TIMEOUT ... supported
SQLDriverConnect ... ok

SQL_DBMS_NAME = MySQL
SQL_DBMS_VERSION = 5.0.24-community-nt
SQL_DRIVER_VERSION = 03.51.12
<Driver Connection Test> completed

<Async Mode Test>
Asynchronous connection ... ok
<Async Connection Test> completed

<Bulk Insert Test>
CREATE TABLE BULKTEST1 (COLA INT, COLB INT) Successfully
INSERT INTO BULKTEST1 VALUES (123, 456) Successfully
CREATE TABLE BULKTEST2 (COLA INT, COLB INT) Successfully
SELECT * FROM BULKTEST1
123     456
INSERT INTO BULKTEST2 VALUES (?,?)
SELECT * FROM BULKTEST2
123     456
Bulk Insert ... ok

<Insertion of Multiple Rows Test>
Message: [MySQL][ODBC 3.51 Driver][mysqld-5.0.24-community-nt]Unknown table 'bulktest'
Create table BULKTEST(COLA INT) successfully
INSERT INTO BULKTEST VALUES(?)
^C
C:\tmp>
[16 Aug 2006 9:31] Tonci Grgin
Hi Sami, can you pleaes do as Miguel requested and provide the complete code
of your odbctest.exe? Also, can you try to upgrade to 3.51.12 and see if problem persists?
[16 Aug 2006 17:20] Sami Aref
Corrected version from 3.51.10 to 3.51.12
[16 Aug 2006 17:29] Sami Aref
Sorry, the MYODBC version was indeed 3.51.12

Code is uploaded, please let me know if you have any questions.
Thanks alot
[17 Aug 2006 6:00] Tonci Grgin
Sami, thanks.
[17 Aug 2006 7:55] Tonci Grgin
We're sorry, but the bug system is not the appropriate forum for asking help on using MySQL products. Your problem is not the result of a bug.

Support on using our products is available both free in our forums at http://forums.mysql.com/ and for a reasonable fee direct from our skilled support engineers at http://www.mysql.com/support/

Thank you for your interest in MySQL.

Explanation:
Sami, I don't see how this can be a bug! Please see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcbinding_arra... and compare with your code.
[17 Aug 2006 16:38] Tonci Grgin
After writing correct test case (which also fails) and consultation with connector team this seems not to be supported.
[17 Aug 2006 17:19] Sami Aref
thanks for the help, 

Any info if this issue will be resolved in the next MyODBC release?
[17 Aug 2006 17:54] Tonci Grgin
Sami, as far as I understand, this is not only connector but server issue too... I'm sorry but there's no definite answer to your question.