You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-29 08:21:15 +03:00
MCOL-5357 Fix TPC-DS query error "MCS-3009: Unknown column '.<colname>'".
For the following query: select item from ( select item from (select a as item from t1) tt union all select item from (select a as item from t1) tt ) ttt; There is an if predicate in buildSimpleColFromDerivedTable() that compares the outermost query field name (ttt.item) to the returned column list of the inner query (tt.item) when building the returned column list of the outer most query. In the above query example, the inner query field name is an alias set in the inner most query and is set to "`tt`.`item`", while the outermost query field name is set to "item". The use of backticks "`" in the inner query alias is causing the execution to not enter the if block which creates the SimpleColumn for the outermost query field name. As a fix, we strip off the backticks from the inner query alias.
This commit is contained in:
@ -2454,6 +2454,20 @@ SimpleColumn* buildSimpleColFromDerivedTable(gp_walk_info& gwi, Item_field* ifp)
|
||||
SimpleColumn* col = dynamic_cast<SimpleColumn*>(cols[j].get());
|
||||
string alias = cols[j]->alias();
|
||||
|
||||
// MCOL-5357 For the following query:
|
||||
|
||||
// select item from (
|
||||
// select item from (select a as item from t1) tt
|
||||
// union all
|
||||
// select item from (select a as item from t1) tt
|
||||
// ) ttt;
|
||||
|
||||
// When the execution reaches the outermost item (ttt.item),
|
||||
// alias = "`tt`.`item`" and ifp->field_name.str = "item".
|
||||
// To make the execution enter the if block below, we strip off
|
||||
// the backticks from alias.
|
||||
boost::erase_all(alias, "`");
|
||||
|
||||
if (strcasecmp(ifp->field_name.str, alias.c_str()) == 0 ||
|
||||
(col && alias.find(".") != string::npos &&
|
||||
(strcasecmp(ifp->field_name.str, col->columnName().c_str()) == 0 ||
|
||||
|
18
mysql-test/columnstore/bugfixes/mcol-5357.result
Normal file
18
mysql-test/columnstore/bugfixes/mcol-5357.result
Normal file
@ -0,0 +1,18 @@
|
||||
DROP DATABASE IF EXISTS mcol_5357;
|
||||
CREATE DATABASE mcol_5357;
|
||||
USE mcol_5357;
|
||||
CREATE TABLE t1 (a INT)engine=columnstore;
|
||||
INSERT INTO t1 VALUES (1), (2), (3);
|
||||
SELECT item FROM (
|
||||
SELECT item FROM (SELECT a AS item FROM t1) tt
|
||||
UNION ALL
|
||||
SELECT item FROM (SELECT a AS item FROM t1) tt
|
||||
) ttt;
|
||||
item
|
||||
1
|
||||
2
|
||||
3
|
||||
1
|
||||
2
|
||||
3
|
||||
DROP DATABASE mcol_5357;
|
24
mysql-test/columnstore/bugfixes/mcol-5357.test
Normal file
24
mysql-test/columnstore/bugfixes/mcol-5357.test
Normal file
@ -0,0 +1,24 @@
|
||||
#
|
||||
# MCOL-5357 Fix TPC-DS query error "MCS-3009: Unknown column '.<colname>'"
|
||||
#
|
||||
|
||||
--source ../include/have_columnstore.inc
|
||||
|
||||
--disable_warnings
|
||||
DROP DATABASE IF EXISTS mcol_5357;
|
||||
--enable_warnings
|
||||
CREATE DATABASE mcol_5357;
|
||||
USE mcol_5357;
|
||||
|
||||
CREATE TABLE t1 (a INT)engine=columnstore;
|
||||
INSERT INTO t1 VALUES (1), (2), (3);
|
||||
|
||||
SELECT item FROM (
|
||||
SELECT item FROM (SELECT a AS item FROM t1) tt
|
||||
UNION ALL
|
||||
SELECT item FROM (SELECT a AS item FROM t1) tt
|
||||
) ttt;
|
||||
|
||||
--disable_warnings
|
||||
DROP DATABASE mcol_5357;
|
||||
--enable_warnings
|
Reference in New Issue
Block a user