diff options
Diffstat (limited to 'sql/field.cc')
-rw-r--r-- | sql/field.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sql/field.cc b/sql/field.cc index 18f99945645..080cf34c76d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1375,7 +1375,25 @@ bool Field::load_data_set_no_data(THD *thd, bool fixed_format) { reset(); // Do not use the DEFAULT value if (fixed_format) + { set_notnull(); + /* + We're loading a fixed format file, e.g.: + LOAD DATA INFILE 't1.txt' INTO TABLE t1 FIELDS TERMINATED BY ''; + Suppose the file ended unexpectedly and no data was provided for an + auto-increment column in the current row. + Historically, if sql_mode=NO_AUTO_VALUE_ON_ZERO, then the column value + is set to 0 in such case (the next auto_increment value is not used). + This behaviour was introduced by the fix for "bug#12053" in mysql-4.1. + Note, loading a delimited file works differently: + "no data" is not converted to 0 on NO_AUTO_VALUE_ON_ZERO: + it's considered as equal to setting the column to NULL, + which is then replaced to the next auto_increment value. + This difference seems to be intentional. + */ + if (this == table->next_number_field) + table->auto_increment_field_not_null= true; + } set_has_explicit_value(); // Do not auto-update this field return false; } |