[MCOL-3949] IF() is incorrect when using hex constant Created: 2020-04-16  Updated: 2020-11-12  Resolved: 2020-04-20

Status: Closed
Project: MariaDB ColumnStore
Component/s: PrimProc
Affects Version/s: 1.5.3
Fix Version/s: 1.5.1

Type: Bug Priority: Major
Reporter: David Hall (Inactive) Assignee: Roman
Resolution: Fixed Votes: 0
Labels: None

Sprint: 2020-7

 Description   

Consider the following:

select  IF(r_regionkey >= 0x40000000, r_regionkey+10, r_regionkey)   page from region cc order by 1 ;

This returns r_regionkey+10, even though all r_regionkey are < 5.

Replacing 0x40000000 with it's base 10 equivalent (1073741824) does not exhibit the bug.

Debugging shows that the constant column is malformed when it reaches the IF function.

This is a regression in 1.5. columnstore 1.4.4 returns the correct response, and debugging shows the constant column is correct.



 Comments   
Comment by David Hall (Inactive) [ 2020-04-16 ]

This regression is caught by working_tpch1/misc/CCBillEU.sql which contains the query

select  IF(  ( IF(r_regionkey >= 0x40000000, r_regionkey+10, r_regionkey) > 0 ) , 1, 0) page from region cc order by 1 ;

Comment by David Hall (Inactive) [ 2020-04-17 ]

QA:
Before the patch:
MariaDB [tpch1]> select IF(r_regionkey >= 0x40000000, r_regionkey+10, r_regionkey) page from region cc order by 1 ;
------

page

------

10
11
12
13
14

------

After the patch:
MariaDB [tpch1]> select IF(r_regionkey >= 0x40000000, r_regionkey+10, r_regionkey) page from region cc order by 1 ;
------

page

------

0
1
2
3
4

------

Comment by David Hall (Inactive) [ 2020-04-17 ]

Server has changed the way type_handler works so our use of it failed, causing the wrong execution path in gp_walk() with the case Item::CONST_ITEM, Item::STRING_RESULT. The same change was needed in buildReturnedColumn().

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