Commit 02b7735b authored by Monty's avatar Monty

MDEV-30310 Assertion failure in best_access_path upon IN exceeding...

MDEV-30310 Assertion failure in best_access_path upon IN exceeding IN_PREDICATE_CONVERSION_THRESHOLD, derived_with_keys=off

The bug was some old code that, without any explanation, reset
PART_KEY_FLAG from fields in temporary tables. This caused
join_tab->key_dependent to not be updated properly, which caused
an assert.
parent 4be0bfad
......@@ -1419,5 +1419,24 @@ A
1
drop table t1, duplicates_tbl;
#
# MDEV-30310
# Assertion failure in best_access_path upon IN exceeding
# IN_PREDICATE_CONVERSION_THRESHOLD, derived_with_keys=off
#
CREATE TABLE t1 (l_orderkey int);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (o_orderkey int);
INSERT INTO t2 VALUES (3),(4);
SET IN_PREDICATE_CONVERSION_THRESHOLD= 2;
SET OPTIMIZER_SWITCH='derived_with_keys=on';
SELECT * FROM t1 JOIN t2 ON (l_orderkey = o_orderkey) WHERE l_orderkey IN (1, 2, 3);
l_orderkey o_orderkey
SET OPTIMIZER_SWITCH='derived_with_keys=off';
SELECT * FROM t1 JOIN t2 ON (l_orderkey = o_orderkey) WHERE l_orderkey IN (1, 2, 3);
l_orderkey o_orderkey
SET @@IN_PREDICATE_CONVERSION_THRESHOLD=@@global.IN_PREDICATE_CONVERSION_THRESHOLD;
SET @@OPTIMIZER_SWITCH=@@global.OPTIMIZER_SWITCH;
DROP TABLE t1, t2;
#
# End of 11.0 tests
#
......@@ -1205,6 +1205,25 @@ from t1;
drop table t1, duplicates_tbl;
--echo #
--echo # MDEV-30310
--echo # Assertion failure in best_access_path upon IN exceeding
--echo # IN_PREDICATE_CONVERSION_THRESHOLD, derived_with_keys=off
--echo #
CREATE TABLE t1 (l_orderkey int);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (o_orderkey int);
INSERT INTO t2 VALUES (3),(4);
SET IN_PREDICATE_CONVERSION_THRESHOLD= 2;
SET OPTIMIZER_SWITCH='derived_with_keys=on';
SELECT * FROM t1 JOIN t2 ON (l_orderkey = o_orderkey) WHERE l_orderkey IN (1, 2, 3);
SET OPTIMIZER_SWITCH='derived_with_keys=off';
SELECT * FROM t1 JOIN t2 ON (l_orderkey = o_orderkey) WHERE l_orderkey IN (1, 2, 3);
SET @@IN_PREDICATE_CONVERSION_THRESHOLD=@@global.IN_PREDICATE_CONVERSION_THRESHOLD;
SET @@OPTIMIZER_SWITCH=@@global.OPTIMIZER_SWITCH;
DROP TABLE t1, t2;
--echo #
--echo # End of 11.0 tests
--echo #
......@@ -1820,7 +1820,7 @@ CREATE TABLE t1(f1 YEAR(4));
INSERT INTO t1 VALUES (0000),(2001);
(SELECT MAX(f1) FROM t1) UNION (SELECT MAX(f1) FROM t1);
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def MAX(f1) MAX(f1) 13 4 4 Y 32864 0 63
def MAX(f1) MAX(f1) 13 4 4 Y 49248 0 63
MAX(f1)
2001
DROP TABLE t1;
......
......@@ -147,7 +147,7 @@ id data data
2 female no
select t1.id from t1 union select t2.id from t2;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def id id 246 4 1 Y 32768 0 63
def id id 246 4 1 Y 49152 0 63
id
1
2
......@@ -158,7 +158,7 @@ insert into t1 values (2,'two');
set @arg00=1 ;
select @arg00 FROM t1 where a=1 union distinct select 1 FROM t1 where a=1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def @arg00 @arg00 8 20 1 Y 32768 0 63
def @arg00 @arg00 8 20 1 Y 49152 0 63
@arg00
1
select * from (select @arg00) aaa;
......@@ -168,12 +168,12 @@ def aaa @arg00 @arg00 8 20 1 Y 32768 0 63
1
select 1 union select 1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def 1 1 3 1 1 N 32769 0 63
def 1 1 3 1 1 N 49153 0 63
1
1
select * from (select 1 union select 1) aaa;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def aaa 1 1 3 1 1 N 32769 0 63
def aaa 1 1 3 1 1 N 49153 0 63
1
1
drop table t1;
......
......@@ -130,7 +130,7 @@ mysql_stmt_next_result(): 0; field_count: 0
# cat MYSQL_TMP_DIR/test_mdev26145.out.log
# ------------------------------------
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def MAX(a) MAX(a) 3 11 0 Y 32768 0 63
def MAX(a) MAX(a) 3 11 0 Y 49152 0 63
# ------------------------------------
......
......@@ -2377,7 +2377,7 @@ t2 CREATE TABLE `t2` (
DROP TABLE t2;
SELECT c_int FROM t1 UNION SELECT c_enum FROM t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def c_int c_int 253 11 0 Y 0 0 8
def c_int c_int 253 11 0 Y 16384 0 8
c_int
SELECT COALESCE(c_int, c_enum) FROM t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
......
......@@ -403,7 +403,7 @@ t2 CREATE TABLE `t2` (
DROP TABLE t2;
SELECT c_int FROM t1 UNION SELECT c_set FROM t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def c_int c_int 253 33 0 Y 0 0 33
def c_int c_int 253 33 0 Y 16384 0 33
c_int
SELECT COALESCE(c_int, c_set) FROM t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
......
......@@ -354,8 +354,6 @@ select_unit::create_result_table(THD *thd_arg, List<Item> *column_types,
return TRUE;
table->keys_in_use_for_query.clear_all();
for (uint i=0; i < table->s->fields; i++)
table->field[i]->flags &= ~(PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG);
if (create_table)
{
......@@ -393,9 +391,6 @@ select_union_recursive::create_result_table(THD *thd_arg,
return true;
incr_table->keys_in_use_for_query.clear_all();
for (uint i=0; i < table->s->fields; i++)
incr_table->field[i]->flags &= ~(PART_KEY_FLAG | PART_INDIRECT_KEY_FLAG);
return false;
}
......
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