mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Fixed MDEV-14994 Assertion `join->best_read < double(1.79...15e+308L)' or
server crash in JOIN::fix_all_splittings_in_plan Cost formulas must take into account the case when a splittable table has now rows.
This commit is contained in:
@ -14928,3 +14928,20 @@ SELECT * FROM t1 LEFT JOIN v2 ON (a = pk);
|
||||
a pk MIN(b)
|
||||
DROP VIEW v2;
|
||||
DROP TABLE t1,t2;
|
||||
#
|
||||
# MDEV-14994: splittable table with no rows
|
||||
#
|
||||
CREATE TABLE t1 (f INT PRIMARY KEY) ENGINE=MyISAM;
|
||||
CREATE VIEW v1 AS SELECT a.* FROM t1 AS a STRAIGHT_JOIN t1 AS b;
|
||||
CREATE VIEW v2 AS SELECT f FROM v1 GROUP BY f;
|
||||
SELECT * FROM v1 JOIN v2 ON v1.f = v2.f;
|
||||
f f
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM v1 JOIN v2 ON v1.f = v2.f;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||
3 LATERAL DERIVED NULL NULL NULL NULL NULL NULL NULL NULL no matching row in const table
|
||||
Warnings:
|
||||
Note 1003 /* select#1 */ select NULL AS `f`,`v2`.`f` AS `f` from `test`.`t1` `a` straight_join `test`.`t1` `b` join `test`.`v2` where 0
|
||||
DROP VIEW v1,v2;
|
||||
DROP TABLE t1;
|
||||
|
@ -2598,3 +2598,18 @@ SELECT * FROM t1 LEFT JOIN v2 ON (a = pk);
|
||||
|
||||
DROP VIEW v2;
|
||||
DROP TABLE t1,t2;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-14994: splittable table with no rows
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (f INT PRIMARY KEY) ENGINE=MyISAM;
|
||||
CREATE VIEW v1 AS SELECT a.* FROM t1 AS a STRAIGHT_JOIN t1 AS b;
|
||||
CREATE VIEW v2 AS SELECT f FROM v1 GROUP BY f;
|
||||
|
||||
SELECT * FROM v1 JOIN v2 ON v1.f = v2.f;
|
||||
EXPLAIN EXTENDED
|
||||
SELECT * FROM v1 JOIN v2 ON v1.f = v2.f;
|
||||
|
||||
DROP VIEW v1,v2;
|
||||
DROP TABLE t1;
|
||||
|
@ -645,7 +645,8 @@ double spl_postjoin_oper_cost(THD *thd, double join_record_count, uint rec_len)
|
||||
cost+= get_tmp_table_lookup_cost(thd, join_record_count,rec_len) *
|
||||
join_record_count; // cost to perform post join operation used here
|
||||
cost+= get_tmp_table_lookup_cost(thd, join_record_count, rec_len) +
|
||||
join_record_count * log2 (join_record_count) *
|
||||
(join_record_count == 0 ? 0 :
|
||||
join_record_count * log2 (join_record_count)) *
|
||||
SORT_INDEX_CMP_COST; // cost to perform sorting
|
||||
return cost;
|
||||
}
|
||||
@ -948,7 +949,9 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count,
|
||||
spl_plan->table= best_table;
|
||||
spl_plan->key= best_key;
|
||||
spl_plan->parts= best_key_parts;
|
||||
spl_plan->split_sel= best_rec_per_key / spl_opt_info->unsplit_card;
|
||||
spl_plan->split_sel= best_rec_per_key /
|
||||
(spl_opt_info->unsplit_card ?
|
||||
spl_opt_info->unsplit_card : 1);
|
||||
|
||||
uint rec_len= table->s->rec_buff_length;
|
||||
|
||||
|
Reference in New Issue
Block a user