1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-15703: Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT

This patch fixes the issue with passing the DEFAULT or IGNORE values to
positional parameters for some kind of SQL statements to be executed
as prepared statements.

The main idea of the patch is to associate an actual value being passed
by the USING clause with the positional parameter represented by
the Item_param class. Such association must be performed on execution of
UPDATE statement in PS/SP mode. Other corner cases that results in
server crash is on handling CREATE TABLE when positional parameter
placed after the DEFAULT clause or CALL statement and passing either
the value DEFAULT or IGNORE as an actual value for the positional parameter.
This case is fixed by checking whether an error is set in diagnostics
area at the function pack_vcols() on return from the function pack_expression()
This commit is contained in:
Dmitry Shulga
2024-02-08 12:17:02 +07:00
committed by Oleksandr Byelkin
parent 6b2cd78695
commit e48bd474a2
16 changed files with 418 additions and 17 deletions

View File

@ -8870,6 +8870,9 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table,
@param values values to fill with
@param ignore_errors TRUE if we should ignore errors
@param use_value forces usage of value of the items instead of result
@param check_for_computability whether to check for ability to invoke val_*()
methods (val_int () etc) against supplied
values
@details
fill_record() may set table->auto_increment_field_not_null and a
@ -8883,7 +8886,7 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table,
bool
fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
bool ignore_errors, bool use_value)
bool ignore_errors, bool use_value, bool check_for_computability)
{
List_iterator_fast<Item> v(values);
List<TABLE> tbl_list;
@ -8921,6 +8924,10 @@ fill_record(THD *thd, TABLE *table, Field **ptr, List<Item> &values,
else
value=v++;
if (check_for_computability &&
value->check_is_evaluable_expression_or_error())
goto err;
bool vers_sys_field= table->versioned() && field->vers_sys_field();
if (field->field_index == autoinc_index)
@ -8995,7 +9002,7 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, Field **ptr,
bool result;
Table_triggers_list *triggers= table->triggers;
result= fill_record(thd, table, ptr, values, ignore_errors, FALSE);
result= fill_record(thd, table, ptr, values, ignore_errors, false, false);
if (!result && triggers && *ptr)
result= triggers->process_triggers(thd, event, TRG_ACTION_BEFORE, TRUE) ||