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

Do not apply splitting for constant tables.
This commit is contained in:
Igor Babaev 2018-01-29 23:51:04 -08:00
parent 4808996b12
commit 775aa5542d
4 changed files with 32 additions and 8 deletions

View File

@ -14917,3 +14917,14 @@ EXPLAIN
} }
DROP VIEW v2; DROP VIEW v2;
DROP TABLE t1,t2; 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;

View File

@ -2582,3 +2582,19 @@ eval EXPLAIN FORMAT=JSON $q;
DROP VIEW v2; DROP VIEW v2;
DROP TABLE t1,t2; 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;

View File

@ -1118,11 +1118,11 @@ bool JOIN::fix_all_splittings_in_plan()
{ {
table_map prev_tables= 0; table_map prev_tables= 0;
table_map all_tables= (1 << table_count) - 1; 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]; POSITION *cur_pos= &best_positions[tablenr];
JOIN_TAB *tab= cur_pos->table; 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; SplM_plan_info *spl_plan= cur_pos->spl_plan;
if (tab->fix_splitting(spl_plan, all_tables & ~prev_tables)) if (tab->fix_splitting(spl_plan, all_tables & ~prev_tables))

View File

@ -4565,12 +4565,6 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
DBUG_EXECUTE("opt", print_keyuse_array(keyuse_array);); 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_table_map= no_rows_const_tables;
join->const_tables= const_count; join->const_tables= const_count;
eliminate_tables(join); eliminate_tables(join);
@ -4877,6 +4871,9 @@ make_join_statistics(JOIN *join, List<TABLE_LIST> &tables_list,
s->scan_time(); 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 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 This is can't be to high as otherwise we are likely to use