Commit 9853026c authored by Alexander Barkov's avatar Alexander Barkov

MDEV-20800 Server crashes in Field_inet6::store_warning upon updating table statistics

Suppress warnings when Field_inet6::store() is called from
read_statistics_for_table() and other optimizer related routines.

This patch does for Field_inet6 the same thing with what Monty's
patch previously did for other Field_xxx:

> commit 1bbe8c5e
> Author: Michael Widenius <monty@mariadb.org>
> Date:   Sun Sep 22 04:08:48 2019 +0300
>
>    Proper fix for disabling warnings in read_statistics_for_table().
>    MDEV-20589: Server still crashes in Field::set_warning_truncated_wrong_value

Alas, some meaningful warnings disappeared.
parent 2cb7047f
...@@ -30,13 +30,11 @@ SELECT * FROM t1 WHERE a='garbage'; ...@@ -30,13 +30,11 @@ SELECT * FROM t1 WHERE a='garbage';
a a
Warnings: Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' Warning 1292 Incorrect inet6 value: 'garbage'
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
EXPLAIN SELECT * FROM t1 WHERE a='garbage'; EXPLAIN SELECT * FROM t1 WHERE a='garbage';
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings: Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' Warning 1292 Incorrect inet6 value: 'garbage'
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
SELECT * FROM t1 WHERE a>='::fe'; SELECT * FROM t1 WHERE a>='::fe';
a a
::fe ::fe
...@@ -46,13 +44,9 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -46,13 +44,9 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index 1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a>='garbage'; SELECT * FROM t1 WHERE a>='garbage';
a a
Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
EXPLAIN SELECT * FROM t1 WHERE a>='garbage'; EXPLAIN SELECT * FROM t1 WHERE a>='garbage';
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
SELECT * FROM t1 WHERE a IN ('::80','::a0','::f0'); SELECT * FROM t1 WHERE a IN ('::80','::a0','::f0');
a a
::80 ::80
...@@ -67,13 +61,11 @@ a ...@@ -67,13 +61,11 @@ a
::a0 ::a0
Warnings: Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' Warning 1292 Incorrect inet6 value: 'garbage'
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
EXPLAIN SELECT * FROM t1 WHERE a IN ('::80','::a0','garbage'); EXPLAIN SELECT * FROM t1 WHERE a IN ('::80','::a0','garbage');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index 1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index
Warnings: Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' Warning 1292 Incorrect inet6 value: 'garbage'
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
SELECT * FROM t1 WHERE a BETWEEN '::80' AND '::81'; SELECT * FROM t1 WHERE a BETWEEN '::80' AND '::81';
a a
::80 ::80
...@@ -83,13 +75,9 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -83,13 +75,9 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index 1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a BETWEEN '::80' AND 'garbage'; SELECT * FROM t1 WHERE a BETWEEN '::80' AND 'garbage';
a a
Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN '::80' AND 'garbage'; EXPLAIN SELECT * FROM t1 WHERE a BETWEEN '::80' AND 'garbage';
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
SELECT * FROM t1 WHERE a=CAST('::ff' AS INET6); SELECT * FROM t1 WHERE a=CAST('::ff' AS INET6);
a a
::ff ::ff
......
...@@ -30,13 +30,11 @@ SELECT * FROM t1 WHERE a='garbage'; ...@@ -30,13 +30,11 @@ SELECT * FROM t1 WHERE a='garbage';
a a
Warnings: Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' Warning 1292 Incorrect inet6 value: 'garbage'
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
EXPLAIN SELECT * FROM t1 WHERE a='garbage'; EXPLAIN SELECT * FROM t1 WHERE a='garbage';
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings: Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' Warning 1292 Incorrect inet6 value: 'garbage'
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
SELECT * FROM t1 WHERE a>='::fe'; SELECT * FROM t1 WHERE a>='::fe';
a a
::fe ::fe
...@@ -65,13 +63,11 @@ a ...@@ -65,13 +63,11 @@ a
::a0 ::a0
Warnings: Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' Warning 1292 Incorrect inet6 value: 'garbage'
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
EXPLAIN SELECT * FROM t1 WHERE a IN ('::80','::a0','garbage'); EXPLAIN SELECT * FROM t1 WHERE a IN ('::80','::a0','garbage');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 4 Using where 1 SIMPLE t1 range a a 17 NULL 4 Using where
Warnings: Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' Warning 1292 Incorrect inet6 value: 'garbage'
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
SELECT * FROM t1 WHERE a BETWEEN '::80' AND '::81'; SELECT * FROM t1 WHERE a BETWEEN '::80' AND '::81';
a a
::80 ::80
......
...@@ -30,13 +30,11 @@ SELECT * FROM t1 WHERE a='garbage'; ...@@ -30,13 +30,11 @@ SELECT * FROM t1 WHERE a='garbage';
a a
Warnings: Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' Warning 1292 Incorrect inet6 value: 'garbage'
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
EXPLAIN SELECT * FROM t1 WHERE a='garbage'; EXPLAIN SELECT * FROM t1 WHERE a='garbage';
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings: Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' Warning 1292 Incorrect inet6 value: 'garbage'
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
SELECT * FROM t1 WHERE a>='::fe'; SELECT * FROM t1 WHERE a>='::fe';
a a
::fe ::fe
...@@ -46,13 +44,9 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -46,13 +44,9 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index 1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a>='garbage'; SELECT * FROM t1 WHERE a>='garbage';
a a
Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
EXPLAIN SELECT * FROM t1 WHERE a>='garbage'; EXPLAIN SELECT * FROM t1 WHERE a>='garbage';
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
SELECT * FROM t1 WHERE a IN ('::80','::a0','::f0'); SELECT * FROM t1 WHERE a IN ('::80','::a0','::f0');
a a
::80 ::80
...@@ -67,13 +61,11 @@ a ...@@ -67,13 +61,11 @@ a
::a0 ::a0
Warnings: Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' Warning 1292 Incorrect inet6 value: 'garbage'
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
EXPLAIN SELECT * FROM t1 WHERE a IN ('::80','::a0','garbage'); EXPLAIN SELECT * FROM t1 WHERE a IN ('::80','::a0','garbage');
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index 1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index
Warnings: Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' Warning 1292 Incorrect inet6 value: 'garbage'
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
SELECT * FROM t1 WHERE a BETWEEN '::80' AND '::81'; SELECT * FROM t1 WHERE a BETWEEN '::80' AND '::81';
a a
::80 ::80
...@@ -83,13 +75,9 @@ id select_type table type possible_keys key key_len ref rows Extra ...@@ -83,13 +75,9 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index 1 SIMPLE t1 range a a 17 NULL 2 Using where; Using index
SELECT * FROM t1 WHERE a BETWEEN '::80' AND 'garbage'; SELECT * FROM t1 WHERE a BETWEEN '::80' AND 'garbage';
a a
Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
EXPLAIN SELECT * FROM t1 WHERE a BETWEEN '::80' AND 'garbage'; EXPLAIN SELECT * FROM t1 WHERE a BETWEEN '::80' AND 'garbage';
id select_type table type possible_keys key key_len ref rows Extra 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 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
Warnings:
Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1
SELECT * FROM t1 WHERE a=CAST('::ff' AS INET6); SELECT * FROM t1 WHERE a=CAST('::ff' AS INET6);
a a
::ff ::ff
......
#
# Start of 10.5 tests
#
#
# MDEV-20800 Server crashes in Field_inet6::store_warning upon updating table statistics
#
CREATE TABLE t1 (a INET6);
INSERT INTO t1 VALUES ('1::1'),('2::2');
ANALYZE TABLE t1 PERSISTENT FOR ALL;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
INSERT INTO t1 VALUES ('3::3');
DROP TABLE t1;
#
# End of 10.5 tests
#
--source include/have_stat_tables.inc
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-20800 Server crashes in Field_inet6::store_warning upon updating table statistics
--echo #
CREATE TABLE t1 (a INET6);
INSERT INTO t1 VALUES ('1::1'),('2::2');
ANALYZE TABLE t1 PERSISTENT FOR ALL;
INSERT INTO t1 VALUES ('3::3');
DROP TABLE t1;
--echo #
--echo # End of 10.5 tests
--echo #
...@@ -609,6 +609,7 @@ class Field_inet6: public Field ...@@ -609,6 +609,7 @@ class Field_inet6: public Field
Sql_condition::enum_warning_level level) Sql_condition::enum_warning_level level)
{ {
static const Name type_name= type_handler_inet6.name(); static const Name type_name= type_handler_inet6.name();
if (get_thd()->count_cuted_fields > CHECK_FIELD_EXPRESSION)
get_thd()->push_warning_truncated_value_for_field(level, type_name.ptr(), get_thd()->push_warning_truncated_value_for_field(level, type_name.ptr(),
str.ptr(), table->s, str.ptr(), table->s,
field_name.str); field_name.str);
......
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