diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-10-13 23:07:48 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-10-13 23:07:48 +0400 |
commit | 9853026cec66b0e96e041a177c67e25c94908bea (patch) | |
tree | 08617a7863e9cebab9d928d51617b46ebce86425 | |
parent | 2cb7047f692cf26b8e2fb67246330051ff9a5702 (diff) | |
download | mariadb-git-9853026cec66b0e96e041a177c67e25c94908bea.tar.gz |
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 1bbe8c5e0f6823acd4780d7563e8c02f8b4c5a01
> 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.
6 files changed, 40 insertions, 31 deletions
diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_innodb.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_innodb.result index ad2d22c2153..5f7063b8f4b 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6_innodb.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_innodb.result @@ -30,13 +30,11 @@ SELECT * FROM t1 WHERE a='garbage'; a Warnings: 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'; 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 Warnings: 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'; a ::fe @@ -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 SELECT * FROM t1 WHERE a>='garbage'; a -Warnings: -Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1 EXPLAIN SELECT * FROM t1 WHERE a>='garbage'; 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 -Warnings: -Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1 SELECT * FROM t1 WHERE a IN ('::80','::a0','::f0'); a ::80 @@ -67,13 +61,11 @@ a ::a0 Warnings: 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'); 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 Warnings: 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'; a ::80 @@ -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 SELECT * FROM t1 WHERE a BETWEEN '::80' AND 'garbage'; 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'; 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 -Warnings: -Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1 SELECT * FROM t1 WHERE a=CAST('::ff' AS INET6); a ::ff diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_memory.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_memory.result index 56c4ae8231d..db4196366ca 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6_memory.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_memory.result @@ -30,13 +30,11 @@ SELECT * FROM t1 WHERE a='garbage'; a Warnings: 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'; 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 Warnings: 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'; a ::fe @@ -65,13 +63,11 @@ a ::a0 Warnings: 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'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range a a 17 NULL 4 Using where Warnings: 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'; a ::80 diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_myisam.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_myisam.result index 6525bda5aa5..c8dba6ff959 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6_myisam.result +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_myisam.result @@ -30,13 +30,11 @@ SELECT * FROM t1 WHERE a='garbage'; a Warnings: 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'; 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 Warnings: 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'; a ::fe @@ -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 SELECT * FROM t1 WHERE a>='garbage'; a -Warnings: -Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1 EXPLAIN SELECT * FROM t1 WHERE a>='garbage'; 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 -Warnings: -Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1 SELECT * FROM t1 WHERE a IN ('::80','::a0','::f0'); a ::80 @@ -67,13 +61,11 @@ a ::a0 Warnings: 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'); 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 Warnings: 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'; a ::80 @@ -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 SELECT * FROM t1 WHERE a BETWEEN '::80' AND 'garbage'; 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'; 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 -Warnings: -Warning 1292 Incorrect inet6 value: 'garbage' for column `test`.`t1`.`a` at row 1 SELECT * FROM t1 WHERE a=CAST('::ff' AS INET6); a ::ff diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_stat_tables.result b/plugin/type_inet/mysql-test/type_inet/type_inet6_stat_tables.result new file mode 100644 index 00000000000..6d84d105c99 --- /dev/null +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_stat_tables.result @@ -0,0 +1,17 @@ +# +# 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 +# diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6_stat_tables.test b/plugin/type_inet/mysql-test/type_inet/type_inet6_stat_tables.test new file mode 100644 index 00000000000..fb092db6bc4 --- /dev/null +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6_stat_tables.test @@ -0,0 +1,19 @@ +--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 # diff --git a/plugin/type_inet/sql_type_inet.cc b/plugin/type_inet/sql_type_inet.cc index 322f494ba2b..9bf77e62d24 100644 --- a/plugin/type_inet/sql_type_inet.cc +++ b/plugin/type_inet/sql_type_inet.cc @@ -609,9 +609,10 @@ class Field_inet6: public Field Sql_condition::enum_warning_level level) { static const Name type_name= type_handler_inet6.name(); - get_thd()->push_warning_truncated_value_for_field(level, type_name.ptr(), - str.ptr(), table->s, - field_name.str); + if (get_thd()->count_cuted_fields > CHECK_FIELD_EXPRESSION) + get_thd()->push_warning_truncated_value_for_field(level, type_name.ptr(), + str.ptr(), table->s, + field_name.str); } int set_null_with_warn(const ErrConv &str) { |