mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-16385 ROW SP variable is allowed in unexpected context
The problem described in the bug report happened because the code did not test check_cols(1) after fix_fields() in a few places. Additionally, fix_fields() could be called multiple times for SP variables, because they are all fixed at a early stage in append_for_log(). Solution: 1. Adding a few helper methods - fix_fields_if_needed() - fix_fields_if_needed_for_scalar() - fix_fields_if_needed_for_bool() - fix_fields_if_needed_for_order_by() and using it in many cases instead of fix_fields() where the "fixed" status is not definitely known to be "false". 2. Adding DBUG_ASSERT(!fixed) into Item_splocal*::fix_fields() to catch double execution. 3. Adding tests. As a good side effect, the patch removes a lot of duplicate code (~60 lines): if (!item->fixed && item->fix_fields(..) && item->check_cols(1)) return true;
This commit is contained in:
@ -3709,8 +3709,7 @@ mysql_execute_command(THD *thd)
|
||||
|
||||
Item **it= lex->value_list.head_ref();
|
||||
if (!(*it)->basic_const_item() ||
|
||||
(!(*it)->fixed && (*it)->fix_fields(lex->thd, it)) ||
|
||||
(*it)->check_cols(1))
|
||||
(*it)->fix_fields_if_needed_for_scalar(lex->thd, it))
|
||||
{
|
||||
my_message(ER_SET_CONSTANTS_ONLY, ER_THD(thd, ER_SET_CONSTANTS_ONLY),
|
||||
MYF(0));
|
||||
@ -3819,8 +3818,7 @@ mysql_execute_command(THD *thd)
|
||||
goto error;
|
||||
/* PURGE MASTER LOGS BEFORE 'data' */
|
||||
it= (Item *)lex->value_list.head();
|
||||
if ((!it->fixed && it->fix_fields(lex->thd, &it)) ||
|
||||
it->check_cols(1))
|
||||
if (it->fix_fields_if_needed_for_scalar(lex->thd, &it))
|
||||
{
|
||||
my_error(ER_WRONG_ARGUMENTS, MYF(0), "PURGE LOGS BEFORE");
|
||||
goto error;
|
||||
@ -5680,7 +5678,7 @@ end_with_restore_list:
|
||||
if (lex->kill_type == KILL_TYPE_ID || lex->kill_type == KILL_TYPE_QUERY)
|
||||
{
|
||||
Item *it= (Item *)lex->value_list.head();
|
||||
if ((!it->fixed && it->fix_fields(lex->thd, &it)) || it->check_cols(1))
|
||||
if (it->fix_fields_if_needed_for_scalar(lex->thd, &it))
|
||||
{
|
||||
my_message(ER_SET_CONSTANTS_ONLY, ER_THD(thd, ER_SET_CONSTANTS_ONLY),
|
||||
MYF(0));
|
||||
|
Reference in New Issue
Block a user