Commit 1db675b6 authored by Igor Babaev's avatar Igor Babaev

Fixed mdev-4380.

Uninitialized field next_equal_field of the Field objects created
for the fields of a temporary table could hang the server.

parent ddb84f90
......@@ -964,4 +964,29 @@ set histogram_type=@save_histogram_type;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2,t3;
set use_stat_tables=@save_use_stat_tables;
#
# Bug mdev-4380: 2-way join with a materialized IN subquery in WHERE
# when optimizer_use_condition_selectivity=3
#
set use_stat_tables=PREFERABLY;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (5),(9);
CREATE TABLE t2 (b VARCHAR(8));
INSERT INTO t2 VALUES ('red'),('blue');
CREATE TABLE t3 (c VARCHAR(8), d VARCHAR(8));
INSERT INTO t3 VALUES ('white','black'),('cyan','yellow');
ANALYZE TABLE t1, t2, t3;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t2 analyze status OK
test.t3 analyze status OK
FLUSH TABLES;
set optimizer_use_condition_selectivity=3;
SELECT * FROM t1, t2 WHERE ( 'orange', 'green' ) IN (
SELECT MAX(c), MAX(d) FROM t3, t2 WHERE c >= d AND b = c
);
a b
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2,t3;
set use_stat_tables=@save_use_stat_tables;
set use_stat_tables=@save_use_stat_tables;
......@@ -972,6 +972,31 @@ set histogram_type=@save_histogram_type;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2,t3;
set use_stat_tables=@save_use_stat_tables;
#
# Bug mdev-4380: 2-way join with a materialized IN subquery in WHERE
# when optimizer_use_condition_selectivity=3
#
set use_stat_tables=PREFERABLY;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (5),(9);
CREATE TABLE t2 (b VARCHAR(8));
INSERT INTO t2 VALUES ('red'),('blue');
CREATE TABLE t3 (c VARCHAR(8), d VARCHAR(8));
INSERT INTO t3 VALUES ('white','black'),('cyan','yellow');
ANALYZE TABLE t1, t2, t3;
Table Op Msg_type Msg_text
test.t1 analyze status OK
test.t2 analyze status OK
test.t3 analyze status OK
FLUSH TABLES;
set optimizer_use_condition_selectivity=3;
SELECT * FROM t1, t2 WHERE ( 'orange', 'green' ) IN (
SELECT MAX(c), MAX(d) FROM t3, t2 WHERE c >= d AND b = c
);
a b
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2,t3;
set use_stat_tables=@save_use_stat_tables;
set use_stat_tables=@save_use_stat_tables;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
SET SESSION STORAGE_ENGINE=DEFAULT;
......@@ -561,5 +561,35 @@ DROP TABLE t1,t2,t3;
set use_stat_tables=@save_use_stat_tables;
--echo #
--echo # Bug mdev-4380: 2-way join with a materialized IN subquery in WHERE
--echo # when optimizer_use_condition_selectivity=3
--echo #
set use_stat_tables=PREFERABLY;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (5),(9);
CREATE TABLE t2 (b VARCHAR(8));
INSERT INTO t2 VALUES ('red'),('blue');
CREATE TABLE t3 (c VARCHAR(8), d VARCHAR(8));
INSERT INTO t3 VALUES ('white','black'),('cyan','yellow');
ANALYZE TABLE t1, t2, t3;
FLUSH TABLES;
set optimizer_use_condition_selectivity=3;
SELECT * FROM t1, t2 WHERE ( 'orange', 'green' ) IN (
SELECT MAX(c), MAX(d) FROM t3, t2 WHERE c >= d AND b = c
);
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
DROP TABLE t1,t2,t3;
set use_stat_tables=@save_use_stat_tables;
set use_stat_tables=@save_use_stat_tables;
......@@ -14336,6 +14336,7 @@ Field *create_tmp_field_from_field(THD *thd, Field *org_field,
new_field->vcol_info= 0;
new_field->stored_in_db= TRUE;
new_field->cond_selectivity= 1.0;
new_field->next_equal_field= NULL;
}
return new_field;
}
......
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