[MCOL-656] Error in LIKE behaviour Created: 2017-04-06  Updated: 2017-05-11  Resolved: 2017-05-11

Status: Closed
Project: MariaDB ColumnStore
Component/s: PrimProc
Affects Version/s: 1.0.8, 1.1.0
Fix Version/s: 1.0.9, 1.1.0

Type: Bug Priority: Major
Reporter: Andrew Hutchings (Inactive) Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 0
Labels: community

Sprint: 2017-10

 Description   

From mailing list:

CREATE TABLE `test_like` (
  `dep` varchar(2) DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=utf8
 
CREATE TABLE `test_like_my` (
  `dep` varchar(2) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8
 
INSERT INTO test_like VALUES ('05'),('5'),('50'),('10');
INSERT INTO test_like_my VALUES ('05'),('5'),('50'),('10');
 
SELECT * FROM test_like;                                     
+------+
| dep  |
+------+
| 05   |
| 5    |
| 50   |
| 10   |
+------+
 
 
SELECT * FROM test_like_my;
+------+
| dep  |
+------+
| 05   |
| 5    |
| 50   |
| 10   |
+------+

And 2 query on columnstore:

SELECT count(*) FROM test_like  WHERE ( dep LIKE "05%" )  ;  
+----------+
| count(*) |
+----------+
|        1 |
+----------+
SELECT count(*) FROM test_like  WHERE ( dep LIKE "%05%" )  ;
+----------+
| count(*) |
+----------+
|        2 |
+----------+

And 2 query on MyIsam :

SELECT count(*) FROM test_like_my  WHERE ( dep LIKE "05%" )  ;
+----------+
| count(*) |
+----------+
|        1 |
+----------+
SELECT count(*) FROM test_like_my  WHERE ( dep LIKE "%05%" )  ;
+----------+
| count(*) |
+----------+
|        1 |
+----------+



 Comments   
Comment by Andrew Hutchings (Inactive) [ 2017-04-06 ]

It is matching the wrong ones too...

MariaDB [test]> SELECT * FROM test_like  WHERE ( dep LIKE "%05%" )  ;
+------+
| dep  |
+------+
| 50   |
| 10   |
+------+
2 rows in set (0.02 sec)

Comment by Pierre Coustilas [ 2017-04-06 ]

interesting. I tested with a varchar (3) instead of varchar (2). The result is columnstore in correct :

CREATE TABLE `test_like3` (`dep` varchar(3) DEFAULT NULL) ENGINE=columnstore DEFAULT CHARSET=utf8;
INSERT INTO test_like3 VALUES ('05'),('5'),('50'),('10');
 
SELECT count(*) FROM test_like3  WHERE ( dep LIKE "05%" )  ;
+----------+
| count(*) |
+----------+
|        1 |
+----------+
 
SELECT count(*) FROM test_like3  WHERE ( dep LIKE "%05%" )  ;
+----------+
| count(*) |
+----------+
|        1 |
+----------+
 
And the matching is correct : 
 # mysql 13:11:04 > SELECT * FROM test_like3  WHERE ( dep LIKE "%05%" )  ;
+------+
| dep  |
+------+
| 05   |
+------+
 

Comment by Andrew Hutchings (Inactive) [ 2017-05-09 ]

Four pull requests open. Two on engine (develop and develop-1.0), two on regression suite (master and 1.0).

The cause was essentially the LIKE was truncated to the length of the column when the column was a non-dictionary column (< 8 bytes). So for the original test case the LIKE on "%05%" became a LIKE on "%0" which matches 10 and 50. LIKE is now pushed through expression step instead of simple filter step which has an 8 byte limitation on non-dictionary CHAR/VARCHAR.

Comment by Daniel Lee (Inactive) [ 2017-05-11 ]

Build verified: 1.0.9-1

MariaDB [mytest]> SELECT count FROM test_like WHERE ( dep LIKE "05%" ) ;
----------

count

----------

1

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

MariaDB [mytest]> SELECT count FROM test_like WHERE ( dep LIKE "%05%" ) ;
----------

count

----------

1

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

Comment by Daniel Lee (Inactive) [ 2017-05-11 ]

Build verified: Github source 1.1.0-1

[root@localhost mariadb-columnstore-server]# git show
commit 349cae544b6bc71910267a3b3b0fa3fb57b0a587
Merge: bd13090 2ecb85c
Author: benthompson15 <ben.thompson@mariadb.com>
Date: Thu May 4 16:06:16 2017 -0500

Merge pull request #50 from mariadb-corporation/10.2-fixes

10.2 fixes

[root@localhost mariadb-columnstore-server]# cd mariadb-columnstore-engine/
[root@localhost mariadb-columnstore-engine]# git show
commit b4883e6abd18fb63c4af450679c2720cdb537dad
Merge: 85a5eaa 83331f4
Author: dhall-InfiniDB <david.hall@mariadb.com>
Date: Thu May 11 09:43:28 2017 -0500

Merge pull request #182 from mariadb-corporation/MCOL-712

MCOL-712 Support TEXT for GROUP BY

MariaDB [mytest]> CREATE TABLE `test_like` (
-> `dep` varchar(2) DEFAULT NULL
-> ) ENGINE=Columnstore DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.10 sec)

MariaDB [mytest]> INSERT INTO test_like VALUES ('05'),('5'),('50'),('10');
Query OK, 4 rows affected (0.08 sec)
Records: 4 Duplicates: 0 Warnings: 0

MariaDB [mytest]> SELECT * FROM test_like;
------

dep

------

05
5
50
10

------
4 rows in set (0.03 sec)

MariaDB [mytest]> SELECT count FROM test_like WHERE ( dep LIKE "05%" ) ;
----------

count

----------

1

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

MariaDB [mytest]>
MariaDB [mytest]> SELECT count FROM test_like WHERE ( dep LIKE "%05%" ) ;
----------

count

----------

1

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

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