diff options
author | dlenev@brandersnatch.localdomain <> | 2004-10-07 13:02:39 +0400 |
---|---|---|
committer | dlenev@brandersnatch.localdomain <> | 2004-10-07 13:02:39 +0400 |
commit | 1f54900630636f502a4dbf16faefb4e132db0d3f (patch) | |
tree | fe89ee02ecc0b2b98bcca9915320aa37cb8ff4c9 /sql/field_conv.cc | |
parent | 96458f8f64641d5b974a17733af8c709b513bfe0 (diff) | |
download | mariadb-git-1f54900630636f502a4dbf16faefb4e132db0d3f.tar.gz |
Fix for bug #5915 "ALTER TABLE behaves differently when converting column
to auto_increment in 4.1".
Now we are enforcing NO_AUTO_VALUE_ON_ZERO mode during ALTER TABLE only
if we are converting one auto_increment column to another auto_increment
column (this also includes most common case when we don't do anything
with such column).
Also now when we convert some column to TIMESTAMP NOT NULL column with
ALTER TABLE we convert NULL values to current timestamp, (as we do this
in INSERT). One can still get old behavior by setting system TIMESTAMP
variable to 0.
Diffstat (limited to 'sql/field_conv.cc')
-rw-r--r-- | sql/field_conv.cc | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/sql/field_conv.cc b/sql/field_conv.cc index c9b21b5f96f..890687fc925 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -252,7 +252,8 @@ static void do_copy_timestamp(Copy_field *copy) { if (*copy->from_null_ptr & copy->from_bit) { - ((Field_timestamp*) copy->to_field)->set_time();// Same as set_field_to_null + /* Same as in set_field_to_null_with_conversions() */ + ((Field_timestamp*) copy->to_field)->set_time(); } else (copy->do_copy2)(copy); @@ -262,7 +263,11 @@ static void do_copy_timestamp(Copy_field *copy) static void do_copy_next_number(Copy_field *copy) { if (*copy->from_null_ptr & copy->from_bit) - copy->to_field->reset(); // Same as set_field_to_null + { + /* Same as in set_field_to_null_with_conversions() */ + copy->to_field->table->auto_increment_field_not_null= FALSE; + copy->to_field->reset(); + } else (copy->do_copy2)(copy); } @@ -437,18 +442,20 @@ void Copy_field::set(Field *to,Field *from,bool save) } } else - do_copy=do_copy_not_null; + { + if (to_field->type() == FIELD_TYPE_TIMESTAMP) + do_copy= do_copy_timestamp; // Automatic timestamp + else if (to_field == to_field->table->next_number_field) + do_copy= do_copy_next_number; + else + do_copy= do_copy_not_null; + } } else if (to_field->real_maybe_null()) { to_null_ptr= to->null_ptr; to_bit= to->null_bit; - if (to_field->type() == FIELD_TYPE_TIMESTAMP) - do_copy=do_copy_timestamp; // Automatic timestamp - else if (to_field == to_field->table->next_number_field) - do_copy=do_copy_next_number; - else - do_copy=do_copy_maybe_null; + do_copy= do_copy_maybe_null; } else do_copy=0; |