mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
A fix and a test case for Bug#15441 "Running SP causes Server
to Crash": the bug was that due to non-standard name resolution precedence in stored procedures (See Bug#5967) a stored procedure variable took precedence over a table column when the arguments for VALUES() function were resolved. The implementation of VALUES() function was not designed to work with Item_splocal and crashed. VALUES() function is non-standard. It can refer to, and is meaningful for, table columns only. The patch disables SP variables as possible arguments of VALUES() function.
This commit is contained in:
@ -5148,10 +5148,17 @@ bool Item_insert_value::fix_fields(THD *thd, Item **items)
|
||||
Item_ref *ref= (Item_ref *)arg;
|
||||
if (ref->ref[0]->type() != FIELD_ITEM)
|
||||
{
|
||||
my_error(ER_BAD_FIELD_ERROR, MYF(0), "", "VALUES() function");
|
||||
return TRUE;
|
||||
}
|
||||
arg= ref->ref[0];
|
||||
}
|
||||
/*
|
||||
According to our SQL grammar, VALUES() function can reference
|
||||
only to a column.
|
||||
*/
|
||||
DBUG_ASSERT(arg->type() == FIELD_ITEM);
|
||||
|
||||
Item_field *field_arg= (Item_field *)arg;
|
||||
|
||||
if (field_arg->field->table->insert_values)
|
||||
|
10
sql/item.h
10
sql/item.h
@ -2056,6 +2056,16 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
Item_insert_value -- an implementation of VALUES() function.
|
||||
You can use the VALUES(col_name) function in the UPDATE clause
|
||||
to refer to column values from the INSERT portion of the INSERT
|
||||
... UPDATE statement. In other words, VALUES(col_name) in the
|
||||
UPDATE clause refers to the value of col_name that would be
|
||||
inserted, had no duplicate-key conflict occurred.
|
||||
In all other places this function returns NULL.
|
||||
*/
|
||||
|
||||
class Item_insert_value : public Item_field
|
||||
{
|
||||
public:
|
||||
|
@ -4438,7 +4438,7 @@ simple_expr:
|
||||
}
|
||||
$$= new Item_default_value(Lex->current_context(), $3);
|
||||
}
|
||||
| VALUES '(' simple_ident ')'
|
||||
| VALUES '(' simple_ident_nospvar ')'
|
||||
{ $$= new Item_insert_value(Lex->current_context(), $3); }
|
||||
| FUNC_ARG0 '(' ')'
|
||||
{
|
||||
|
Reference in New Issue
Block a user