From dd41be2a51bd6823f5d7f5ff7f51ae7c002e7071 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 1 Nov 2024 12:40:43 +0400 Subject: [PATCH] MDEV-29184 Assertion `0' in Item_row::illegal_method_call, Type_handler_row::Item_update_null_value, Item::update_null_value - Moving the check_cols(1) test from fix_fields() to fix_length_and_dec(). So the test is now done before the code calling val_decimal() in fix_length_and_dec(). - Removing Item_func_interval::fix_fields(), as it become equal to the inherited one. --- mysql-test/main/func_set.result | 5 +++++ mysql-test/main/func_set.test | 8 ++++++++ sql/item_cmpfunc.cc | 15 ++++----------- sql/item_cmpfunc.h | 1 - 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/mysql-test/main/func_set.result b/mysql-test/main/func_set.result index 9dc63220d9e..8fccd0d6374 100644 --- a/mysql-test/main/func_set.result +++ b/mysql-test/main/func_set.result @@ -224,3 +224,8 @@ SELECT INTERVAL(1,ROW(1,2)); ERROR 21000: Operand should contain 1 column(s) SELECT INTERVAL(ROW(1,2),1); ERROR 21000: Operand should contain 1 column(s) +# +# MDEV-29184 Assertion `0' in Item_row::illegal_method_call, Type_handler_row::Item_update_null_value, Item::update_null_value +# +SELECT INTERVAL(0, ROW(1,1), 1, 1, 1, 1, 1, 1, 1) AS f; +ERROR 21000: Operand should contain 1 column(s) diff --git a/mysql-test/main/func_set.test b/mysql-test/main/func_set.test index 6df1d8ab97f..13250316a2f 100644 --- a/mysql-test/main/func_set.test +++ b/mysql-test/main/func_set.test @@ -147,3 +147,11 @@ SELECT INTERVAL(ROW(1,1),ROW(1,2)); SELECT INTERVAL(1,ROW(1,2)); --error ER_OPERAND_COLUMNS SELECT INTERVAL(ROW(1,2),1); + + +--echo # +--echo # MDEV-29184 Assertion `0' in Item_row::illegal_method_call, Type_handler_row::Item_update_null_value, Item::update_null_value +--echo # + +--error ER_OPERAND_COLUMNS +SELECT INTERVAL(0, ROW(1,1), 1, 1, 1, 1, 1, 1, 1) AS f; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 8bc04d07dfd..6ea30e7dde7 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1951,22 +1951,15 @@ bool Item_func_opt_neg::eq(const Item *item, bool binary_cmp) const } -bool Item_func_interval::fix_fields(THD *thd, Item **ref) +bool Item_func_interval::fix_length_and_dec() { - if (Item_long_func::fix_fields(thd, ref)) - return true; - for (uint i= 0 ; i < row->cols(); i++) + uint rows= row->cols(); + + for (uint i= 0 ; i < rows; i++) { if (row->element_index(i)->check_cols(1)) return true; } - return false; -} - - -bool Item_func_interval::fix_length_and_dec() -{ - uint rows= row->cols(); use_decimal_comparison= ((row->element_index(0)->result_type() == DECIMAL_RESULT) || diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index d680945826d..d651dc3b720 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1120,7 +1120,6 @@ public: Item_func_interval(THD *thd, Item_row *a): Item_long_func(thd, a), row(a), intervals(0) { } - bool fix_fields(THD *, Item **) override; longlong val_int() override; bool fix_length_and_dec() override; LEX_CSTRING func_name_cstring() const override