• unknown's avatar
    Bug#27507: Wrong DATETIME value was allowed by ALTER TABLE in the NO_ZERO_DATE · f3b78f34
    unknown authored
    mode.
    
    When a new DATE/DATETIME field without default value is being added by the
    ALTER TABLE the '0000-00-00' value is used as the default one. But it wasn't
    checked whether such value was allowed by the set sql mode. Due to this
    '0000-00-00' values was allowed for DATE/DATETIME fields even in the
    NO_ZERO_DATE mode.
    
    Now the mysql_alter_table() function checks whether the '0000-00-00' value
    is allowed for DATE/DATETIME fields by the set sql mode.
    The new error_if_not_empty flag is used in the mysql_alter_table() function
    to indicate that it should abort if the table being altered isn't empty.
    The new new_datetime_field field is used in the mysql_alter_table() function
    for error throwing purposes. 
    The new error_if_not_empty parameter is added to the copy_data_between_tables()
    function to indicate the it should return error if the source table isn't empty.
    
    
    mysql-test/t/alter_table.test:
      Added a test case for the bug#27507: Wrong DATETIME value was allowed by
      ALTER TABLE in the NO_ZERO_DATE mode.
    mysql-test/r/alter_table.result:
      Added a test case for the bug#27507: Wrong DATETIME value was allowed by
      ALTER TABLE in the NO_ZERO_DATE mode.
    sql/sql_table.cc:
      Bug#27507: Wrong DATETIME value was allowed by ALTER TABLE in the NO_ZERO_DATE
      mode.
      Now the mysql_alter_table() function checks whether the '0000-00-00' value
      is allowed for DATE/DATETIME fields by the set sql mode.
      The new error_if_not_empty flag is used in the mysql_alter_table() function
      to indicate that it should abort if the table being altered isn't empty.
      The new new_datetime_field field is used in the mysql_alter_table() function
      for error throwing purposes. 
      The new error_if_not_empty parameter is added to the copy_data_between_tables()
      function to indicate the it should return error if the source table isn't empty.
    f3b78f34
sql_table.cc 133 KB