Commit 860c1ca9 authored by Yuchen Pei's avatar Yuchen Pei

MDEV-33679 Spider group by handler: skip on multiple equalities

The spider group by handler is created in
JOIN::make_aggr_tables_info(), by which time calls to
substitute_for_best_equal_field() should have already removed all the
multiple equalities (i.e. Item_equal, with MULT_EQUAL_FUNC func_type).
Therefore, if there is still such items, it is deemed as an optimizer
bug and should be skipped.
parent 9c93d41a
#
# MDEV-33679 spider returns parsing failure on valid left join select by translating the on expression to ()
#
for master_1
for child2
for child3
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE `t1` (`c` INT(10) UNSIGNED NOT NULL, `b` VARCHAR(255) NOT NULL , PRIMARY KEY (`c`) USING BTREE ) ENGINE=MYISAM;
CREATE TABLE `t2` (`a` INT(10) UNSIGNED NOT NULL, `c` INT(10) UNSIGNED NOT NULL ) ENGINE=MYISAM;
SET spider_same_server_link= on;
CREATE TABLE `t1_spider` (`c` INT(10) UNSIGNED NOT NULL, `b` VARCHAR(255) NOT NULL , PRIMARY KEY (`c`) USING BTREE ) COMMENT='wrapper "mysql",srv "srv", table "t1"' ENGINE=SPIDER;
CREATE TABLE `t2_spider` (`a` INT(10) UNSIGNED NOT NULL, `c` INT(10) UNSIGNED NOT NULL
, PRIMARY KEY (`a`) USING BTREE
) COMMENT='wrapper "mysql",srv "srv",table "t2"' ENGINE=SPIDER;
INSERT INTO t1_spider VALUES(1,'oooo');
INSERT INTO t2_spider VALUES(1,1);
SELECT t2_spider.a,t1_spider.c FRoM t2_spider LEFT join t1_spider ON (t2_spider.c = t1_spider.c) WHERE t2_spider.a = 1;
a c
1 1
Warnings:
Warning 1815 Internal error: Spider group by handler: Encountered multiple equalities, likely an optimizer bug
drop table t1, t2, t1_spider, t2_spider;
drop server srv;
for master_1
for child2
for child3
--echo #
--echo # MDEV-33679 spider returns parsing failure on valid left join select by translating the on expression to ()
--echo #
--disable_query_log
--disable_result_log
--source ../../t/test_init.inc
--enable_result_log
--enable_query_log
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
CREATE TABLE `t1` (`c` INT(10) UNSIGNED NOT NULL, `b` VARCHAR(255) NOT NULL , PRIMARY KEY (`c`) USING BTREE ) ENGINE=MYISAM;
CREATE TABLE `t2` (`a` INT(10) UNSIGNED NOT NULL, `c` INT(10) UNSIGNED NOT NULL ) ENGINE=MYISAM;
SET spider_same_server_link= on;
CREATE TABLE `t1_spider` (`c` INT(10) UNSIGNED NOT NULL, `b` VARCHAR(255) NOT NULL , PRIMARY KEY (`c`) USING BTREE ) COMMENT='wrapper "mysql",srv "srv", table "t1"' ENGINE=SPIDER;
CREATE TABLE `t2_spider` (`a` INT(10) UNSIGNED NOT NULL, `c` INT(10) UNSIGNED NOT NULL
, PRIMARY KEY (`a`) USING BTREE
) COMMENT='wrapper "mysql",srv "srv",table "t2"' ENGINE=SPIDER;
INSERT INTO t1_spider VALUES(1,'oooo');
INSERT INTO t2_spider VALUES(1,1);
SELECT t2_spider.a,t1_spider.c FRoM t2_spider LEFT join t1_spider ON (t2_spider.c = t1_spider.c) WHERE t2_spider.a = 1;
drop table t1, t2, t1_spider, t2_spider;
drop server srv;
--disable_query_log
--disable_result_log
--source ../../t/test_deinit.inc
--enable_result_log
--enable_query_log
......@@ -5566,6 +5566,17 @@ int spider_db_mbase_util::check_item_func(
if (spider_db_check_ft_idx(item_func, spider) == MAX_KEY)
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
break;
case Item_func::MULT_EQUAL_FUNC:
/* If there is still Item_equal by the time of
JOIN::make_aggr_tables_info() where the spider group by handler
is created, it indicates a bug in the optimizer, because there
shouldn't be any. */
push_warning_printf(
spider->trx->thd, SPIDER_WARN_LEVEL_WARN, ER_INTERNAL_ERROR,
ER_THD(spider->trx->thd, ER_INTERNAL_ERROR),
"Spider group by handler: Encountered multiple equalities, likely "
"an optimizer bug");
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
default:
break;
}
......@@ -6492,6 +6503,17 @@ int spider_db_mbase_util::print_item_func(
last_str = SPIDER_SQL_CLOSE_PAREN_STR;
last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN;
break;
case Item_func::MULT_EQUAL_FUNC:
/* If there is still Item_equal by the time of
JOIN::make_aggr_tables_info() where the spider group by handler
is created, it indicates a bug in the optimizer, because there
shouldn't be any. */
push_warning_printf(
spider->trx->thd, SPIDER_WARN_LEVEL_WARN, ER_INTERNAL_ERROR,
ER_THD(spider->trx->thd, ER_INTERNAL_ERROR),
"Spider group by handler: Encountered multiple equalities, likely "
"an optimizer bug");
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
default:
THD *thd = spider->trx->thd;
SPIDER_SHARE *share = spider->share;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment