[MCOL-3827] view: column is not found in info map Created: 2020-02-21  Updated: 2020-09-21  Resolved: 2020-08-31

Status: Closed
Project: MariaDB ColumnStore
Component/s: ExeMgr
Affects Version/s: 1.4.3
Fix Version/s: 1.4.5, 5.4.1

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

Sprint: 2020-7
Epic/Theme: 1.4_regressions

 Description   

create table t1 (a int, b int) engine=columnstore;
insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10);
create view v1 (c,d,e,f) as select a,b,
(select a+2 from t1 limit 1) e1, (select a from t1 limit 1) f1 from t1;
select * from v1 order by 1,2,3,4;

ERROR 1815 (HY000): Internal error: column is not found in info map.

This is a regression since 1.2.6



 Comments   
Comment by David Hall (Inactive) [ 2020-03-11 ]

It appears the problem only surfaces in queries with order by 1,2,3,4. The same query with order by 1,2 does not fail.

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

The query found in working_tpch1_compareLogOnly/view/mts_view.sql

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;

also shows this error. Note that it has order by 1,2.

Comment by David Hall (Inactive) [ 2020-07-01 ]

This is caused by an ORDER BY on the returned value of a subquery. Such results don't have oids in the key maps and it gets confused.

Comment by David Hall (Inactive) [ 2020-07-02 ]

mts.1.0200.sql has this query, which is the simplest to exhibit the problem:
select (select a from t3), a from t2 order by 1, 2;

Comment by David Hall (Inactive) [ 2020-08-14 ]

The problem stems from moving order by into our code. Order by, as coded, doesn't see the results of a subquery. In this case, the parser will syntax out (or runtime will error) if the subquery returns more than one value, so ordering on it is redundant. Still, we should support it, as automated query builders may create such things.

A simplified way to reproduce:

CREATE TABLE t2 (a int(11) , b int(11) )engine=columnstore;
CREATE TABLE t3 (a int(11) )engine=columnstore;
insert into t2 values (1,7),(2,7);
insert into t3 values(3);
select (select a from t3), a from t2 order by 1, 2;

An interesting note:

select (select a from t3) c, a from t2 order by c, 2;

will not error. It won't put c in the sort, but it won't error. Since c must be a single value, it doesn't matter that it doesn't get into the sort:

select (select a from t3) c, a from t2 order by c, 2;
+------+------+
| c    | a    |
+------+------+
|    3 |    1 |
|    3 |    2 |
+------+------+

Adding a second value to t3 results in an error which is consistent with InnoDB behavior:

insert into t3 values(4);
select (select a from t3) c, a from t2 order by c, 2;
ERROR 1815 (HY000): Internal error: IDB-3002: Subquery returns more than 1 row.

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

The problem stems from moving order by into our code. Order by, as coded, doesn't see the results of a subquery. In this case, the parser will syntax out, or runtime will, if the subquery returns more than one row, so ordering on it is redundant. Still, we should support it, as automated query builders may create such things.

A simplified way to reproduce:

CREATE TABLE t2 (a int(11) , b int(11) )engine=columnstore;
CREATE TABLE t3 (a int(11) )engine=columnstore;
insert into t2 values (1,7),(2,7);
insert into t3 values(3);
select (select a from t3), a from t2 order by 1, 2;

An interesting note:

select (select a from t3) c, a from t2 order by c, 2;

will not error. It won't put c in the sort, but it won't error. Since c must be a single value, it doesn't matter that it doesn't get into the sort:

select (select a from t3) c, a from t2 order by c, 2;
+------+------+
| c    | a    |
+------+------+
|    3 |    1 |
|    3 |    2 |
+------+------+

Adding a second value to t3 results in an error:

insert into t3 values(4);
select (select a from t3) c, a from t2 order by c, 2;
ERROR 1815 (HY000): Internal error: IDB-3002: Subquery returns more than 1 row.

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

Fixed by optimizing out any order by on a scaler subselect. This way, any internal confusion is avoided, and cost of sorting on a single value is saved.

Comment by Gagan Goel (Inactive) [ 2020-08-18 ]

David.Hall Can you reinstate all the relevant regression tests for this fix?

Comment by David Hall (Inactive) [ 2020-08-20 ]

MariaDB [tpch1]> select * from v1 order by 1,2,3,4;
------------------+

c d e f

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

1 2 3 1
1 3 3 1
2 4 3 1
2 5 3 1
3 10 3 1

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

Comment by Daniel Lee (Inactive) [ 2020-08-31 ]

Builds verified: 1.4.5-1 (drone #483), 1.5.4-1 (drone #496)

MariaDB [mytest]> create table t1 (a int, b int) engine=columnstore;
Query OK, 0 rows affected (0.181 sec)

MariaDB [mytest]> insert into t1 values (1,2), (1,3), (2,4), (2,5), (3,10);
Query OK, 5 rows affected (0.775 sec)
Records: 5 Duplicates: 0 Warnings: 0

MariaDB [mytest]> create view v1 (c,d,e,f) as select a,b,
-> (select a+2 from t1 limit 1) e1, (select a from t1 limit 1) f1 from t1;
Query OK, 0 rows affected (0.001 sec)

MariaDB [mytest]> select * from v1 order by 1,2,3,4;
------------------+

c d e f

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

1 2 3 1
1 3 3 1
2 4 3 1
2 5 3 1
3 10 3 1

------------------+
5 rows in set (0.090 sec)

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