Bug #94545 SQL_NO_DATA when fetching VARCHAR(500) with filter
Submitted: 4 Mar 2019 13:38 Modified: 13 May 2019 9:15
Reporter: David Wieland Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.3.11 OS:Debian (Stretch)
Assigned to: CPU Architecture:x86 (64 bit)

[4 Mar 2019 13:38] David Wieland
Description:
SQLFetch(...) will return SQL_NO_DATA if you try to fetch a large column using a filter. The column size limit seems to be 1 KiB as VARCHAR(341) succeeds and VARCHAR(342) fails.

How to repeat:
Precondition:

create table my_table
(
	my_index int,
	my_column varchar(2048),
	constraint my_table_pk
		unique (my_index)
);

INSERT INTO my_table (my_index, my_column) VALUES (1, 'abc');
INSERT INTO my_table (my_index, my_column) VALUES (2, 'def');

Compile attached file with: gcc main.c -lodbc
[4 Mar 2019 13:38] David Wieland
Example code

Attachment: main.c (text/x-csrc), 1.06 KiB.

[15 Mar 2019 8:41] MySQL Verification Team
Thank you for the bug report. On your test case which is the error number to be expected?.
[15 Mar 2019 8:44] David Wieland
Expected result: SQL_SUCCESS
[15 Mar 2019 9:49] MySQL Verification Team
Thank you for the feedback. I compiled your test case changing just the Password for root and both Windows and Linux I got -2, wonder what I am doing wrong.
[15 Mar 2019 10:47] David Wieland
I think you need to select an existing database in the DSN. It's called "bugfix" in my example.
[15 Mar 2019 10:49] David Wieland
Fixed precondition:

create database bugfix;

create table bugfix.my_table
(
	my_index int,
	my_column varchar(2048),
	constraint my_table_pk
		unique (my_index)
);
[18 Mar 2019 12:29] Bogdan Degtyariov
Hi David

Thank you for your report.
The problem is confirmed in ODBC driver 5.3.11.
It has been also spotted in 8.0, but recently fixed in bug 93895.
We will back-port the fix from 8.0 into 5.3 branch.

Also, there is a work-around for this issue. Not using parameters or specifying NO_SSPS=1 in the connection string will allow the driver to fetch the data. Because the workaround exists I am setting the severity to S2.
[21 Mar 2019 6:15] Bogdan Degtyariov
The bug fix is pushed into ODBC Driver 5.3.13
[28 Mar 2019 22:11] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/ODBC 5.3.13 release, and here's the changelog entry that was combined with MySQL bug #93895 

An exception was emitted when fetching contents of a BLOB field after
executing a statement as a server-side prepared statement with a bound
parameter. 

The workaround is not using parameters or
specifying NO_SSPS=1 in the connection string; this allows the driver to
fetch the data.

Thank you for the bug report.
[29 Mar 2019 8:42] David Wieland
Thank you for your work!
[13 May 2019 9:15] David Wieland
A retest of mysql-connector-odbc-5.3.13-linux-debian9-x86-64bit.tar.gz from https://dev.mysql.com/downloads/ shows the same problems.