Commit 6bfeace1 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-15759 Expect "Impossible WHERE" for indexed_int_column=out_of_range_int_constant

parent 25410d44
......@@ -849,3 +849,21 @@ DROP TABLE IF EXISTS t1;
#
# End of 10.2 tests
#
#
# Start of 10.4 tests
#
#
# MDEV-15759 Expect "Impossible WHERE" for indexed_int_column=out_of_range_int_constant
#
CREATE TABLE t1 (a BIT(7), KEY(a));
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
EXPLAIN SELECT * FROM t1 WHERE a=200;
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
EXPLAIN SELECT * FROM t1 WHERE a<=>200;
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
DROP TABLE t1;
#
# End of 10.4 tests
#
......@@ -483,3 +483,21 @@ DROP TABLE IF EXISTS t1;
--echo # End of 10.2 tests
--echo #
--echo #
--echo # Start of 10.4 tests
--echo #
--echo #
--echo # MDEV-15759 Expect "Impossible WHERE" for indexed_int_column=out_of_range_int_constant
--echo #
CREATE TABLE t1 (a BIT(7), KEY(a));
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
EXPLAIN SELECT * FROM t1 WHERE a=200;
EXPLAIN SELECT * FROM t1 WHERE a<=>200;
DROP TABLE t1;
--echo #
--echo # End of 10.4 tests
--echo #
......@@ -268,5 +268,17 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1
DROP TABLE t1;
#
# MDEV-15759 Expect "Impossible WHERE" for indexed_int_column=out_of_range_int_constant
#
CREATE TABLE t1 (a TINYINT, KEY(a));
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
EXPLAIN SELECT * FROM t1 WHERE a=200;
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
EXPLAIN SELECT * FROM t1 WHERE a<=>200;
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
DROP TABLE t1;
#
# End of 10.4 tests
#
......@@ -196,6 +196,17 @@ EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE ?+a<=>1+a' USING 1;
EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE 1+a<=>?+a' USING 1;
DROP TABLE t1;
--echo #
--echo # MDEV-15759 Expect "Impossible WHERE" for indexed_int_column=out_of_range_int_constant
--echo #
CREATE TABLE t1 (a TINYINT, KEY(a));
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
EXPLAIN SELECT * FROM t1 WHERE a=200;
EXPLAIN SELECT * FROM t1 WHERE a<=>200;
DROP TABLE t1;
--echo #
--echo # End of 10.4 tests
--echo #
......@@ -447,7 +447,7 @@ UPDATE t1 SET user_id=null WHERE request_id=9999999999999;
show status like '%Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 3
Handler_read_key 2
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
......@@ -459,7 +459,7 @@ UPDATE t1 SET user_id=null WHERE request_id=999999999999999999999999999999;
show status like '%Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 3
Handler_read_key 2
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
......
......@@ -8114,6 +8114,11 @@ Item_bool_func::get_mm_leaf(RANGE_OPT_PARAM *param,
*/
else if (err == 1 && field->result_type() == INT_RESULT)
{
if (type == EQ_FUNC || type == EQUAL_FUNC) // e.g. tinyint = 200
{
tree= new (alloc) SEL_ARG_IMPOSSIBLE(field);
goto end;
}
if (type == LT_FUNC && (value->val_int() > 0))
type= LE_FUNC;
else if (type == GT_FUNC &&
......
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