Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-112674

odbc sqldriver ends up with errors because the size of data is returned 1 char higher.

XMLWordPrintable

    • Windows

      moving from Qt6.4.2 to Qt6.4.3 it appears odbc sqldriver has a bug. In Qt6.4.3 if the size of the database column equals the size of the QString. for example if  column Uuid in table is a varchar(36), and the inserted Data is of size 36 characters  then  Qt6.4.3 odbc driver passes size 37 which results in the error.

      This is happening probably because of the code like following:

       in Qt/6.4.3/Src/qtbase/src/plugins/sqldrivers/odbc/qsql_odbc.cpp, line
      1374:
      {
      auto encoded = toSQLTCHAR(query);
      r = SQLPrepare(d->hStmt,
      encoded.data(),
      SQLINTEGER(encoded.size()));
      }
      
      In Qt6.4.2 it was:
      r = SQLPrepare(d->hStmt,
      toSQLTCHAR(query).data(),
      (SQLINTEGER) query.length());

      The problem is that toSQLTCHAR returns a QVarLengthArray which has a
      size one element bigger than the original QString. That is probably because it  appends(0) at the end.

      When client application runs it ends with following error:

      "[Microsoft][SQL Server Native Client 11.0][SQL
      Server]Character or binary data in table
      "MyDatabase.dbo.mytable", column "Uuid" is truncated.
      Truncated Data: B98E2686-E67F-4F8F-8D8D-DD0B0DBBFECE."

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            chehrlic Christian Ehrlicher
            irfan.omair@digia.com Irfan Omair
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes