[MCOL-4823] WHERE varchar_col<char_col returns a wrong result on a large table Created: 2021-07-29  Updated: 2021-12-10  Resolved: 2021-08-24

Status: Closed
Project: MariaDB ColumnStore
Component/s: PrimProc
Affects Version/s: 6.1.1
Fix Version/s: 6.2.1, 6.2.2

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MCOL-4791 Fix ColumnCommand fudged data type fo... Stalled
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.



 Comments   
Comment by Daniel Lee (Inactive) [ 2021-08-05 ]

Build verified: Drone build # 2929 (develop-6 branch)

The fixed has been committed to both develop and develop-6 branches.
As of now, the "Fix Version" is assigned to 6.1.1, which already has been released. A new release number needs to be assigned. If the fix will be released as 6.1.1-2, we need to commit it to develop-5. Would 6.1.2-1 also be based on develop-5?

Comment by Daniel Lee (Inactive) [ 2021-08-24 ]

This ticket has been reassigned to 6.2.1, which has been verified (branch develop-6)

Generated at Thu Feb 08 02:53:16 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.