[MCOL-352] substr() on view returns NULL sometimes Created: 2016-10-10 Updated: 2016-11-11 Resolved: 2016-11-11 |
|
| Status: | Closed |
| Project: | MariaDB ColumnStore |
| Component/s: | PrimProc |
| Affects Version/s: | 1.0.3 |
| Fix Version/s: | 1.0.5 |
| Type: | Bug | Priority: | Minor |
| Reporter: | David Hall (Inactive) | Assignee: | Daniel Lee (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
CentOS |
||
| Sprint: | 2016-21, 2016-22 |
| Description |
|
This issue exists in InfiniDB. This issue arose because of an anomoly seen in working_tcph_comparelogonly/partitionOptimization/vTpch22.sql When substr is called on a view, sometimes it returns NULL Here we select substr and acct_bal from the table. We get the expected result.
----------
---------- Here we select substr and acct_bal from the view. We get unexpected NULLs on some of the rows.
----------
---------- Here we select only substr from the view. We get the expected result.
-----------
----------- MariaDB [tpch1]> |
| Comments |
| Comment by David Hall (Inactive) [ 2016-10-17 ] | ||||||||||||||||||||||||||||||||
| Comment by David Hall (Inactive) [ 2016-10-17 ] | ||||||||||||||||||||||||||||||||
|
Note that this bug is intermittent. Sometimes it manifests, sometimes it doesn't. It seems to only happen in vtable mode. The relevant test is working_tpch1_compareLogOnly/partitionOptimization/vTpch22.sql | ||||||||||||||||||||||||||||||||
| Comment by David Hall (Inactive) [ 2016-10-17 ] | ||||||||||||||||||||||||||||||||
|
I renamed vTpch22.sql to vTpch22.sql.fixme. Be sure to name it back when fixed. | ||||||||||||||||||||||||||||||||
| Comment by Andrew Hutchings (Inactive) [ 2016-10-25 ] | ||||||||||||||||||||||||||||||||
|
I'm pretty sure it is the same problem. Scenario appears to be: View is evaluated as a subquery. Derived processing doesn't include any LHS of query so the function applied on the view result is not pushed to PrimProc. The unprocessed result is passed straight back to mysqld which can produce unexpected results. We appear to need a way (probably in ha_from_sub) to process a function for a column from a subquery. Or push the function down into the subquery. | ||||||||||||||||||||||||||||||||
| Comment by David Thompson (Inactive) [ 2016-10-25 ] | ||||||||||||||||||||||||||||||||
|
Possibly same root cause as | ||||||||||||||||||||||||||||||||
| Comment by Andrew Hutchings (Inactive) [ 2016-10-26 ] | ||||||||||||||||||||||||||||||||
|
Fix ready when we have the branches unlocked | ||||||||||||||||||||||||||||||||
| Comment by Andrew Hutchings (Inactive) [ 2016-10-27 ] | ||||||||||||||||||||||||||||||||
|
Problem was actually due to the union of the CHAR columns becoming a VARCHAR so ExeMgr was expecting the VARCHAR to be NUL terminated (which it wasn't) before executing the function. | ||||||||||||||||||||||||||||||||
| Comment by David Hall (Inactive) [ 2016-10-27 ] | ||||||||||||||||||||||||||||||||
|
Renamed vTpch22.sql.fixme to vTpch22.sql. | ||||||||||||||||||||||||||||||||
| Comment by Daniel Lee (Inactive) [ 2016-11-11 ] | ||||||||||||||||||||||||||||||||
|
Build verified: mcsadmin> getsoft Name : mariadb-columnstore-platform The two queries in the bug description returned different rows, most likely due to the ordering of the rows returned and the limit 10 clause. Without using the limit 10 clause, lots of rows returned and none of them had NULL in the first column. Just to make sure the return results match are matching, I executed the following queries, one on actual table and the other on the view. MariaDB [tpch10c]> select distinct cntrycode, sum(c_acctbal) from (select substr(c_phone, 1, 2) as cntrycode, c_acctbal from customer where substr(c_phone, 1, 2) in ('13', '31', '23', '29', '30', '18', '17') order by cntrycode, c_acctbal) a order by cntrycode;
----------
---------- MariaDB [tpch10c]> select distinct cntrycode, sum(c_acctbal) from (select substr(c_phone, 1, 2) as cntrycode, c_acctbal from v_customer where substr(c_phone, 1, 2) in ('13', '31', '23', '29', '30', '18', '17') order by cntrycode, c_acctbal) a order by cntrycode;
----------
---------- |