From 4e3728f03842043dff6b4ba03a316f8a54984b25 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 2 Jul 2022 12:22:10 +0200 Subject: MDEV-29225 make explicit_defaults_for_timestamps SESSION variable make @@explicit_defaults_for_timestamp session variable --- sql/sql_insert.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_insert.cc') diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 4e0415a049a..8668b5d0dd2 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -4432,7 +4432,7 @@ TABLE *select_create::create_table_from_items(THD *thd, List *items, tmp_table.maybe_null= 0; tmp_table.in_use= thd; - if (!opt_explicit_defaults_for_timestamp) + if (!(thd->variables.option_bits & OPTION_EXPLICIT_DEF_TIMESTAMP)) promote_first_timestamp_column(&alter_info->create_list); if (create_info->fix_create_fields(thd, alter_info, *create_table)) -- cgit v1.2.1 From 3ebbfd88a0360938e3a5a480265beb2a71b1268a Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 2 Aug 2022 16:23:08 +0400 Subject: MDEV-29159 Patch for MDEV-28918 introduces more inconsistency than it solves, breaks usability 1. Store assignment failures on incompatible data types now raise errors if: - STRICT_ALL_TABLES or STRICT_TRANS_TABLES sql_mode is used, and - IGNORE is not used Otherwise, only a warning is raised and the statement continues. 2. Changing the error/warning test as follows: -ERROR HY000: Illegal parameter data types inet6 and int for operation 'SET' +ERROR HY000: Cannot cast 'int' as 'inet6' in assignment of `db`.`t`.`col` so in case of a big table it's easier to see which column has the problem. The new error text is also applied to SP variables. --- sql/sql_insert.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'sql/sql_insert.cc') diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 9507aaf3ab7..9b60e072896 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -768,7 +768,7 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, value_count= values->elements; if ((res= mysql_prepare_insert(thd, table_list, fields, values, - update_fields, update_values, duplic, + update_fields, update_values, duplic, ignore, &unused_conds, FALSE))) { retval= thd->is_error(); @@ -839,7 +839,8 @@ bool mysql_insert(THD *thd, TABLE_LIST *table_list, behaviour for non-transactional tables. */ if (values->elements && - table_list->table->check_assignability_opt_fields(fields, *values)) + table_list->table->check_assignability_opt_fields(fields, *values, + ignore)) goto abort; while ((values= its++)) @@ -1638,7 +1639,8 @@ static void prepare_for_positional_update(TABLE *table, TABLE_LIST *tables) int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, List &fields, List_item *values, List &update_fields, List &update_values, - enum_duplicates duplic, COND **where, + enum_duplicates duplic, bool ignore, + COND **where, bool select_insert) { SELECT_LEX *select_lex= thd->lex->first_select_lex(); @@ -1713,7 +1715,8 @@ int mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, ON DUPLICATE KEY UPDATE col=expr [, col=expr]; */ TABLE::check_assignability_explicit_fields(update_fields, - update_values); + update_values, + ignore); select_lex->no_wrap_view_item= FALSE; } @@ -3814,7 +3817,7 @@ int mysql_insert_select_prepare(THD *thd, select_result *sel_res) if ((res= mysql_prepare_insert(thd, lex->query_tables, lex->field_list, 0, lex->update_list, lex->value_list, - lex->duplicates, + lex->duplicates, lex->ignore, &select_lex->where, TRUE))) DBUG_RETURN(res); @@ -3915,7 +3918,8 @@ select_insert::prepare(List &values, SELECT_LEX_UNIT *u) INSERT INTO t1 (col1, col2) VALUES (expr1, expr2); INSERT INTO t1 SET col1=expr1, col2=expr2; */ - res= table_list->table->check_assignability_opt_fields(*fields, values); + res= table_list->table->check_assignability_opt_fields(*fields, values, + lex->ignore); } if (!res && fields->elements) @@ -3978,7 +3982,8 @@ select_insert::prepare(List &values, SELECT_LEX_UNIT *u) ON DUPLICATE KEY UPDATE col=expr [, col=expr] */ TABLE::check_assignability_explicit_fields(*info.update_fields, - *info.update_values); + *info.update_values, + lex->ignore); if (!res) { /* -- cgit v1.2.1