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

WHERE varchar_col<char_col returns a wrong result on a large table

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.1.1
    • Fix Version/s: 6.2.1, 6.2.2
    • Component/s: PrimProc
    • Labels:
      None
    • Sprint:
      2021-10

      Description

      I create a MyISAM table with some string columns with the latin1_bin collation, insert 122881 records and run a query with a WHERE condition which matches all those records:

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1
      (
        l_returnflag char(1) CHARACTER SET latin1 COLLATE latin1_bin,
        l_shipinstruct char(25) CHARACTER SET latin1 COLLATE latin1_bin,
        l_comment varchar(44) CHARACTER SET latin1 COLLATE latin1_bin
      ) ENGINE=MyISAM;
       
      DELIMITER $$
      FOR i IN 1..122881
      DO
        INSERT INTO t1 VALUES ('a', 'aaaa','AAAA');
      END FOR;
      $$
      DELIMITER ;
      SELECT count(*) FROM t1 WHERE l_comment < l_shipinstruct;
      

      It returns all records as expected:

      +----------+
      | count(*) |
      +----------+
      |   122881 |
      +----------+
      

      Now I make a ColumnStore table with the same structure and data and run the same SELECT query:

      DROP TABLE IF EXISTS t2;
      CREATE TABLE t2 LIKE t1;
      ALTER TABLE t2 ENGINE=ColumnStore;
      INSERT INTO t2 SELECT * FROM t1;
      SELECT count(*) FROM t2 WHERE l_comment < l_shipinstruct;
      

      +----------+
      | count(*) |
      +----------+
      |        1 |
      +----------+
      

      Notice, it returns a wrong result.

      Moreover, if I repeat the last query multiple times, it can also return a result like this:

      +----------+
      | count(*) |
      +----------+
      |   122880 |
      +----------+
      

      But it never returns the expected result 122881.

      The problem happens because this method:

      SCommand StrFilterCmd::duplicate()
      {
          SCommand ret;
          StrFilterCmd* filterCmd;
       
          ret.reset(new StrFilterCmd());
          filterCmd = (StrFilterCmd*) ret.get();
          filterCmd->fBOP = fBOP;
          filterCmd->fCompare = fCompare;
          filterCmd->fCharLength = fCharLength;
       
          return ret;
      }
      

      misses these two lines:

          filterCmd->leftColType = leftColType;
          filterCmd->rightColType = rightColType;
      

      Note, the same method of the parent class, i.e. FilterCommand::duplicate(), does have these two lines!

      StrFilterCmd::duplicate() fully duplicates FilterCommand::duplicate() with the exeption that the mentioned two members are not coppied.

      To fix this problem and to avoid similar bugs in the future, the duplicate code should be removed.
      StrFilterCmd::duplicate() should just call the inherited FilterCommand::duplicate(), then additionally copy its specific members.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dleeyh Daniel Lee
              Reporter:
              bar Alexander Barkov
              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.