mirror of
https://github.com/MariaDB/server.git
synced 2026-05-07 07:35:32 +02:00
Bug#48525: trigger changes "Column 'id' cannot be null" behaviour
CHECK_FIELD_IGNORE was treated as CHECK_FIELD_ERROR_FOR_NULL; UPDATE...SET...NULL on NOT NULL fields behaved differently after a trigger. Now distinguishes between IGNORE and ERROR_FOR_NULL and save/restores check-field options. mysql-test/r/trigger.result: Show that UPDATE...SET...NULL on NOT NULL columns doesn't behave differently when run after a trigger. mysql-test/t/trigger.test: Show that UPDATE...SET...NULL on NOT NULL columns doesn't behave differently when run after a trigger. sql/field_conv.cc: CHECK_FIELD_IGNORE was treated as CHECK_FIELD_ERROR_FOR_NULL. Distinguish between the two. sql/sp_head.cc: Raise error as needed. sql/sql_class.cc: Save and restore check-fields options. sql/sql_class.h: Make room so we can save check-fields options. sql/sql_insert.cc: Raise error as needed.
This commit is contained in:
parent
454c003a5c
commit
28e95ba535
7 changed files with 55 additions and 9 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -178,13 +183,18 @@ set_field_to_null_with_conversions(Field *field, bool no_conversions)
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue