summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2018-01-08 15:21:52 -0800
committerIgor Babaev <igor@askmonty.org>2018-01-08 15:22:17 -0800
commitc5ac1f953bf6d4279967f03a8343303f715ad7aa (patch)
tree10885c7baf121d8a06f9887000f898040b05daf2
parent7349b9ab5eda351737f9d63c445df0ade6dcbf9e (diff)
downloadmariadb-git-bb-10.3-vicentiu-no-dtoa.tar.gz
Fixed mdev-14880: Assertion `inj_cond_list.elements' failedbb-10.3-vicentiu-no-dtoa
in JOIN::inject_best_splitting_cond The value of SplM_opt_info::last_plan should be set to NULL before any search for a splitting plan for a splittable materialized table.
-rw-r--r--mysql-test/r/derived_cond_pushdown.result65
-rw-r--r--mysql-test/t/derived_cond_pushdown.test22
-rw-r--r--sql/opt_split.cc2
3 files changed, 88 insertions, 1 deletions
diff --git a/mysql-test/r/derived_cond_pushdown.result b/mysql-test/r/derived_cond_pushdown.result
index e78afa0eb90..0eb12033dd3 100644
--- a/mysql-test/r/derived_cond_pushdown.result
+++ b/mysql-test/r/derived_cond_pushdown.result
@@ -14788,3 +14788,68 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
Warnings:
Note 1003 with cte as (/* select#2 */ select `test`.`t1`.`pk` AS `pk` from `test`.`t1` where 0 group by `test`.`t1`.`pk`)/* select#1 */ select NULL AS `pk` from `cte`
DROP TABLE t1;
+#
+# MDEV-14880: assertion failure in optimizer when splitting is applied
+#
+CREATE TABLE t1 (pk1 INT PRIMARY KEY, f INT) ENGINE=Aria;
+INSERT INTO t1 VALUES (1,0),(2,0);
+CREATE TABLE t2 (pk2 INT PRIMARY KEY) ENGINE=Aria;
+INSERT INTO t2 VALUES (1),(2),(3);
+CREATE VIEW v2 AS SELECT pk2, COUNT(*) AS cnt FROM t2 GROUP BY pk2;
+SELECT * FROM t1 INNER JOIN v2 ON pk1 = pk2 WHERE f <> 5;
+pk1 f pk2 cnt
+1 0 1 1
+2 0 2 1
+EXPLAIN EXTENDED SELECT * FROM t1 INNER JOIN v2 ON pk1 = pk2 WHERE f <> 5;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t1 ALL PRIMARY NULL NULL NULL 2 100.00 Using where
+1 PRIMARY <derived2> ref key0 key0 4 test.t1.pk1 2 100.00
+2 LATERAL DERIVED t2 eq_ref PRIMARY PRIMARY 4 test.t1.pk1 1 100.00 Using index
+Warnings:
+Note 1003 /* select#1 */ select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`f` AS `f`,`v2`.`pk2` AS `pk2`,`v2`.`cnt` AS `cnt` from `test`.`t1` join `test`.`v2` where `v2`.`pk2` = `test`.`t1`.`pk1` and `test`.`t1`.`f` <> 5
+EXPLAIN FORMAT=JSON SELECT * FROM t1 INNER JOIN v2 ON pk1 = pk2 WHERE f <> 5;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "possible_keys": ["PRIMARY"],
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t1.f <> 5"
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ref",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "4",
+ "used_key_parts": ["pk2"],
+ "ref": ["test.t1.pk1"],
+ "rows": 2,
+ "filtered": 100,
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "outer_ref_condition": "t1.pk1 is not null",
+ "table": {
+ "table_name": "t2",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["pk2"],
+ "ref": ["test.t1.pk1"],
+ "rows": 1,
+ "filtered": 100,
+ "using_index": true
+ }
+ }
+ }
+ }
+ }
+}
+DROP VIEW v2;
+DROP TABLE t1,t2;
diff --git a/mysql-test/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test
index 23c54cf3c09..f6e902336b3 100644
--- a/mysql-test/t/derived_cond_pushdown.test
+++ b/mysql-test/t/derived_cond_pushdown.test
@@ -2535,3 +2535,25 @@ eval $q;
eval EXPLAIN EXTENDED $q;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-14880: assertion failure in optimizer when splitting is applied
+--echo #
+
+CREATE TABLE t1 (pk1 INT PRIMARY KEY, f INT) ENGINE=Aria;
+INSERT INTO t1 VALUES (1,0),(2,0);
+
+CREATE TABLE t2 (pk2 INT PRIMARY KEY) ENGINE=Aria;
+INSERT INTO t2 VALUES (1),(2),(3);
+
+CREATE VIEW v2 AS SELECT pk2, COUNT(*) AS cnt FROM t2 GROUP BY pk2;
+
+let $q=
+SELECT * FROM t1 INNER JOIN v2 ON pk1 = pk2 WHERE f <> 5;
+
+eval $q;
+eval EXPLAIN EXTENDED $q;
+eval EXPLAIN FORMAT=JSON $q;
+
+DROP VIEW v2;
+DROP TABLE t1,t2;
diff --git a/sql/opt_split.cc b/sql/opt_split.cc
index 4d71e9cdd1b..ac2972f4264 100644
--- a/sql/opt_split.cc
+++ b/sql/opt_split.cc
@@ -922,6 +922,7 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count,
}
while (keyuse_ext->table == table);
}
+ spl_opt_info->last_plan= 0;
if (best_table)
{
/*
@@ -963,7 +964,6 @@ SplM_plan_info * JOIN_TAB::choose_best_splitting(double record_count,
reset_validity_vars_for_keyuses(best_key_keyuse_ext_start, best_table,
best_key, remaining_tables, false);
}
- spl_opt_info->last_plan= 0;
if (spl_plan)
{
if(record_count * spl_plan->cost < spl_opt_info->unsplit_cost)