=== modified file 'sql/field_conv.cc' --- sql/field_conv.cc 2009-06-17 14:56:44 +0000 +++ sql/field_conv.cc 2009-11-05 15:07:54 +0000 @@ -122,13 +122,18 @@ set_field_to_null(Field *field) return 0; } field->reset(); - if (field->table->in_use->count_cuted_fields == CHECK_FIELD_WARN) - { + switch (field->table->in_use->count_cuted_fields) { + case CHECK_FIELD_WARN: field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + /* fall through */ + case CHECK_FIELD_IGNORE: return 0; + case CHECK_FIELD_ERROR_FOR_NULL: + if (!field->table->in_use->no_errors) + my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name); + return -1; } - if (!field->table->in_use->no_errors) - my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name); + DBUG_ASSERT(0); // impossible return -1; } @@ -170,21 +175,26 @@ set_field_to_null_with_conversions(Field if (field->type() == MYSQL_TYPE_TIMESTAMP) { ((Field_timestamp*) field)->set_time(); return 0; // Ok to set time to NULL } field->reset(); if (field == field->table->next_number_field) { field->table->auto_increment_field_not_null= FALSE; return 0; // field is set in fill_record() } - if (field->table->in_use->count_cuted_fields == CHECK_FIELD_WARN) - { + switch (field->table->in_use->count_cuted_fields) { + case CHECK_FIELD_WARN: field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_BAD_NULL_ERROR, 1); + /* fall through */ + case CHECK_FIELD_IGNORE: return 0; + case CHECK_FIELD_ERROR_FOR_NULL: + if (!field->table->in_use->no_errors) + my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name); + return -1; } - if (!field->table->in_use->no_errors) - my_error(ER_BAD_NULL_ERROR, MYF(0), field->field_name); + DBUG_ASSERT(0); // impossible return -1; } === modified file 'sql/sp_head.cc' --- sql/sp_head.cc 2009-10-26 09:55:57 +0000 +++ sql/sp_head.cc 2009-11-05 14:51:31 +0000 @@ -2987,6 +2987,7 @@ int sp_instr_set_trigger_field::execute(THD *thd, uint *nextp) { DBUG_ENTER("sp_instr_set_trigger_field::execute"); + thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; DBUG_RETURN(m_lex_keeper.reset_lex_and_exec_core(thd, nextp, TRUE, this)); } === modified file 'sql/sql_class.cc' --- sql/sql_class.cc 2009-11-01 23:13:11 +0000 +++ sql/sql_class.cc 2009-11-05 14:52:23 +0000 @@ -3096,6 +3096,7 @@ void THD::reset_sub_statement_state(Sub_ } #endif + backup->count_cuted_fields= count_cuted_fields; backup->options= options; backup->in_sub_stmt= in_sub_stmt; backup->enable_slow_log= enable_slow_log; @@ -3133,6 +3134,7 @@ void THD::reset_sub_statement_state(Sub_ void THD::restore_sub_statement_state(Sub_statement_state *backup) { + DBUG_ENTER("THD::restore_sub_statement_state"); #ifndef EMBEDDED_LIBRARY /* BUG#33029, if we are replicating from a buggy master, restore auto_inc_intervals_forced so that the top statement can use the @@ -3159,6 +3161,7 @@ void THD::restore_sub_statement_state(Su /* ha_release_savepoint() never returns error. */ (void)ha_release_savepoint(this, sv); } + count_cuted_fields= backup->count_cuted_fields; transaction.savepoints= backup->savepoints; options= backup->options; in_sub_stmt= backup->in_sub_stmt; @@ -3188,6 +3191,7 @@ void THD::restore_sub_statement_state(Su */ examined_row_count+= backup->examined_row_count; cuted_fields+= backup->cuted_fields; + DBUG_VOID_RETURN; } === modified file 'sql/sql_class.h' --- sql/sql_class.h 2009-10-20 18:00:07 +0000 +++ sql/sql_class.h 2009-11-04 16:31:27 +0000 @@ -992,6 +992,7 @@ public: bool enable_slow_log; bool last_insert_id_used; SAVEPOINT *savepoints; + enum enum_check_fields count_cuted_fields; }; === modified file 'sql/sql_insert.cc' --- sql/sql_insert.cc 2009-10-16 10:29:42 +0000 +++ sql/sql_insert.cc 2009-11-05 14:51:39 +0000 @@ -3131,7 +3132,7 @@ bool select_insert::send_data(List thd->count_cuted_fields= CHECK_FIELD_WARN; // Calculate cuted fields store_values(values); - thd->count_cuted_fields= CHECK_FIELD_IGNORE; + thd->count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL; if (thd->is_error()) { table->auto_increment_field_not_null= FALSE;