[MCOL-898] NULL operand ignored in vtable mode when querying view Created: 2017-08-29 Updated: 2020-08-25 Resolved: 2017-10-25 |
|
| Status: | Closed |
| Project: | MariaDB ColumnStore |
| Component/s: | PrimProc |
| Affects Version/s: | 1.0.10 |
| Fix Version/s: | 1.0.12, 1.1.1 |
| Type: | Bug | Priority: | Major |
| Reporter: | patrice | Assignee: | Daniel Lee (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Sprint: | 2017-19, 2017-20, 2017-21 |
| Description |
|
With the example below, columnstore return a number instead of NULL in the addition when there is a if in the view and using vtable=0 gives NULL. use test; |
| Comments |
| Comment by Geoff Montee (Inactive) [ 2017-08-29 ] | |||||||||||||||||||||||||||||||||||
|
It looks like this can be simplified into the following:
Results:
| |||||||||||||||||||||||||||||||||||
| Comment by David Hall (Inactive) [ 2017-10-05 ] | |||||||||||||||||||||||||||||||||||
|
Substitution to remove the view still results in incorrect data. Therefore, the use of a view is not a contributing factor: MariaDB [dhall]> SELECT if(`test_bug`.`a` > 0,`test_bug`.`a`,1)+NULL FROM test_bug;
----------------------------------------------
---------------------------------------------- MariaDB [dhall]> SELECT if(`test_bug`.`a` > 0,`test_bug`.`a`,1)+NULL FROM test_bug;
----------------------------------------------
---------------------------------------------- | |||||||||||||||||||||||||||||||||||
| Comment by David Hall (Inactive) [ 2017-10-06 ] | |||||||||||||||||||||||||||||||||||
|
Swapping the order (NULL+a) gives the correct answer and can be used as a workaround. The problem is caused by the right hand side of the '+' being evaluated first which sets a global NULL flag. The if logic on the left hand side uses that NULL flag in ways that cause the issue. By switching the order, the NULL is evaluated after the if so it doesn't interfere with the if and the if doesn't mess with the flag and so the proper answer is given. | |||||||||||||||||||||||||||||||||||
| Comment by David Hall (Inactive) [ 2017-10-06 ] | |||||||||||||||||||||||||||||||||||
|
func_if uses a private utility boolVal(). We were passing in the global value of isNull, which had been set, which short circuited the boolVal logic. We then set isNull to false because we didn't want the action of boolVal to influence the final answer. Unfortunately, this had the effect of wiping out the right hand side setting. I changed boolVal to use a private isNull, and let the other functions use isNull unchanged. | |||||||||||||||||||||||||||||||||||
| Comment by Daniel Lee (Inactive) [ 2017-10-24 ] | |||||||||||||||||||||||||||||||||||
|
Build verified: Github source for 1.1.1-1 /root/columnstore/mariadb-columnstore-server Merge pull request #72 from mariadb-corporation/ /root/columnstore/mariadb-columnstore-server/mariadb-columnstore-engine removed duplicaue entries Verified test case in the bug description, as well as in the comments. | |||||||||||||||||||||||||||||||||||
| Comment by Daniel Lee (Inactive) [ 2017-10-25 ] | |||||||||||||||||||||||||||||||||||
|
Build verified: Github source for 1.0.12-1 /root/columnstore/mariadb-columnstore-server Merge pull request #69 from mariadb-corporation/ /root/columnstore/mariadb-columnstore-server/mariadb-columnstore-engine Merge pull request #300 from mariadb-corporation/ Verified with the same tests. | |||||||||||||||||||||||||||||||||||
| Comment by Daniel Lee (Inactive) [ 2017-10-25 ] | |||||||||||||||||||||||||||||||||||
|
Both 1.0.12 and 1.1.1 have been verified |