Skip to content

Commit fed115c

Browse files
authored
Merge pull request mariadb-corporation#2837 from tntnatbry/MCOL-5357-dev
MCOL-5357 Fix TPC-DS query error "MCS-3009: Unknown column '.<colname>'".
2 parents 5a21440 + 1477b28 commit fed115c

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

dbcon/mysql/ha_mcs_execplan.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2454,6 +2454,20 @@ SimpleColumn* buildSimpleColFromDerivedTable(gp_walk_info& gwi, Item_field* ifp)
24542454
SimpleColumn* col = dynamic_cast<SimpleColumn*>(cols[j].get());
24552455
string alias = cols[j]->alias();
24562456

2457+
// MCOL-5357 For the following query:
2458+
2459+
// select item from (
2460+
// select item from (select a as item from t1) tt
2461+
// union all
2462+
// select item from (select a as item from t1) tt
2463+
// ) ttt;
2464+
2465+
// When the execution reaches the outermost item (ttt.item),
2466+
// alias = "`tt`.`item`" and ifp->field_name.str = "item".
2467+
// To make the execution enter the if block below, we strip off
2468+
// the backticks from alias.
2469+
boost::erase_all(alias, "`");
2470+
24572471
if (strcasecmp(ifp->field_name.str, alias.c_str()) == 0 ||
24582472
(col && alias.find(".") != string::npos &&
24592473
(strcasecmp(ifp->field_name.str, col->columnName().c_str()) == 0 ||
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
DROP DATABASE IF EXISTS mcol_5357;
2+
CREATE DATABASE mcol_5357;
3+
USE mcol_5357;
4+
CREATE TABLE t1 (a INT)engine=columnstore;
5+
INSERT INTO t1 VALUES (1), (2), (3);
6+
SELECT item FROM (
7+
SELECT item FROM (SELECT a AS item FROM t1) tt
8+
UNION ALL
9+
SELECT item FROM (SELECT a AS item FROM t1) tt
10+
) ttt;
11+
item
12+
1
13+
2
14+
3
15+
1
16+
2
17+
3
18+
DROP DATABASE mcol_5357;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#
2+
# MCOL-5357 Fix TPC-DS query error "MCS-3009: Unknown column '.<colname>'"
3+
#
4+
5+
--source ../include/have_columnstore.inc
6+
7+
--disable_warnings
8+
DROP DATABASE IF EXISTS mcol_5357;
9+
--enable_warnings
10+
CREATE DATABASE mcol_5357;
11+
USE mcol_5357;
12+
13+
CREATE TABLE t1 (a INT)engine=columnstore;
14+
INSERT INTO t1 VALUES (1), (2), (3);
15+
16+
SELECT item FROM (
17+
SELECT item FROM (SELECT a AS item FROM t1) tt
18+
UNION ALL
19+
SELECT item FROM (SELECT a AS item FROM t1) tt
20+
) ttt;
21+
22+
--disable_warnings
23+
DROP DATABASE mcol_5357;
24+
--enable_warnings

0 commit comments

Comments
 (0)