Bug #67920 Non-compliant behavior of SQLMoreResults
Submitted: 17 Dec 2012 6:12 Modified: 6 Aug 2013 22:01
Reporter: Serge Kraikov Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:5.2.2 OS:Windows
Assigned to: Bogdan Degtyariov CPU Architecture:Any
Tags: ODBC, SchemaOnly

[17 Dec 2012 6:12] Serge Kraikov
Description:
I trying to get a list of columns using command.ExecuteReader(CommandBehavior.SchemaOnly), and get unintelligible exception on closing this reader.

How to repeat:

IDbConnection _connection = new OdbcConnection(@"Driver={MySQL ODBC 5.2w Driver};Server=server;Database=sakila;User=root;Password=password;Option=3;");
_connection.Open();

IDbCommand command = _connection.CreateCommand();
command.CommandText = "select * from film";

IDataReader reader = command.ExecuteReader(CommandBehavior.SchemaOnly);
// closing the reader throws Exception "ERROR [HY010] [MySQL][ODBC 5.2(w) Driver][mysqld-5.5.28]"
if (reader != null && !reader.IsClosed) reader.Close();
[11 Jan 2013 8:09] Bogdan Degtyariov
Verified with 5.2.3
[11 Jan 2013 8:18] Bogdan Degtyariov
C# test case

Attachment: Form1.cs (text/plain), 1.31 KiB.

[14 Jan 2013 5:40] Bogdan Degtyariov
The problem occurs because of non-compliant behavior of the function SQLMoreResults() implemented in MySQL Connector/ODBC.

As said in MSDN here

http://msdn.microsoft.com/en-us/library/ms714673%28v=vs.85%29.aspx

For some drivers, output parameters and return values are not available until
all result sets and row counts have been processed. For such drivers, output
parameters and return values become available when SQLMoreResults returns
SQL_NO_DATA.

However, as mentioned the returned result is wrong (SQL_ERROR).
[14 Jan 2013 5:56] Bogdan Degtyariov
Changed the bug synopsis in order to reflect the actual problem
[14 Jan 2013 7:55] Bogdan Degtyariov
Patch and test case

Attachment: bug67920.diff (application/octet-stream, text), 1.76 KiB.

[22 Apr 2013 13:01] Bogdan Degtyariov
The patch will be released in Connector/ODBC 5.2.6.
Connector/ODBC 5.1 does not have this problem.
[6 Aug 2013 22:01] Daniel So
Added the following changelog entry to Connector/ODBC 5.2.6:

When called after SQLPrepare, the funciton SQLMoreResults returned SQL_ERROR, instead of SQL_NO_DATA as required by the ODBC specification.