Commit 07c0bac0 authored by Igor Babaev's avatar Igor Babaev

Fixed mdev-14947 Assertion `0' fails in Field_null::can_optimize_keypart_ref

when number of NULLs in IN list reaches in_predicate_conversion_threshold

The bug was fixed by removing an assertion that had been set in order
just to test whether the code could be ever executed.
parent e15f4af4
...@@ -614,3 +614,27 @@ Warnings: ...@@ -614,3 +614,27 @@ Warnings:
Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where !<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`c`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`c`),(`test`.`t2`.`a`,`test`.`t2`.`c`) in ( <materialize> (/* select#2 */ select `tvc_0`.`1`,`tvc_0`.`2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where `test`.`t2`.`a` = `<subquery2>`.`1` and `test`.`t2`.`c` = `<subquery2>`.`2`)))) Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where !<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`c`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`c`),(`test`.`t2`.`a`,`test`.`t2`.`c`) in ( <materialize> (/* select#2 */ select `tvc_0`.`1`,`tvc_0`.`2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where `test`.`t2`.`a` = `<subquery2>`.`1` and `test`.`t2`.`c` = `<subquery2>`.`2`))))
drop table t1, t2, t3; drop table t1, t2, t3;
set @@in_predicate_conversion_threshold= default; set @@in_predicate_conversion_threshold= default;
#
# MDEV-14947: conversion of TVC with only NULL values
#
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (3), (2), (7);
SELECT * FROM t1 WHERE i IN (NULL, NULL, NULL, NULL, NULL);
i
EXPLAIN EXTENDED SELECT * FROM t1 WHERE i IN (NULL, NULL, NULL, NULL, NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`i` AS `i` from `test`.`t1` where `test`.`t1`.`i` in (NULL,NULL,NULL,NULL,NULL)
SET in_predicate_conversion_threshold= 5;
SELECT * FROM t1 WHERE i IN (NULL, NULL, NULL, NULL, NULL);
i
EXPLAIN EXTENDED SELECT * FROM t1 WHERE i IN (NULL, NULL, NULL, NULL, NULL);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join ((values (NULL),(NULL),(NULL),(NULL),(NULL)) `tvc_0`) where `test`.`t1`.`i` = `tvc_0`.`NULL`
SET in_predicate_conversion_threshold= default;
DROP TABLE t1;
...@@ -318,3 +318,25 @@ eval explain extended $query; ...@@ -318,3 +318,25 @@ eval explain extended $query;
drop table t1, t2, t3; drop table t1, t2, t3;
set @@in_predicate_conversion_threshold= default; set @@in_predicate_conversion_threshold= default;
--echo #
--echo # MDEV-14947: conversion of TVC with only NULL values
--echo #
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (3), (2), (7);
let $q=
SELECT * FROM t1 WHERE i IN (NULL, NULL, NULL, NULL, NULL);
eval $q;
eval EXPLAIN EXTENDED $q;
SET in_predicate_conversion_threshold= 5;
eval $q;
eval EXPLAIN EXTENDED $q;
SET in_predicate_conversion_threshold= default;
DROP TABLE t1;
...@@ -2372,13 +2372,11 @@ class Field_null :public Field_str { ...@@ -2372,13 +2372,11 @@ class Field_null :public Field_str {
bool can_optimize_keypart_ref(const Item_bool_func *cond, bool can_optimize_keypart_ref(const Item_bool_func *cond,
const Item *item) const const Item *item) const
{ {
DBUG_ASSERT(0);
return false; return false;
} }
bool can_optimize_group_min_max(const Item_bool_func *cond, bool can_optimize_group_min_max(const Item_bool_func *cond,
const Item *const_item) const const Item *const_item) const
{ {
DBUG_ASSERT(0);
return false; return false;
} }
}; };
......
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