mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
MDEV-31494 Server crashes in ha_partition::index_blocks / get_key_scans_params
MDEV-31445 Server crashes in ha_partition::index_blocks / cost_for_index_read The crash happened in the case where partition pruning finds 0 partitions.
This commit is contained in:
@ -2858,3 +2858,41 @@ id select_type table type possible_keys key key_len ref rows Extra
|
|||||||
2 DEPENDENT SUBQUERY t3 ref_or_null a1,b a1 10 func,test.t2.a 198 Using where; Full scan on NULL key
|
2 DEPENDENT SUBQUERY t3 ref_or_null a1,b a1 10 func,test.t2.a 198 Using where; Full scan on NULL key
|
||||||
set optimizer_switch=@tmp_os;
|
set optimizer_switch=@tmp_os;
|
||||||
drop table t1,t2,t3;
|
drop table t1,t2,t3;
|
||||||
|
#
|
||||||
|
# MDEV-31494 Server crashes in ha_partition::index_blocks /
|
||||||
|
# get_key_scans_params
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a INT);
|
||||||
|
INSERT INTO t1 VALUES (1),(2);
|
||||||
|
CREATE TABLE t2 (b INT, c INT, KEY(c)) PARTITION BY LIST (b) (PARTITION p0 VALUES IN (1,2), PARTITION p1 VALUES IN (3,4));
|
||||||
|
INSERT INTO t2 VALUES (1,1),(2,2);
|
||||||
|
explain SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE t2.b = 5 AND t2.c = 10;
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
|
||||||
|
SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE t2.b = 5 AND t2.c = 10;
|
||||||
|
a b c
|
||||||
|
DROP TABLE t1, t2;
|
||||||
|
#
|
||||||
|
# MDEV-31445 Server crashes in ha_partition::index_blocks /
|
||||||
|
# cost_for_index_read
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a INT);
|
||||||
|
CREATE TABLE t2 (b INT);
|
||||||
|
CREATE TABLE t3 (c INT, d INT, KEY(d)) PARTITION BY KEY (c) PARTITIONS 2;
|
||||||
|
CREATE TABLE t4 (e INT);
|
||||||
|
INSERT INTO t1 VALUES (1),(2);
|
||||||
|
INSERT INTO t2 VALUES (1),(2);
|
||||||
|
INSERT INTO t3 VALUES (1,1),(2,2);
|
||||||
|
INSERT INTO t4 VALUES (1),(2);
|
||||||
|
explain SELECT * FROM t1 LEFT JOIN (t2 JOIN t3 ON (0 IN (SELECT e FROM t4) AND t3.d = t2.b)) ON (t3.c < t2.b);
|
||||||
|
id select_type table type possible_keys key key_len ref rows Extra
|
||||||
|
1 PRIMARY t1 ALL NULL NULL NULL NULL 2
|
||||||
|
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
|
||||||
|
1 PRIMARY t3 ref d d 5 test.t2.b 1 Using where
|
||||||
|
2 SUBQUERY t4 ALL NULL NULL NULL NULL 2 Using where
|
||||||
|
SELECT * FROM t1 LEFT JOIN (t2 JOIN t3 ON (0 IN (SELECT e FROM t4) AND t3.d = t2.b)) ON (t3.c < t2.b);
|
||||||
|
a b c d
|
||||||
|
1 NULL NULL NULL
|
||||||
|
2 NULL NULL NULL
|
||||||
|
drop table t1,t2,t3,t4;
|
||||||
|
# End of 11.0 tests
|
||||||
|
@ -3062,3 +3062,40 @@ set optimizer_switch=@tmp_os;
|
|||||||
|
|
||||||
drop table t1,t2,t3;
|
drop table t1,t2,t3;
|
||||||
|
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-31494 Server crashes in ha_partition::index_blocks /
|
||||||
|
--echo # get_key_scans_params
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a INT);
|
||||||
|
INSERT INTO t1 VALUES (1),(2);
|
||||||
|
|
||||||
|
CREATE TABLE t2 (b INT, c INT, KEY(c)) PARTITION BY LIST (b) (PARTITION p0 VALUES IN (1,2), PARTITION p1 VALUES IN (3,4));
|
||||||
|
|
||||||
|
INSERT INTO t2 VALUES (1,1),(2,2);
|
||||||
|
explain SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE t2.b = 5 AND t2.c = 10;
|
||||||
|
SELECT * FROM t1 STRAIGHT_JOIN t2 WHERE t2.b = 5 AND t2.c = 10;
|
||||||
|
DROP TABLE t1, t2;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-31445 Server crashes in ha_partition::index_blocks /
|
||||||
|
--echo # cost_for_index_read
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a INT);
|
||||||
|
CREATE TABLE t2 (b INT);
|
||||||
|
CREATE TABLE t3 (c INT, d INT, KEY(d)) PARTITION BY KEY (c) PARTITIONS 2;
|
||||||
|
CREATE TABLE t4 (e INT);
|
||||||
|
|
||||||
|
INSERT INTO t1 VALUES (1),(2);
|
||||||
|
INSERT INTO t2 VALUES (1),(2);
|
||||||
|
INSERT INTO t3 VALUES (1,1),(2,2);
|
||||||
|
INSERT INTO t4 VALUES (1),(2);
|
||||||
|
|
||||||
|
explain SELECT * FROM t1 LEFT JOIN (t2 JOIN t3 ON (0 IN (SELECT e FROM t4) AND t3.d = t2.b)) ON (t3.c < t2.b);
|
||||||
|
SELECT * FROM t1 LEFT JOIN (t2 JOIN t3 ON (0 IN (SELECT e FROM t4) AND t3.d = t2.b)) ON (t3.c < t2.b);
|
||||||
|
|
||||||
|
drop table t1,t2,t3,t4;
|
||||||
|
|
||||||
|
--echo # End of 11.0 tests
|
||||||
|
@ -12204,7 +12204,7 @@ ulonglong ha_partition::index_blocks(uint index, uint ranges, ha_rows rows)
|
|||||||
ulonglong blocks= 0;
|
ulonglong blocks= 0;
|
||||||
ulonglong active_partitions= bitmap_bits_set(&m_part_info->read_partitions);
|
ulonglong active_partitions= bitmap_bits_set(&m_part_info->read_partitions);
|
||||||
/* Assume rows are evenly dived among partitions */
|
/* Assume rows are evenly dived among partitions */
|
||||||
rows= (rows+ active_partitions -1) / active_partitions;
|
rows= (rows+ active_partitions -1) / MY_MAX(active_partitions, 1);
|
||||||
|
|
||||||
for (uint i= bitmap_get_first_set(&m_part_info->read_partitions);
|
for (uint i= bitmap_get_first_set(&m_part_info->read_partitions);
|
||||||
i < m_tot_parts;
|
i < m_tot_parts;
|
||||||
|
Reference in New Issue
Block a user