From 71185efe54333a26359155d9fc1d5354edb95a0b Mon Sep 17 00:00:00 2001 From: Leonid Fedorov Date: Tue, 16 Apr 2024 14:57:53 +0000 Subject: [PATCH] Fixed review notices, added the loop over selects, to collect error on more tnan two selects --- dbcon/mysql/ha_mcs_execplan.cpp | 21 ++++++++++++------- .../columnstore/bugfixes/MCOL-5699.result | 12 ++++++++++- .../columnstore/bugfixes/MCOL-5699.test | 16 +++++++++++++- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/dbcon/mysql/ha_mcs_execplan.cpp b/dbcon/mysql/ha_mcs_execplan.cpp index 3eaed5f85..bd218ae57 100644 --- a/dbcon/mysql/ha_mcs_execplan.cpp +++ b/dbcon/mysql/ha_mcs_execplan.cpp @@ -6744,16 +6744,21 @@ int processFrom(bool& isUnion, SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP& // is_unit_op() give a segv for derived_handler's SELECT_LEX // check INTERSECT or EXCEPT, that are not implemented - auto* nextSelect = select_lex.master_unit()->first_select()->next_select(); - if (nextSelect) + if (select_lex.master_unit() && select_lex.master_unit()->first_select()) { - if (nextSelect->get_linkage() == INTERSECT_TYPE) + for (auto nextSelect = select_lex.master_unit()->first_select()->next_select(); nextSelect; + nextSelect = nextSelect->next_select()) { - setError(gwi.thd, ER_INTERNAL_ERROR, "INTERSECT is not supported by Columnstore engine", gwi); - } - else if (nextSelect->get_linkage() == EXCEPT_TYPE) - { - setError(gwi.thd, ER_INTERNAL_ERROR, "EXCEPT is not supported by Columnstore engine", gwi); + if (nextSelect->get_linkage() == INTERSECT_TYPE) + { + setError(gwi.thd, ER_INTERNAL_ERROR, "INTERSECT is not supported by Columnstore engine", gwi); + return ER_INTERNAL_ERROR; + } + else if (nextSelect->get_linkage() == EXCEPT_TYPE) + { + setError(gwi.thd, ER_INTERNAL_ERROR, "EXCEPT is not supported by Columnstore engine", gwi); + return ER_INTERNAL_ERROR; + } } } diff --git a/mysql-test/columnstore/bugfixes/MCOL-5699.result b/mysql-test/columnstore/bugfixes/MCOL-5699.result index d89cfe5c4..73e34fd00 100644 --- a/mysql-test/columnstore/bugfixes/MCOL-5699.result +++ b/mysql-test/columnstore/bugfixes/MCOL-5699.result @@ -4,7 +4,9 @@ USE mcol_5699 ; CREATE TABLE cs1(a text) ENGINE=columnstore; INSERT INTO cs1 VALUES('a'),('b'),('c'),('x'); CREATE TABLE cs2(a text) ENGINE=columnstore; -INSERT INTO cs1 VALUES('y'),('z'),('x'); +INSERT INTO cs2 VALUES('y'),('z'),('x'); +CREATE TABLE cs3(a text) ENGINE=columnstore; +INSERT INTO cs3 VALUES('r'),('t'),('z'); SELECT a from cs1 UNION ALL select a from cs2; a a @@ -30,4 +32,12 @@ SELECT a from cs1 EXCEPT ALL select a from cs2; ERROR HY000: Internal error: EXCEPT is not supported by Columnstore engine SELECT a from cs1 EXCEPT DISTINCT select a from cs2; ERROR HY000: Internal error: EXCEPT is not supported by Columnstore engine +SELECT a from cs1 UNION select a from cs2 INTERSECT ALL select a from cs3; +ERROR HY000: Internal error: INTERSECT is not supported by Columnstore engine +SELECT a from cs1 UNION select a from cs2 INTERSECT DISTINCT select a from cs3; +ERROR HY000: Internal error: INTERSECT is not supported by Columnstore engine +SELECT a from cs1 UNION select a from cs2 EXCEPT ALL select a from cs3; +ERROR HY000: Internal error: EXCEPT is not supported by Columnstore engine +SELECT a from cs1 UNION select a from cs2 EXCEPT DISTINCT select a from cs3; +ERROR HY000: Internal error: EXCEPT is not supported by Columnstore engine DROP DATABASE mcol_5699 ; diff --git a/mysql-test/columnstore/bugfixes/MCOL-5699.test b/mysql-test/columnstore/bugfixes/MCOL-5699.test index 6b7e25349..f2b04f2ca 100644 --- a/mysql-test/columnstore/bugfixes/MCOL-5699.test +++ b/mysql-test/columnstore/bugfixes/MCOL-5699.test @@ -8,7 +8,11 @@ CREATE TABLE cs1(a text) ENGINE=columnstore; INSERT INTO cs1 VALUES('a'),('b'),('c'),('x'); CREATE TABLE cs2(a text) ENGINE=columnstore; -INSERT INTO cs1 VALUES('y'),('z'),('x'); +INSERT INTO cs2 VALUES('y'),('z'),('x'); + +CREATE TABLE cs3(a text) ENGINE=columnstore; +INSERT INTO cs3 VALUES('r'),('t'),('z'); + SELECT a from cs1 UNION ALL select a from cs2; SELECT a from cs1 UNION DISTINCT select a from cs2; @@ -22,4 +26,14 @@ SELECT a from cs1 EXCEPT ALL select a from cs2; --ERROR 1815 SELECT a from cs1 EXCEPT DISTINCT select a from cs2; +--ERROR 1815 +SELECT a from cs1 UNION select a from cs2 INTERSECT ALL select a from cs3; +--ERROR 1815 +SELECT a from cs1 UNION select a from cs2 INTERSECT DISTINCT select a from cs3; +--ERROR 1815 +SELECT a from cs1 UNION select a from cs2 EXCEPT ALL select a from cs3; +--ERROR 1815 +SELECT a from cs1 UNION select a from cs2 EXCEPT DISTINCT select a from cs3; + + DROP DATABASE mcol_5699 ;