Uploaded image for project: 'MariaDB Connector/ODBC'
  1. MariaDB Connector/ODBC
  2. ODBC-146

Wrong decimal value (0) when after longtext field in select clausule (using ADO, client side cursor)

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 3.0.3
    • 2.0.17, 3.0.5
    • General
    • None
    • Windows server 2012 R2

    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

      Attachments

        1. mdb.vbs
          0.6 kB
        2. SQL.LOG
          100 kB

        Activity

          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.

          Lawrin Lawrin Novitsky added a comment - 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.
          marek.srom Marek Šrom added a comment -

          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...

          marek.srom Marek Šrom added a comment - 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...

          Thanks, that is even more than I expected

          Lawrin Lawrin Novitsky added a comment - Thanks, that is even more than I expected
          marek.srom Marek Šrom added a comment -

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

          marek.srom Marek Šrom added a comment - If it helps, in mySQL ODBC connector 5.3.10 it works ok...

          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)

          Lawrin Lawrin Novitsky added a comment - 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)

          People

            Lawrin Lawrin Novitsky
            marek.srom Marek Šrom
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.