[ODBC-146] Wrong decimal value (0) when after longtext field in select clausule (using ADO, client side cursor) Created: 2018-05-22  Updated: 2018-05-30  Resolved: 2018-05-30

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

Type: Bug Priority: Major
Reporter: Marek Šrom Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows server 2012 R2


Attachments: Text File SQL.LOG     File mdb.vbs    

 Description   

ODBC connector 3.0.3 returns always value 0 for decimal fields when accessed via ADODB with clientside cursor when decimal field is after longtext field in select clausule .e.g:

vb6 code
set conn = new ADODB.Connection
set rs = new ADODB.Recordset
rs.CursorLocation = adUseClient
conn.Open "DRIVER=

{MariaDB ODBC 3.0 Driver}

;SERVER=...;DATABASE=...;UID=...;PWD=...; OPTION=3;"
conn.execute "create table aaa(nm_price decimal(20,4), m_comment longtext)"
conn.execute "insert into aaa values(123.45, 'xxx')"
rs.Open "SELECT m_comment, nm_price from aaa", conn, adOpenForwardOnly, adLockReadOnly
MsgBox rs.Collect("nm_price") ' = 0 - ERROR
rs.Close
rs.Open "SELECT nm_price from aaa", conn, adOpenForwardOnly, adLockReadOnly
MsgBox rs.Collect("nm_price") ' = 123.45 - OK
rs.Close
set rs=nothing
conn.execute "drop table aaa"
conn.Close
set conn = nothing



 Comments   
Comment by Lawrin Novitsky [ 2018-05-23 ]

Thank you for your report.
So, if longtext field follows decimal in the columns list, or if the field of any other type would precede decimal field, everything would be fine?
Also, I would appreciate if you could provide here ODBC trace.

Comment by Marek Šrom [ 2018-05-23 ]

Yes, if longtext column is behind decimal field in select clausule, everything is ok, also if field of different type (tried int) if before decimal, it is also ok...

I modified samle code to be vbs to be easier to test... I'll attach odbc trace...

Comment by Lawrin Novitsky [ 2018-05-24 ]

Thanks, that is even more than I expected

Comment by Marek Šrom [ 2018-05-24 ]

If it helps, in mySQL ODBC connector 5.3.10 it works ok...

Comment by Lawrin Novitsky [ 2018-05-30 ]

It happened, that SQLGetData converted incorrectly into SQL_NUMERIC(while converting while fetching into bound buffers worked well). Following some obscure logic, VB used SQLGetData if decimal field followed longtext, and SQLBindCol+SQLFetch otherwise.
The fix and the testcase have been pushed into odbc-3.0 as 62545da, and into odbc-2.0 as 7e10afd(cherry-picking)

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