[MCOL-4428] WHERE char6col <='STR' OR char6col IS NULL -- returns a wrong result after MCOL-495 Created: 2020-12-02  Updated: 2021-02-15  Resolved: 2020-12-09

Status: Closed
Project: MariaDB ColumnStore
Component/s: ExeMgr
Affects Version/s: 5.5.1
Fix Version/s: 5.5.1

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MCOL-495 Make string comparison not case sensi... Closed
relates to MCOL-4064 Make JOIN collation aware Closed
relates to MCOL-4417 Non-equality comparison operators do ... Closed
relates to MCOL-4539 WHERE short_char_column='literal' ign... Closed

 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);



 Comments   
Comment by Daniel Lee (Inactive) [ 2020-12-09 ]

Build verified: 5.5.1 (Drone 1304)

MariaDB [mytest]> CREATE TABLE `t1` (`p_mfgr` char(6) DEFAULT NULL) ENGINE=Columnstore DEFAULT CHARSET=latin1;
Query OK, 0 rows affected (0.217 sec)

MariaDB [mytest]> INSERT INTO `t1` VALUES ('MFGR#1');
Query OK, 1 row affected (0.889 sec)

MariaDB [mytest]>
MariaDB [mytest]> select p_mfgr from t1 where p_mfgr <='MFGR#1' or p_mfgr is null;
--------

p_mfgr

--------

MFGR#1

--------
1 row in set (0.109 sec)

MariaDB [mytest]> select p_mfgr from t1 where p_mfgr <='MFGR#1' or p_mfgr is null;
--------

p_mfgr

--------

MFGR#1

--------
1 row in set (0.045 sec)

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