[MCOL-3828] UNION: complains about table not in query Created: 2020-02-21 Updated: 2020-11-12 Resolved: 2020-03-30 |
|
| Status: | Closed |
| Project: | MariaDB ColumnStore |
| Component/s: | ExeMgr |
| Affects Version/s: | 1.4.3 |
| Fix Version/s: | 1.4.3-5, 1.4.4, 1.5.1 |
| Type: | Bug | Priority: | Critical |
| Reporter: | David Hall (Inactive) | Assignee: | Daniel Lee (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Sprint: | 2020-4, 2020-5 | ||||||||
| Epic/Theme: | 1.4_regressions | ||||||||
| Description |
|
Consider the following sequence from working_tpch/union/union.sql CREATE TABLE t1 ( INSERT INTO t1 VALUES (8,'dummy'); INSERT INTO t4 VALUES (1,1,NULL,NULL); SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t6.uc = t1.cid AND t1.cv = "dummy" AND t6.un = "test"; create table t1 (a int) engine=columnstore; SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc; This only happens if you run the full sequence. Otherwise, there's no complaint about a table not existing – one that isn't in the query at all. |
| Comments |
| Comment by David Hall (Inactive) [ 2020-02-25 ] | ||||||||||||||||||||||||||
|
This appears to be a similar problem that sometimes occurs in working_tpch1_comparelogonly.view/view.sql CREATE TABLE t2 ( id int, gid int, lid int, dt date) engine=columnstore; SELECT DISTINCT t2.gid AS lgid,(SELECT t1.name FROM t1, t2 WHERE t1.lid = t2.lid AND t2.gid = t1.lid and t1.lid =1 ) as clid FROM t2 order by 1, 2; CREATE VIEW v1 AS SELECT DISTINCT t2.gid AS lgid,(SELECT t1.name FROM t1, t2 WHERE t1.lid = t2.lid AND t2.gid = t1.lid and t1.lid =1 ) as clid FROM t2; DROP VIEW v1; CREATE TABLE t1 (a INT) engine=columnstore; SELECT * FROM t1 UNION SELECT * FROM v1; | ||||||||||||||||||||||||||
| Comment by David Hall (Inactive) [ 2020-03-05 ] | ||||||||||||||||||||||||||
|
Got a different error this time: ERROR 1815 (HY000) at line 115: Internal error: value is not numerical. | ||||||||||||||||||||||||||
| Comment by David Hall (Inactive) [ 2020-03-11 ] | ||||||||||||||||||||||||||
|
Found a similar problem in working_tpch1_compareLogOnly/view/mts_view.sql lines 896 and 897 | ||||||||||||||||||||||||||
| Comment by Roman [ 2020-03-20 ] | ||||||||||||||||||||||||||
|
So, there were two bugs that caused the issues: tables are not joined was caused by join order and conditions replacement introduced by MDB's optimizer that was called by optimize_unflattened_subqueries_mcs() function under the hood. I replaced the f() to address equi-JOIN conditions injection for IN + subquery predicates. | ||||||||||||||||||||||||||
| Comment by Roman [ 2020-03-20 ] | ||||||||||||||||||||||||||
|
Plz review. | ||||||||||||||||||||||||||
| Comment by Daniel Lee (Inactive) [ 2020-03-30 ] | ||||||||||||||||||||||||||
|
Builds verified: 1.4.4-1 source, 1.5.0-1 BB 1.4.4-1 /root/ColumnStore/buildColumnstoreFromGithubSource/server /root/ColumnStore/buildColumnstoreFromGithubSource/server/engine Merge pull request #1117 from drrtuy/ 1.5.0-1 engine commit: Verified tests cases in both bug description and in comments. | ||||||||||||||||||||||||||
| Comment by Daniel Lee (Inactive) [ 2020-04-01 ] | ||||||||||||||||||||||||||
|
Build verified: 1.4.3-5 hot fix, Azure 20200401.6 MariaDB [mytest]> CREATE TABLE t1 ( MariaDB [mytest]> INSERT INTO t1 VALUES (8,'dummy'); MariaDB [mytest]> CREATE TABLE t2 ( MariaDB [mytest]> CREATE TABLE t3 ( MariaDB [mytest]> INSERT INTO t3 VALUES (1,'V1',NULL); MariaDB [mytest]> CREATE TABLE t4 ( MariaDB [mytest]> INSERT INTO t4 VALUES (1,1,NULL,NULL); MariaDB [mytest]> CREATE TABLE t5 ( MariaDB [mytest]> CREATE TABLE t6 ( MariaDB [mytest]> INSERT INTO t6 VALUES (1,'test',8); MariaDB [mytest]> SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t6.uc = t1.cid AND t1.cv = "dummy" AND t6.un = "test";
-----
----- MariaDB [mytest]> SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t3.must IS NOT NULL AND t6.uc = t1.cid AND t1.cv = "dummy" AND t6.un = "test"; MariaDB [mytest]> (SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t3.must IS NOT NULL AND t6.uc = t1.cid AND t1.cv = "dummy" AND t6.un = "test") UNION (SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t6.uc = t1.cid AND t1.cv = "dummy" AND t6.un = "test");
-----
----- MariaDB [mytest]> drop table if exists t1; MariaDB [mytest]> drop table if exists t2; MariaDB [mytest]> drop table if exists t3; MariaDB [mytest]> drop table if exists t4; MariaDB [mytest]> drop table if exists t5; MariaDB [mytest]> drop table if exists t6; MariaDB [mytest]> create table t1 (a int) engine=columnstore; MariaDB [mytest]> insert into t1 values (1),(2),(3); MariaDB [mytest]> create table t2 (a int) engine=columnstore; MariaDB [mytest]> insert into t2 values (3),(4),(5); MariaDB [mytest]> SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc;
------
------ |