diff --git a/mysql-test/main/win_sum.result b/mysql-test/main/win_sum.result index a17c17845af6e..aa376ecf7bab6 100644 --- a/mysql-test/main/win_sum.result +++ b/mysql-test/main/win_sum.result @@ -105,3 +105,12 @@ EXISTS (SELECT 1 ORDER BY 1+sum(2) OVER ()) # # End of 10.4 tests # +# +# MDEV-32411 Item_sum arguments incorrectly reset to temp table fields which causes crash +# +CREATE TABLE t1 (a INT NOT NULL) ; +INSERT INTO t1 VALUES (EXISTS(SELECT avg(3) OVER (ORDER BY COUNT(DISTINCT a, HEX(a))))); +DROP TABLE t1; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/win_sum.test b/mysql-test/main/win_sum.test index 9800174f54ca0..d392443594948 100644 --- a/mysql-test/main/win_sum.test +++ b/mysql-test/main/win_sum.test @@ -57,3 +57,14 @@ SELECT EXISTS (SELECT 1 ORDER BY 1+sum(2) OVER ()); --echo # --echo # End of 10.4 tests --echo # + +--echo # +--echo # MDEV-32411 Item_sum arguments incorrectly reset to temp table fields which causes crash +--echo # +CREATE TABLE t1 (a INT NOT NULL) ; +INSERT INTO t1 VALUES (EXISTS(SELECT avg(3) OVER (ORDER BY COUNT(DISTINCT a, HEX(a))))); +DROP TABLE t1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 78da78adeb1c3..f7b5e97188bdd 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -546,27 +546,6 @@ void Item_sum::fix_num_length_and_dec() max_length=float_length(decimals); } -Item *Item_sum::get_tmp_table_item(THD *thd) -{ - Item_sum* sum_item= (Item_sum *) copy_or_same(thd); - if (sum_item && sum_item->result_field) // If not a const sum func - { - Field *result_field_tmp= sum_item->result_field; - for (uint i=0 ; i < sum_item->arg_count ; i++) - { - Item *arg= sum_item->args[i]; - if (!arg->const_item()) - { - if (arg->type() == Item::FIELD_ITEM) - ((Item_field*) arg)->field= result_field_tmp++; - else - sum_item->args[i]= new (thd->mem_root) Item_temptable_field(thd, result_field_tmp++); - } - } - } - return sum_item; -} - void Item_sum::update_used_tables () { diff --git a/sql/item_sum.h b/sql/item_sum.h index da314471f5c2e..83c7d5cf9e0dd 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -525,7 +525,6 @@ class Item_sum :public Item_func_or_sum aggregator_clear(); } virtual void make_unique() { force_copy_fields= TRUE; } - Item *get_tmp_table_item(THD *thd) override; virtual Field *create_tmp_field(MEM_ROOT *root, bool group, TABLE *table); Field *create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src, const Tmp_field_param *param) override diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 76c00c0f932e9..143a6822c758b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3232,10 +3232,13 @@ void my_message_sql(uint error, const char *str, myf MyFlags) MyFlags)); DBUG_ASSERT(str != NULL); + DBUG_ASSERT(*str != '\0'); DBUG_ASSERT(error != 0); DBUG_ASSERT((MyFlags & ~(ME_BELL | ME_ERROR_LOG | ME_ERROR_LOG_ONLY | ME_NOTE | ME_WARNING | ME_FATAL)) == 0); + DBUG_ASSERT(str[strlen(str)-1] != '\n'); + if (MyFlags & ME_NOTE) { level= Sql_condition::WARN_LEVEL_NOTE; diff --git a/sql/sql_error.cc b/sql/sql_error.cc index decf44c07a628..af8898c7afb7d 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -691,7 +691,6 @@ Sql_condition *Warning_info::push_warning(THD *thd, const char *msg) { Sql_condition *cond= NULL; - DBUG_ASSERT(msg[strlen(msg)-1] != '\n'); if (! m_read_only) { @@ -749,6 +748,7 @@ void push_warning(THD *thd, Sql_condition::enum_warning_level level, if (level == Sql_condition::WARN_LEVEL_ERROR) level= Sql_condition::WARN_LEVEL_WARN; + DBUG_ASSERT(msg[strlen(msg)-1] != '\n'); (void) thd->raise_condition(code, NULL, level, msg); /* Make sure we also count warnings pushed after calling set_ok_status(). */ diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index d9d310c8078c8..0ed5cb5e99f02 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -3087,6 +3087,8 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, } else if (info->errmsg != NULL) safe_strcpy(info->error_text, sizeof(info->error_text), info->errmsg); + else if (info->error_text[0] == 0) + safe_strcpy(info->error_text, sizeof(info->error_text), ER(info->error)); my_message(info->error, info->error_text, MYF(0));