Commit 775aa554 authored by Igor Babaev's avatar Igor Babaev

Fixed mdev-15017 Server crashes in in st_join_table::fix_splitting

Do not apply splitting for constant tables.
parent 4808996b
......@@ -14917,3 +14917,14 @@ EXPLAIN
}
DROP VIEW v2;
DROP TABLE t1,t2;
#
# MDEV-15017: splittable table is constant table
#
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
CREATE TABLE t2 (pk INT, b INT, PRIMARY KEY (pk)) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1,2),(3,4);
CREATE VIEW v2 AS SELECT pk, MIN(b) FROM t2 GROUP BY pk;
SELECT * FROM t1 LEFT JOIN v2 ON (a = pk);
a pk MIN(b)
DROP VIEW v2;
DROP TABLE t1,t2;
......@@ -2582,3 +2582,19 @@ eval EXPLAIN FORMAT=JSON $q;
DROP VIEW v2;
DROP TABLE t1,t2;
--echo #
--echo # MDEV-15017: splittable table is constant table
--echo #
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
CREATE TABLE t2 (pk INT, b INT, PRIMARY KEY (pk)) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1,2),(3,4);
CREATE VIEW v2 AS SELECT pk, MIN(b) FROM t2 GROUP BY pk;
SELECT * FROM t1 LEFT JOIN v2 ON (a = pk);
DROP VIEW v2;
DROP TABLE t1,t2;
......@@ -1118,11 +1118,11 @@ bool JOIN::fix_all_splittings_in_plan()
{
table_map prev_tables= 0;
table_map all_tables= (1 << table_count) - 1;
for (uint tablenr=0 ; tablenr < table_count ; tablenr++)
for (uint tablenr= 0; tablenr < table_count; tablenr++)
{
POSITION *cur_pos= &best_positions[tablenr];
JOIN_TAB *tab= cur_pos->table;
if (tab->table->is_splittable())
if (tablenr >= const_tables && tab->table->is_splittable())
{
SplM_plan_info *spl_plan= cur_pos->spl_plan;
if (tab->fix_splitting(spl_plan, all_tables & ~prev_tables))
......
......@@ -4565,12 +4565,6 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
DBUG_EXECUTE("opt", print_keyuse_array(keyuse_array););
}
for (s= stat; s < stat_end; s++)
{
if (s->table->is_splittable())
s->add_keyuses_for_splitting();
}
join->const_table_map= no_rows_const_tables;
join->const_tables= const_count;
eliminate_tables(join);
......@@ -4877,6 +4871,9 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
s->scan_time();
}
if (s->table->is_splittable())
s->add_keyuses_for_splitting();
/*
Set a max range of how many seeks we can expect when using keys
This is can't be to high as otherwise we are likely to use
......
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