Skip to content

Commit

Permalink
Merge branch '10.5' into 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Jan 9, 2025
2 parents 9ddecc2 + 82fd202 commit addc828
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 23 deletions.
9 changes: 9 additions & 0 deletions mysql-test/main/win_sum.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
11 changes: 11 additions & 0 deletions mysql-test/main/win_sum.test
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
21 changes: 0 additions & 21 deletions sql/item_sum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
{
Expand Down
1 change: 0 additions & 1 deletion sql/item_sum.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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(). */
Expand Down
2 changes: 2 additions & 0 deletions sql/sql_repl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit addc828

Please sign in to comment.