diff options
author | Sergei Golubchik <serg@mariadb.org> | 2015-12-16 12:12:01 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2015-12-21 21:30:46 +0100 |
commit | ad5db17e882fea36dcae6f6e61996b5f9bf28962 (patch) | |
tree | 06fa978199bd8fb09874de989984381e28bb4715 /sql/field_conv.cc | |
parent | de7636e1470848bb5d92437b7c6c7b9c4d6caedc (diff) | |
download | mariadb-git-ad5db17e882fea36dcae6f6e61996b5f9bf28962.tar.gz |
cleanup
* move common code to a new set_bad_null_error() function
* move repeated comparison out of the loop
* remove unused code
* unused method Table_triggers_list::set_table
* redundant condition (if (table) after table was dereferenced)
* add an assert
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r-- | sql/field_conv.cc | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 0ad8cee0c3b..df4730a50ce 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -116,24 +116,11 @@ static void do_outer_field_to_null_str(Copy_field *copy) } -int -set_field_to_null(Field *field) +static int set_bad_null_error(Field *field, int err) { - if (field->table->null_catch_flags & CHECK_ROW_FOR_NULLS_TO_REJECT) - { - field->table->null_catch_flags|= REJECT_ROW_DUE_TO_NULL_FIELDS; - return -1; - } - if (field->real_maybe_null()) - { - field->set_null(); - field->reset(); - return 0; - } - field->reset(); switch (field->table->in_use->count_cuted_fields) { case CHECK_FIELD_WARN: - field->set_warning(Sql_condition::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + field->set_warning(Sql_condition::WARN_LEVEL_WARN, err, 1); /* fall through */ case CHECK_FIELD_IGNORE: return 0; @@ -147,6 +134,24 @@ set_field_to_null(Field *field) } +int set_field_to_null(Field *field) +{ + if (field->table->null_catch_flags & CHECK_ROW_FOR_NULLS_TO_REJECT) + { + field->table->null_catch_flags|= REJECT_ROW_DUE_TO_NULL_FIELDS; + return -1; + } + if (field->real_maybe_null()) + { + field->set_null(); + field->reset(); + return 0; + } + field->reset(); + return set_bad_null_error(field, WARN_DATA_TRUNCATED); +} + + /** Set field to NULL or TIMESTAMP or to next auto_increment number. @@ -200,19 +205,7 @@ 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() } - switch (field->table->in_use->count_cuted_fields) { - case CHECK_FIELD_WARN: - field->set_warning(Sql_condition::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; - } - DBUG_ASSERT(0); // impossible - return -1; + return set_bad_null_error(field, ER_BAD_NULL_ERROR); } |