[MCOL-2233] SUBSTRING_INDEX() returns incorrect value when index value is negative Created: 2019-03-12  Updated: 2019-03-16  Resolved: 2019-03-16

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

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

Issue Links:
Problem/Incident
is caused by MCOL-1822 Change the default to use double when... Closed
Sprint: 2019-03

 Description   

Build tested: 1.2.3-1

MariaDB [mytest]> create table t3 (c char(10)) engine=columnstore;
Query OK, 0 rows affected (0.169 sec)

MariaDB [mytest]> insert into t3 values ('aaaaaaaaaa');
Query OK, 1 row affected (0.165 sec)

MariaDB [mytest]> select c, SUBSTRING_INDEX(c,'a', -3) from t3;
--------------------------------------+

c SUBSTRING_INDEX(c,'a', -3)

--------------------------------------+

aaaaaaaaaa aaaaaaaaaa

--------------------------------------+
1 row in set (0.061 sec)

The query should return 'aa' instead.



 Comments   
Comment by Roman [ 2019-03-13 ]

The problem was caused by the loop iterator counter and limiter types change(int64_t -> size_t). When negative values is used as the third argument to SUBSTRING_INDEX then loop limiter becomes close to max(size_t) and function returns an initial string.
Please review the fix.

Comment by Roman [ 2019-03-13 ]

Please review the change.

Comment by Daniel Lee (Inactive) [ 2019-03-16 ]

Build verified: 1.2.3-1

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