• unknown's avatar
    Fix for bug #5915 "ALTER TABLE behaves differently when converting column · bf533c4e
    unknown authored
    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.
    
    
    mysql-test/r/auto_increment.result:
      Added tests for ALTER TABLE converting columns containing NULL and 0
      values to AUTO_INCREMENT columns.
    mysql-test/r/type_timestamp.result:
      Removed test for creation of TIMESTAMP(19) columns (it is 4.0 specific).
      Added test for ALTER TABLE converting columns containing NULL values
      to TIMESTAMP columns.
    mysql-test/t/auto_increment.test:
      Added tests for ALTER TABLE converting columns containing NULL and 0
      values to AUTO_INCREMENT columns.
    mysql-test/t/type_timestamp.test:
      Removed test for creation of TIMESTAMP(19) columns (it is 4.0 specific).
      Added test for ALTER TABLE converting columns containing NULL values
      to TIMESTAMP columns.
    sql/field_conv.cc:
      Fix bug #5915 "ALTER TABLE behaves differently when converting column
      to auto_increment in 4.1". Also now when we are converting some column
      to TIMESTAMP column, we are converting NULL values to CURRENT_TIMESTAMP
      (as it was initially planned).
      
      do_copy_timestamp(): Fixed comment.
      do_copy_next_number(): We should also set auto_increment_field_not_null
        to FALSE if we have NULL in source field.
      Copy_field::set(): Moved setting of copy functions for TIMESTAMP and
        AUTO_INCREMENT fields to proper place (this was dead code before).
    sql/sql_table.cc:
      Fix for bug #5915 "ALTER TABLE behaves differently when converting column
      to auto_increment in 4.1".
      
      Instead of always forcing NO_AUTO_VALUE_ON_ZERO in ALTER TABLE it is
      better to do this 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).
    bf533c4e
field_conv.cc 14.9 KB