Uploaded image for project: 'MariaDB ColumnStore'
  1. MariaDB ColumnStore
  2. MCOL-4428

WHERE char6col <='STR' OR char6col IS NULL -- returns a wrong result after MCOL-495

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5.1
    • Fix Version/s: 5.5.1
    • Component/s: ExeMgr
    • Labels:
      None

      Description

      I run this script:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE `t1` (
        `p_mfgr` char(6) DEFAULT NULL
      ) ENGINE=Columnstore DEFAULT CHARSET=latin1;
      INSERT INTO `t1` VALUES ('MFGR#1');
      select p_mfgr from t1 where p_mfgr <='MFGR#1' or p_mfgr is null;
      select p_mfgr from t1 where p_mfgr <='MFGR#1' or p_mfgr is null;
      

      The first SELECT returns one row. The second select returns no rows.

      The bug was revealed after recent collation-aware comparison changes, and most likely after this commit:

      commit ad32abdf491322703cf3cf25732a76dd44436f36
      Author: Alexander Barkov <bar@mariadb.com>
      Date:   Tue Dec 1 10:48:59 2020 +0400
       
          Part#1 MCOL-495 Make string comparison not case sensitive
          
          Fixing field='str' for long (Dict) string data types.
      

      The bug has been in the code for some time and it was not introduced by the collation-aware comparison changes. But these changes helped to reveal this bug.

      This patch fixes the problem.

      diff --git a/dbcon/joblist/lbidlist.cpp b/dbcon/joblist/lbidlist.cpp
      index 1ce5f5a9..9a9e3787 100644
      --- a/dbcon/joblist/lbidlist.cpp
      +++ b/dbcon/joblist/lbidlist.cpp
      @@ -775,14 +775,14 @@ bool LBIDList::CasualPartitionPredicate(const int64_t Min,
                   }
               }
       
      +        MsgDataPtr += ct.colWidth;
      +
               // Should we also check for empty here?
               if (isNull(value, ct)) // This will work even if the data column is unsigned.
               {
                   continue;
               }
       
      -        MsgDataPtr += ct.colWidth;
      -
               if (bIsChar && 1 < ct.colWidth)
               {
                   datatypes::Charset cs(ct.charsetNumber);
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bar Alexander Barkov
              Reporter:
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Git Integration