From 271b73770cd5bd13bb52bfa4dd91c8d275920467 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Fri, 13 Dec 2024 16:27:14 +0100 Subject: [PATCH] MDEV-30263 Assertion failure in Protocol::end_statement upon HANDLER READ with invalid timestamp Process save_in_field() return codes as in other places (<0 is real error) --- mysql-test/suite/handler/handler_warnings.result | 14 ++++++++++++++ mysql-test/suite/handler/handler_warnings.test | 15 +++++++++++++++ sql/sql_handler.cc | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/handler/handler_warnings.result create mode 100644 mysql-test/suite/handler/handler_warnings.test diff --git a/mysql-test/suite/handler/handler_warnings.result b/mysql-test/suite/handler/handler_warnings.result new file mode 100644 index 00000000000..f64f7cad76f --- /dev/null +++ b/mysql-test/suite/handler/handler_warnings.result @@ -0,0 +1,14 @@ +# +# MDEV-30263: --echo # Assertion failure in Protocol::end_statement +# upon HANDLER READ with invalid timestamp +# +CREATE TABLE t (a TIMESTAMP, KEY(a)); +HANDLER t OPEN; +HANDLER t READ a > ('2022-12'); +a +# above should issue the same warnings/errors as following +SELECT * from t WHERE t.a > ('2022-12'); +a +HANDLER t CLOSE; +DROP TABLE t; +End of 10.5 tests diff --git a/mysql-test/suite/handler/handler_warnings.test b/mysql-test/suite/handler/handler_warnings.test new file mode 100644 index 00000000000..b632381c1c0 --- /dev/null +++ b/mysql-test/suite/handler/handler_warnings.test @@ -0,0 +1,15 @@ +--echo # +--echo # MDEV-30263: --echo # Assertion failure in Protocol::end_statement +--echo # upon HANDLER READ with invalid timestamp +--echo # + +CREATE TABLE t (a TIMESTAMP, KEY(a)); +HANDLER t OPEN; +HANDLER t READ a > ('2022-12'); +--echo # above should issue the same warnings/errors as following +SELECT * from t WHERE t.a > ('2022-12'); +# Cleanup +HANDLER t CLOSE; +DROP TABLE t; + +--echo End of 10.5 tests diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index b1899e9969e..5938537b460 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -700,7 +700,7 @@ mysql_ha_fix_cond_and_key(SQL_HANDLER *handler, MY_BITMAP *old_map= dbug_tmp_use_all_columns(table, &table->write_set); int res= item->save_in_field(key_part->field, 1); dbug_tmp_restore_column_map(&table->write_set, old_map); - if (res) + if (res < 0 || thd->is_error()) return 1; } key_len+= key_part->store_length;