[ODBC-162] SQLNumResultCols returns zero for query with long data and CTE Created: 2018-07-16  Updated: 2018-07-17  Resolved: 2018-07-17

Status: Closed
Project: MariaDB Connector/ODBC
Component/s: General
Affects Version/s: 3.0.5
Fix Version/s: 2.0.17, 3.0.6

Type: Bug Priority: Critical
Reporter: Nazar Mishturak Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None

Attachments: File common.logN_AID    

 Description   

Driver somehow returns 0 colmns for this query. Same query works correctly with MySQL 8.0/MySQL ODBC Connector 8.0

with x as (
    select 1 as `val`
    union all
    select 2 as `val`
    union all
    select 3 as `val`
)
select repeat(cast(x.val as nchar), x.val * 12000) as `string`
     , repeat(cast(x.val as char), x.val * 12000) as `c_string`
     , cast(repeat(char(x.val), x.val * 12000) as binary) as `binary`
     , x.val as `index`
from x;

Relevant part of the trace log:

[ODBC][459][1531695923.138711][SQLExecDirectW.c][177]
		Entry:
			Statement = 0x7f4e0a6d9700
			SQL = [
                    with x as (
                        select 1 as `val`
                        union all
                   ...][length = 594]
[ODBC][459][1531695923.140973][SQLExecDirectW.c][445]
		Exit:[SQL_SUCCESS]
[ODBC][459][1531695923.140991][SQLNumResultCols.c][156]
		Entry:
			Statement = 0x7f4e0a6d9700
			Column Count = 0x7f4e0a5fa5d4
[ODBC][459][1531695923.140999][SQLNumResultCols.c][251]
		Exit:[SQL_SUCCESS]
			Count = 0x7f4e0a5fa5d4 -> 0



 Comments   
Comment by Lawrin Novitsky [ 2018-07-17 ]

Thank you for your bug report.
The fix and the testcase have been pushed to odbc-3.0 and master as f0cd063
and are yet to be merged into odbc-2.0
The problem was that connector misinterpreted type of the WITH statement

Generated at Thu Feb 08 03:26:40 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.