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

Executing an if else query results to an infinite loop

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.3.1
    • 5.2.1, 5.3.0
    • SQL Support
    • None
    • Windows 7
    • d153e4628e7643cf02b795f68f739c4bced15389

    Description

      Executing the following query on DB2:
      select if (1 = 0 ) then 'a'; else 'b'; end if
      generates an infinite loop generating the following message:

      Warning qMakeFieldInfo: Unable to describe column 0 Error: [IBM][CLI Driver][DB2/LINUXX8664] SQL0104N An unexpected token "=" was found following "select if (1 ". Expected tokens may include: "CONCAT". SQLSTATE=42601

      the index of the column is increasing constantly.

      The problem seems to be that SQLSMALLINT count; is not initialized. After initializing it to zero the infinite loop and warning does not occur. Making the same query directly to db without Qt works fine.

      qsql_db2.cpp in bool QDB2Result::exec()

      ..
      SQLSMALLINT count;
      r = SQLNumResultCols(d->hStmt, &count;);
      if (count) {
      setSelect(true);
      for (int i = 0; i < count; ++i) {
      d->recInf.append(qMakeFieldInfo(d, i));
      }
      } else {
      setSelect(false);
      }
      

      Attachments

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

        Activity

          People

            andysh Andy Shaw
            qtcomsupport Qt Support
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes