1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-29 08:21:15 +03:00

MCOL-4525 Implement columnstore_select_handler=AUTO.

This feature allows a query execution to fallback to the server,
in case query execution using the select_handler (SH) fails. In case
of fallback, a warning message containing the original reason for
query failure using SH is generated.

To accomplish this task, SH execution is moved to an earlier step when
we create the SH in create_columnstore_select_handler(), instead of the
previous call to SH execution in ha_columnstore_select_handler::init_scan().
This requires some pre-requisite steps that occur in the server in
JOIN::optimize() and JOIN::exec() to be performed before starting SH execution.

In addition, missing test cases from MCOL-424 are also added to the MTR suite,
and the corresponding fix using disable_indices_for_CEJ() is reverted back
since the original fix now appears to be redundant.
This commit is contained in:
Gagan Goel
2021-06-03 13:52:38 +00:00
parent 4ecd561878
commit e3d8100150
13 changed files with 1065 additions and 146 deletions

View File

@ -0,0 +1,33 @@
# MCOL-424
# Cross engine subquery losing where clause causing incorrect results
DROP DATABASE IF EXISTS mcol424;
CREATE DATABASE mcol424;
USE mcol424;
CREATE USER IF NOT EXISTS'cejuser'@'localhost' IDENTIFIED BY 'Vagrant1|0000001';
GRANT ALL PRIVILEGES ON *.* TO 'cejuser'@'localhost';
FLUSH PRIVILEGES;
CREATE TABLE `trans_test` (
`id` int(11) DEFAULT NULL,
`member_id` int(11) DEFAULT NULL,
`name` varchar(50) DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=latin1;
insert into `trans_test`(`id`,`member_id`,`name`) values (1,1,'trans 1');
insert into `trans_test`(`id`,`member_id`,`name`) values (2,2,'trans 2');
insert into `trans_test`(`id`,`member_id`,`name`) values (3,1,'trans 3');
insert into `trans_test`(`id`,`member_id`,`name`) values (4,2,'trans 4');
insert into `trans_test`(`id`,`member_id`,`name`) values (5,1,'trans 5');
CREATE TABLE `member_test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
insert into `member_test`(`id`,`name`) values (1,'member 1');
insert into `member_test`(`id`,`name`) values (2,'member 2');
insert into `member_test`(`id`,`name`) values (3,'member 3');
SELECT * FROM trans_test t WHERE t.`member_id` IN (SELECT id FROM member_test WHERE id =1);
id member_id name
1 1 trans 1
3 1 trans 3
5 1 trans 5
DROP USER 'cejuser'@'localhost';
DROP DATABASE mcol424;

View File

@ -0,0 +1,337 @@
# MCOL-4525
# Automatic select_handler
# columnstore_select_handler=AUTO allows query execution
# to fallback to the server, in case the execution using
# select_handler fails.
SET default_storage_engine=columnstore;
DROP DATABASE IF EXISTS mcol4525;
CREATE DATABASE mcol4525;
USE mcol4525;
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (1, 1), (5, 0);
SET columnstore_select_handler=ON;
SELECT a xor b FROM t1;
ERROR 42000: The storage engine for the table doesn't support IDB-2030: Predicate and Logic operators can not be used where an expression is expected.
SET columnstore_select_handler=AUTO;
SELECT a xor b FROM t1;
a xor b
0
1
SET columnstore_select_handler=ON;
SELECT DISTINCT a FROM t1 WHERE a IN (SELECT a FROM t1) OR a IN (SELECT a FROM t1);
ERROR HY000: Internal error: IDB-3033: Correlated subquery within OR operator is currently not supported.
SET columnstore_select_handler=AUTO;
SELECT DISTINCT a FROM t1 WHERE a IN (SELECT a FROM t1) OR a IN (SELECT a FROM t1);
a
1
5
DROP TABLE t1;
CREATE TABLE bug4767 (c1 float, c2 double);
INSERT INTO bug4767 VALUES (1.234, 3.4556), (2.3345456, 2.3345456);
SET columnstore_select_handler=ON;
SELECT * FROM bug4767 a JOIN bug4767 b ON (a.c1=b.c2);
ERROR HY000: Internal error: IDB-1002: 'a' and 'b' have incompatible column type specified for join condition.
SET columnstore_select_handler=AUTO;
SELECT * FROM bug4767 a JOIN bug4767 b ON (a.c1=b.c2);
c1 c2 c1 c2
DROP TABLE bug4767;
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1), (2);
CREATE TABLE t2 (b int);
INSERT INTO t2 VALUES (2);
SET columnstore_select_handler=ON;
SELECT a FROM t1 WHERE a IN (SELECT a FROM t2);
ERROR HY000: Internal error: IDB-1000: 't1' and 't2' are not joined.
SET columnstore_select_handler=AUTO;
SELECT a FROM t1 WHERE a IN (SELECT a FROM t2);
a
1
2
DROP TABLE t1;
DROP TABLE t2;
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1), (2), (3);
CREATE TABLE t2 (a int);
INSERT INTO t2 VALUES (2), (3);
CREATE TABLE t3 (a int);
INSERT INTO t3 VALUES (3);
SET columnstore_select_handler=ON;
SELECT * FROM t1 JOIN t2 ON t1.a=t2.a JOIN t3 ON t2.a=t3.a AND t3.a=t1.a;
ERROR HY000: Internal error: IDB-1003: Circular joins are not supported.
SET columnstore_select_handler=AUTO;
SELECT * FROM t1 JOIN t2 ON t1.a=t2.a JOIN t3 ON t2.a=t3.a AND t3.a=t1.a;
a a a
3 3 3
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
CREATE TABLE l(c1 int, c2 int);
CREATE TABLE r(c1 int, c2 int);
CREATE TABLE s(c1 int, c2 int);
INSERT INTO l VALUES (1, 1);
INSERT INTO l VALUES (2, 2);
INSERT INTO r VALUES (1, 1);
INSERT INTO r VALUES (5, 5);
INSERT INTO s VALUES (1, 1);
INSERT INTO s VALUES (9, 9);
SET columnstore_select_handler=ON;
SELECT 'q1', l.c1, r.c1 FROM l LEFT JOIN r ON l.c1 = r.c1 AND l.c1 IN (SELECT c1 FROM s) ORDER BY 1, 2, 3;
ERROR HY000: Internal error: IDB-1015: Subquery on OUTER JOIN ON clause is currently not supported.
SET columnstore_select_handler=AUTO;
SELECT 'q1', l.c1, r.c1 FROM l LEFT JOIN r ON l.c1 = r.c1 AND l.c1 IN (SELECT c1 FROM s) ORDER BY 1, 2, 3;
q1 c1 c1
q1 1 1
q1 2 NULL
DROP TABLE l;
DROP TABLE r;
DROP TABLE s;
CREATE TABLE t1 (col1 int, col2 varchar(5), col_t1 int);
INSERT INTO t1 VALUES(10,'hello',10);
INSERT INTO t1 VALUES(20,'hello',20);
INSERT INTO t1 VALUES(30,'hello',30);
INSERT INTO t1 VALUES(10,'bye',10);
INSERT INTO t1 VALUES(10,'sam',10);
INSERT INTO t1 VALUES(10,'bob',10);
SET columnstore_select_handler=ON;
SELECT SUM(col1) AS col2 FROM t1 GROUP BY col2;
ERROR 42000: The storage engine for the table doesn't support IDB-2016: Non supported item 'col2' on the GROUP BY list.
SELECT col1 c FROM t1 ORDER BY AVG(col1);
ERROR HY000: Internal error: IDB-2021: 'c' is not in GROUP BY clause. All non-aggregate columns in the SELECT and ORDER BY clause must be included in the GROUP BY clause.
SET columnstore_select_handler=AUTO;
SELECT SUM(col1) AS col2 FROM t1 GROUP BY col2;
col2
10
10
60
10
SELECT col1 c FROM t1 ORDER BY AVG(col1);
c
10
DROP TABLE t1;
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1);
SET columnstore_select_handler=ON;
SELECT minute(sleep(a)) FROM t1;
ERROR 42000: The storage engine for the table doesn't support IDB-1001: Function 'minute' isn't supported.
SET columnstore_select_handler=AUTO;
SELECT minute(sleep(a)) FROM t1;
minute(sleep(a))
0
DROP TABLE t1;
CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int);
INSERT INTO t1 VALUES (1), (2);
INSERT INTO t2 VALUES (2), (3);
SET columnstore_select_handler=ON;
SELECT SUM(a) FROM t1 WHERE EXISTS (SELECT MAX(a) FROM t2);
ERROR HY000: Internal error: IDB-3008: Aggregate function in EXISTS subquery is currently not supported.
SELECT * FROM t1 WHERE (a,a) < (SELECT a,a FROM t2 WHERE a=2);
ERROR HY000: Internal error: IDB-3006: This operator cannot be used with lists.
SET columnstore_select_handler=AUTO;
SELECT SUM(a) FROM t1 WHERE EXISTS (SELECT MAX(a) FROM t2);
SUM(a)
3
SELECT * FROM t1 WHERE (a,a) < (SELECT a,a FROM t2 WHERE a=2);
a
1
DROP TABLE t1;
DROP TABLE t2;
CREATE TABLE gen (i int, i2 int);
INSERT INTO gen VALUES (1,0), (1,1), (1,2), (1,3), (1,4), (1,5), (1,6), (1,7), (1,8), (1,9);
SET columnstore_select_handler=ON;
SELECT i2, (SELECT MAX(g2.i2) FROM gen g2 WHERE g2.i = g1.i AND g2.i2 > g1.i2) sub FROM gen g1;
ERROR HY000: Internal error: IDB-3035: Not equal comparison between a column within a subquery with an aggregate result and a column outside of the subquery is not supported.
SET columnstore_select_handler=AUTO;
SELECT i2, (SELECT MAX(g2.i2) FROM gen g2 WHERE g2.i = g1.i AND g2.i2 > g1.i2) sub FROM gen g1;
i2 sub
0 9
1 9
2 9
3 9
4 9
5 9
6 9
7 9
8 9
9 NULL
DROP TABLE gen;
CREATE TABLE t1(a int);
INSERT INTO t1 VALUES (0), (1), (2), (3);
CREATE TABLE t2 (a int);
INSERT INTO t2 VALUES (2), (3);
CREATE VIEW v1 AS SELECT a FROM t1 WHERE a > 1;
SET columnstore_select_handler=ON;
SELECT * FROM t1 LEFT JOIN (t2 AS t, v1) ON v1.a=t1.a ORDER BY 1;
ERROR HY000: Internal error: IDB-1000: 'v1, t1' and 't' are not joined.
SET columnstore_select_handler=AUTO;
SELECT * FROM t1 LEFT JOIN (t2 AS t, v1) ON v1.a=t1.a ORDER BY 1;
a a a
0 NULL NULL
1 NULL NULL
2 2 2
2 3 2
3 2 3
3 3 3
DROP TABLE t1;
DROP TABLE t2;
DROP VIEW v1;
CREATE TABLE c1 (a int);
INSERT INTO c1 VALUES (1), (2), (3);
CREATE TABLE c2 (a int);
INSERT INTO c2 VALUES (2);
CREATE TABLE c3 (a int);
CREATE TABLE c4 (a int);
CREATE TABLE c5 (a int);
SET columnstore_select_handler=ON;
SELECT c1.a AS col1, c2.a AS col2, c1.a xor c2.a FROM
c1 LEFT JOIN
(
(c2 LEFT JOIN c3 ON c2.a=c3.a) LEFT JOIN
(c4 JOIN c5 ON c4.a=c5.a)
ON c2.a=c4.a
)
ON c1.a=c2.a WHERE c2.a < 100;
ERROR 42000: The storage engine for the table doesn't support IDB-2030: Predicate and Logic operators can not be used where an expression is expected.
SET columnstore_select_handler=AUTO;
SELECT c1.a AS col1, c2.a AS col2, c1.a xor c2.a FROM
c1 LEFT JOIN
(
(c2 LEFT JOIN c3 ON c2.a=c3.a) LEFT JOIN
(c4 JOIN c5 ON c4.a=c5.a)
ON c2.a=c4.a
)
ON c1.a=c2.a WHERE c2.a < 100;
col1 col2 c1.a xor c2.a
2 2 0
DROP TABLE c1;
DROP TABLE c2;
DROP TABLE c3;
DROP TABLE c4;
DROP TABLE c5;
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1), (2), (3), (4);
SET columnstore_select_handler=ON;
PREPARE stmt FROM "SELECT a, a xor 0 FROM t1 WHERE a > 1 AND a < 4";
EXECUTE stmt;
ERROR 42000: The storage engine for the table doesn't support IDB-2030: Predicate and Logic operators can not be used where an expression is expected.
EXECUTE stmt;
ERROR 42000: The storage engine for the table doesn't support IDB-2030: Predicate and Logic operators can not be used where an expression is expected.
EXECUTE stmt;
ERROR 42000: The storage engine for the table doesn't support IDB-2030: Predicate and Logic operators can not be used where an expression is expected.
EXECUTE stmt;
ERROR 42000: The storage engine for the table doesn't support IDB-2030: Predicate and Logic operators can not be used where an expression is expected.
DROP PREPARE stmt;
SET columnstore_select_handler=AUTO;
PREPARE stmt FROM "SELECT a, a xor 0 FROM t1 WHERE a > 1 AND a < 4";
EXECUTE stmt;
a a xor 0
2 1
3 1
EXECUTE stmt;
a a xor 0
2 1
3 1
EXECUTE stmt;
a a xor 0
2 1
3 1
EXECUTE stmt;
a a xor 0
2 1
3 1
EXECUTE stmt;
a a xor 0
2 1
3 1
DROP PREPARE stmt;
SET columnstore_select_handler=ON;
CREATE PROCEDURE mcol4525_proc()
BEGIN
SELECT a, a xor 0 FROM t1 WHERE a > 1 AND a < 4;
END
//
CALL mcol4525_proc();
ERROR 42000: The storage engine for the table doesn't support IDB-2030: Predicate and Logic operators can not be used where an expression is expected.
CALL mcol4525_proc();
ERROR 42000: The storage engine for the table doesn't support IDB-2030: Predicate and Logic operators can not be used where an expression is expected.
CALL mcol4525_proc();
ERROR 42000: The storage engine for the table doesn't support IDB-2030: Predicate and Logic operators can not be used where an expression is expected.
DROP PROCEDURE mcol4525_proc;
SET columnstore_select_handler=AUTO;
CREATE PROCEDURE mcol4525_proc()
BEGIN
SELECT a, a xor 0 FROM t1 WHERE a > 1 AND a < 4;
END
//
CALL mcol4525_proc();
a a xor 0
2 1
3 1
CALL mcol4525_proc();
a a xor 0
2 1
3 1
CALL mcol4525_proc();
a a xor 0
2 1
3 1
DROP PROCEDURE mcol4525_proc;
DROP TABLE t1;
CREATE TABLE `giorno` (
`giorno` date NOT NULL DEFAULT '0000-00-00',
`giornoa` mediumint(7) DEFAULT NULL,
`mese` mediumint(6) DEFAULT NULL,
`settimana` mediumint(6) DEFAULT NULL,
`quindicina` mediumint(6) DEFAULT NULL,
`trimestre` smallint(5) DEFAULT NULL,
`quadrimestre` smallint(5) DEFAULT NULL,
`semestre` smallint(5) DEFAULT NULL,
`bimestre` smallint(5) DEFAULT NULL,
`anno` smallint(4) DEFAULT NULL,
PRIMARY KEY (`giorno`),
KEY `mese` (`mese`),
KEY `quindicina` (`quindicina`),
KEY `settimana` (`settimana`),
KEY `trimestre` (`trimestre`),
KEY `semestre` (`semestre`),
KEY `bimestre` (`bimestre`),
KEY `quadrimestre` (`quadrimestre`),
KEY `giornoa` (`giornoa`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Giorni';
CREATE TABLE `campagna_web_codice` (
`cwc_id` int(11) DEFAULT NULL,
`cwc_cw_id` int(11) DEFAULT NULL,
`cwc_cd_id` int(11) DEFAULT NULL,
`cwc_codice` varchar(30) DEFAULT NULL,
`cwc_va_id` int(11) DEFAULT NULL,
`cwc_prezzo` decimal(12,2) DEFAULT NULL,
`cwc_prezzoListino` decimal(12,2) DEFAULT NULL,
`cwc_prezzoSpedizione` decimal(8,2) DEFAULT NULL,
`cwc_in_id` int(11) DEFAULT NULL,
`cwc_na_id` int(11) DEFAULT NULL,
`cwc_desc` varchar(100) DEFAULT NULL,
`cwc_datainizio` date DEFAULT NULL,
`cwc_datafine` date DEFAULT NULL,
`cwc_mo_id` int(11) DEFAULT NULL,
`cwc_ma_id` int(11) DEFAULT NULL,
`cwc_pd_id` int(11) DEFAULT NULL,
`cwc_set_id` int(11) DEFAULT NULL,
`cwc_mr_id` int(11) DEFAULT NULL,
`cwc_ca_id` int(11) DEFAULT NULL,
`cwc_fa_id` int(11) DEFAULT NULL,
`cwc_ti_id` int(11) DEFAULT NULL,
`cwc_azws` varchar(255) DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=utf8;
SET columnstore_select_handler=ON;
SELECT COUNT(DISTINCT cwc_id) npres,COUNT(DISTINCT cwc_cw_id) ncw,cwc_in_id insegna
FROM (giorno,campagna_web_codice)
WHERE cwc_fa_id IN (23) AND giorno BETWEEN cwc_datainizio AND cwc_datafine AND mese IN (202009)
GROUP BY insegna;
ERROR HY000: Internal error: IDB-1000: 'giorno' and 'campagna_web_codice' are not joined.
SET columnstore_select_handler=AUTO;
SELECT COUNT(DISTINCT cwc_id) npres,COUNT(DISTINCT cwc_cw_id) ncw,cwc_in_id insegna
FROM (giorno,campagna_web_codice)
WHERE cwc_fa_id IN (23) AND giorno BETWEEN cwc_datainizio AND cwc_datafine AND mese IN (202009)
GROUP BY insegna;
npres ncw insegna
DROP DATABASE mcol4525;

View File

@ -0,0 +1,62 @@
--source ../include/have_columnstore.inc
--echo # MCOL-424
--echo # Cross engine subquery losing where clause causing incorrect results
if (!$MASTER_MYPORT)
{
# Running with --extern
let $MASTER_MYPORT=`SELECT @@port`;
}
--disable_warnings
DROP DATABASE IF EXISTS mcol424;
--enable_warnings
CREATE DATABASE mcol424;
USE mcol424;
#
# Enable cross engine join
# Configure user and password in Columnstore.xml file
#
--exec $MCS_MCSSETCONFIG CrossEngineSupport User 'cejuser'
--exec $MCS_MCSSETCONFIG CrossEngineSupport Password 'Vagrant1|0000001'
--exec $MCS_MCSSETCONFIG CrossEngineSupport Port $MASTER_MYPORT
#
# Create corresponding in the server
#
--disable_warnings
CREATE USER IF NOT EXISTS'cejuser'@'localhost' IDENTIFIED BY 'Vagrant1|0000001';
--enable_warnings
GRANT ALL PRIVILEGES ON *.* TO 'cejuser'@'localhost';
FLUSH PRIVILEGES;
CREATE TABLE `trans_test` (
`id` int(11) DEFAULT NULL,
`member_id` int(11) DEFAULT NULL,
`name` varchar(50) DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=latin1;
insert into `trans_test`(`id`,`member_id`,`name`) values (1,1,'trans 1');
insert into `trans_test`(`id`,`member_id`,`name`) values (2,2,'trans 2');
insert into `trans_test`(`id`,`member_id`,`name`) values (3,1,'trans 3');
insert into `trans_test`(`id`,`member_id`,`name`) values (4,2,'trans 4');
insert into `trans_test`(`id`,`member_id`,`name`) values (5,1,'trans 5');
CREATE TABLE `member_test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
insert into `member_test`(`id`,`name`) values (1,'member 1');
insert into `member_test`(`id`,`name`) values (2,'member 2');
insert into `member_test`(`id`,`name`) values (3,'member 3');
SELECT * FROM trans_test t WHERE t.`member_id` IN (SELECT id FROM member_test WHERE id =1);
# Clean UP
DROP USER 'cejuser'@'localhost';
DROP DATABASE mcol424;

View File

@ -0,0 +1,312 @@
--source ../include/have_columnstore.inc
--echo # MCOL-4525
--echo # Automatic select_handler
--echo # columnstore_select_handler=AUTO allows query execution
--echo # to fallback to the server, in case the execution using
--echo # select_handler fails.
SET default_storage_engine=columnstore;
--disable_warnings
DROP DATABASE IF EXISTS mcol4525;
CREATE DATABASE mcol4525;
USE mcol4525;
# Test case from working_tpch1/qa_fe_cnxFunctions/xor.sql.negative.sql
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (1, 1), (5, 0);
SET columnstore_select_handler=ON;
--error 1178
SELECT a xor b FROM t1;
SET columnstore_select_handler=AUTO;
SELECT a xor b FROM t1;
# Test case from MCOL-428
# This also tests in-to-exists predicate creation and injection
SET columnstore_select_handler=ON;
--error 1815
SELECT DISTINCT a FROM t1 WHERE a IN (SELECT a FROM t1) OR a IN (SELECT a FROM t1);
SET columnstore_select_handler=AUTO;
SELECT DISTINCT a FROM t1 WHERE a IN (SELECT a FROM t1) OR a IN (SELECT a FROM t1);
DROP TABLE t1;
# Test case from working_tpch1/misc/bug4767.negative.sql
CREATE TABLE bug4767 (c1 float, c2 double);
INSERT INTO bug4767 VALUES (1.234, 3.4556), (2.3345456, 2.3345456);
SET columnstore_select_handler=ON;
--error 1815
SELECT * FROM bug4767 a JOIN bug4767 b ON (a.c1=b.c2);
SET columnstore_select_handler=AUTO;
SELECT * FROM bug4767 a JOIN bug4767 b ON (a.c1=b.c2);
DROP TABLE bug4767;
# Test case from working_tpch1/misc/bug5126.negative.sql
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1), (2);
CREATE TABLE t2 (b int);
INSERT INTO t2 VALUES (2);
SET columnstore_select_handler=ON;
--error 1815
SELECT a FROM t1 WHERE a IN (SELECT a FROM t2);
SET columnstore_select_handler=AUTO;
SELECT a FROM t1 WHERE a IN (SELECT a FROM t2);
DROP TABLE t1;
DROP TABLE t2;
# Test case for MCOL-1205 Circular Joins not supported
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1), (2), (3);
CREATE TABLE t2 (a int);
INSERT INTO t2 VALUES (2), (3);
CREATE TABLE t3 (a int);
INSERT INTO t3 VALUES (3);
SET columnstore_select_handler=ON;
--error 1815
SELECT * FROM t1 JOIN t2 ON t1.a=t2.a JOIN t3 ON t2.a=t3.a AND t3.a=t1.a;
SET columnstore_select_handler=AUTO;
SELECT * FROM t1 JOIN t2 ON t1.a=t2.a JOIN t3 ON t2.a=t3.a AND t3.a=t1.a;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;
# Test case from working_tpch1_compareLogOnly/onClauseJoins/03.sql
CREATE TABLE l(c1 int, c2 int);
CREATE TABLE r(c1 int, c2 int);
CREATE TABLE s(c1 int, c2 int);
INSERT INTO l VALUES (1, 1);
INSERT INTO l VALUES (2, 2);
INSERT INTO r VALUES (1, 1);
INSERT INTO r VALUES (5, 5);
INSERT INTO s VALUES (1, 1);
INSERT INTO s VALUES (9, 9);
SET columnstore_select_handler=ON;
--error 1815
SELECT 'q1', l.c1, r.c1 FROM l LEFT JOIN r ON l.c1 = r.c1 AND l.c1 IN (SELECT c1 FROM s) ORDER BY 1, 2, 3;
SET columnstore_select_handler=AUTO;
SELECT 'q1', l.c1, r.c1 FROM l LEFT JOIN r ON l.c1 = r.c1 AND l.c1 IN (SELECT c1 FROM s) ORDER BY 1, 2, 3;
DROP TABLE l;
DROP TABLE r;
DROP TABLE s;
# Test case from working_tpch1_compareLogOnly/having/having_mysql.sql
CREATE TABLE t1 (col1 int, col2 varchar(5), col_t1 int);
INSERT INTO t1 VALUES(10,'hello',10);
INSERT INTO t1 VALUES(20,'hello',20);
INSERT INTO t1 VALUES(30,'hello',30);
INSERT INTO t1 VALUES(10,'bye',10);
INSERT INTO t1 VALUES(10,'sam',10);
INSERT INTO t1 VALUES(10,'bob',10);
SET columnstore_select_handler=ON;
--error 1178
SELECT SUM(col1) AS col2 FROM t1 GROUP BY col2;
--error 1815
SELECT col1 c FROM t1 ORDER BY AVG(col1);
SET columnstore_select_handler=AUTO;
SELECT SUM(col1) AS col2 FROM t1 GROUP BY col2;
SELECT col1 c FROM t1 ORDER BY AVG(col1);
DROP TABLE t1;
# Test case from working_tpch1_compareLogOnly/misc/bug2891_negative.sql
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1);
SET columnstore_select_handler=ON;
--error 1178
SELECT minute(sleep(a)) FROM t1;
SET columnstore_select_handler=AUTO;
SELECT minute(sleep(a)) FROM t1;
DROP TABLE t1;
# Test case from working_tpch1_compareLogOnly/sub/g3_simple_semi_join.negative.sql
CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int);
INSERT INTO t1 VALUES (1), (2);
INSERT INTO t2 VALUES (2), (3);
SET columnstore_select_handler=ON;
--error 1815
SELECT SUM(a) FROM t1 WHERE EXISTS (SELECT MAX(a) FROM t2);
# Test case from working_tpch1_compareLogOnly/sub/g2_simple_scalar.negative.sql
--error 1815
SELECT * FROM t1 WHERE (a,a) < (SELECT a,a FROM t2 WHERE a=2);
SET columnstore_select_handler=AUTO;
SELECT SUM(a) FROM t1 WHERE EXISTS (SELECT MAX(a) FROM t2);
SELECT * FROM t1 WHERE (a,a) < (SELECT a,a FROM t2 WHERE a=2);
DROP TABLE t1;
DROP TABLE t2;
# Test case from working_tpch1_compareLogOnly/sub/bug3767.sql
CREATE TABLE gen (i int, i2 int);
INSERT INTO gen VALUES (1,0), (1,1), (1,2), (1,3), (1,4), (1,5), (1,6), (1,7), (1,8), (1,9);
SET columnstore_select_handler=ON;
--error 1815
SELECT i2, (SELECT MAX(g2.i2) FROM gen g2 WHERE g2.i = g1.i AND g2.i2 > g1.i2) sub FROM gen g1;
SET columnstore_select_handler=AUTO;
SELECT i2, (SELECT MAX(g2.i2) FROM gen g2 WHERE g2.i = g1.i AND g2.i2 > g1.i2) sub FROM gen g1;
DROP TABLE gen;
# Test case from working_tpch1_compareLogOnly/view/mts_view.30.sql
CREATE TABLE t1(a int);
INSERT INTO t1 VALUES (0), (1), (2), (3);
CREATE TABLE t2 (a int);
INSERT INTO t2 VALUES (2), (3);
CREATE VIEW v1 AS SELECT a FROM t1 WHERE a > 1;
SET columnstore_select_handler=ON;
--error 1815
SELECT * FROM t1 LEFT JOIN (t2 AS t, v1) ON v1.a=t1.a ORDER BY 1;
SET columnstore_select_handler=AUTO;
SELECT * FROM t1 LEFT JOIN (t2 AS t, v1) ON v1.a=t1.a ORDER BY 1;
DROP TABLE t1;
DROP TABLE t2;
DROP VIEW v1;
# Modified test case from MCOL-4680:
# FROM subquery containing nested joins returns an error
CREATE TABLE c1 (a int);
INSERT INTO c1 VALUES (1), (2), (3);
CREATE TABLE c2 (a int);
INSERT INTO c2 VALUES (2);
CREATE TABLE c3 (a int);
CREATE TABLE c4 (a int);
CREATE TABLE c5 (a int);
SET columnstore_select_handler=ON;
--error 1178
SELECT c1.a AS col1, c2.a AS col2, c1.a xor c2.a FROM
c1 LEFT JOIN
(
(c2 LEFT JOIN c3 ON c2.a=c3.a) LEFT JOIN
(c4 JOIN c5 ON c4.a=c5.a)
ON c2.a=c4.a
)
ON c1.a=c2.a WHERE c2.a < 100;
SET columnstore_select_handler=AUTO;
SELECT c1.a AS col1, c2.a AS col2, c1.a xor c2.a FROM
c1 LEFT JOIN
(
(c2 LEFT JOIN c3 ON c2.a=c3.a) LEFT JOIN
(c4 JOIN c5 ON c4.a=c5.a)
ON c2.a=c4.a
)
ON c1.a=c2.a WHERE c2.a < 100;
DROP TABLE c1;
DROP TABLE c2;
DROP TABLE c3;
DROP TABLE c4;
DROP TABLE c5;
# Test case for prepared statements
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1), (2), (3), (4);
SET columnstore_select_handler=ON;
PREPARE stmt FROM "SELECT a, a xor 0 FROM t1 WHERE a > 1 AND a < 4";
--error 1178
EXECUTE stmt;
--error 1178
EXECUTE stmt;
--error 1178
EXECUTE stmt;
--error 1178
EXECUTE stmt;
DROP PREPARE stmt;
SET columnstore_select_handler=AUTO;
PREPARE stmt FROM "SELECT a, a xor 0 FROM t1 WHERE a > 1 AND a < 4";
EXECUTE stmt;
EXECUTE stmt;
EXECUTE stmt;
EXECUTE stmt;
EXECUTE stmt;
DROP PREPARE stmt;
# Test case for stored procedures
SET columnstore_select_handler=ON;
delimiter //;
CREATE PROCEDURE mcol4525_proc()
BEGIN
SELECT a, a xor 0 FROM t1 WHERE a > 1 AND a < 4;
END
//
delimiter ;//
--error 1178
CALL mcol4525_proc();
--error 1178
CALL mcol4525_proc();
--error 1178
CALL mcol4525_proc();
DROP PROCEDURE mcol4525_proc;
SET columnstore_select_handler=AUTO;
delimiter //;
CREATE PROCEDURE mcol4525_proc()
BEGIN
SELECT a, a xor 0 FROM t1 WHERE a > 1 AND a < 4;
END
//
delimiter ;//
CALL mcol4525_proc();
CALL mcol4525_proc();
CALL mcol4525_proc();
DROP PROCEDURE mcol4525_proc;
DROP TABLE t1;
# Test case taken verbatim from MCOL-4525 issue description
CREATE TABLE `giorno` (
`giorno` date NOT NULL DEFAULT '0000-00-00',
`giornoa` mediumint(7) DEFAULT NULL,
`mese` mediumint(6) DEFAULT NULL,
`settimana` mediumint(6) DEFAULT NULL,
`quindicina` mediumint(6) DEFAULT NULL,
`trimestre` smallint(5) DEFAULT NULL,
`quadrimestre` smallint(5) DEFAULT NULL,
`semestre` smallint(5) DEFAULT NULL,
`bimestre` smallint(5) DEFAULT NULL,
`anno` smallint(4) DEFAULT NULL,
PRIMARY KEY (`giorno`),
KEY `mese` (`mese`),
KEY `quindicina` (`quindicina`),
KEY `settimana` (`settimana`),
KEY `trimestre` (`trimestre`),
KEY `semestre` (`semestre`),
KEY `bimestre` (`bimestre`),
KEY `quadrimestre` (`quadrimestre`),
KEY `giornoa` (`giornoa`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Giorni';
CREATE TABLE `campagna_web_codice` (
`cwc_id` int(11) DEFAULT NULL,
`cwc_cw_id` int(11) DEFAULT NULL,
`cwc_cd_id` int(11) DEFAULT NULL,
`cwc_codice` varchar(30) DEFAULT NULL,
`cwc_va_id` int(11) DEFAULT NULL,
`cwc_prezzo` decimal(12,2) DEFAULT NULL,
`cwc_prezzoListino` decimal(12,2) DEFAULT NULL,
`cwc_prezzoSpedizione` decimal(8,2) DEFAULT NULL,
`cwc_in_id` int(11) DEFAULT NULL,
`cwc_na_id` int(11) DEFAULT NULL,
`cwc_desc` varchar(100) DEFAULT NULL,
`cwc_datainizio` date DEFAULT NULL,
`cwc_datafine` date DEFAULT NULL,
`cwc_mo_id` int(11) DEFAULT NULL,
`cwc_ma_id` int(11) DEFAULT NULL,
`cwc_pd_id` int(11) DEFAULT NULL,
`cwc_set_id` int(11) DEFAULT NULL,
`cwc_mr_id` int(11) DEFAULT NULL,
`cwc_ca_id` int(11) DEFAULT NULL,
`cwc_fa_id` int(11) DEFAULT NULL,
`cwc_ti_id` int(11) DEFAULT NULL,
`cwc_azws` varchar(255) DEFAULT NULL
) ENGINE=Columnstore DEFAULT CHARSET=utf8;
SET columnstore_select_handler=ON;
--error 1815
SELECT COUNT(DISTINCT cwc_id) npres,COUNT(DISTINCT cwc_cw_id) ncw,cwc_in_id insegna
FROM (giorno,campagna_web_codice)
WHERE cwc_fa_id IN (23) AND giorno BETWEEN cwc_datainizio AND cwc_datafine AND mese IN (202009)
GROUP BY insegna;
SET columnstore_select_handler=AUTO;
SELECT COUNT(DISTINCT cwc_id) npres,COUNT(DISTINCT cwc_cw_id) ncw,cwc_in_id insegna
FROM (giorno,campagna_web_codice)
WHERE cwc_fa_id IN (23) AND giorno BETWEEN cwc_datainizio AND cwc_datafine AND mese IN (202009)
GROUP BY insegna;
DROP DATABASE mcol4525;
--enable_warnings