diff options
author | unknown <evgen@moonbone.local> | 2007-05-22 00:22:53 +0400 |
---|---|---|
committer | unknown <evgen@moonbone.local> | 2007-05-22 00:22:53 +0400 |
commit | f3b78f34e511305fec193f4cdbc8710f26baf993 (patch) | |
tree | 92d5f891dbb700d9b403af31359afaa1030d358b /mysql-test/r/alter_table.result | |
parent | bc31b650afb6981e50a7e947ac2a80727cf64d0a (diff) | |
download | mariadb-git-f3b78f34e511305fec193f4cdbc8710f26baf993.tar.gz |
Bug#27507: Wrong DATETIME value was allowed by ALTER TABLE in the NO_ZERO_DATE
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.
Diffstat (limited to 'mysql-test/r/alter_table.result')
-rw-r--r-- | mysql-test/r/alter_table.result | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 280cedb8b89..4eace9ac628 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -884,3 +884,22 @@ id 50 51 drop table t1; +set @orig_sql_mode = @@sql_mode; +set sql_mode="no_zero_date"; +create table t1(f1 int); +alter table t1 add column f2 datetime not null, add column f21 date not null; +insert into t1 values(1,'2000-01-01','2000-01-01'); +alter table t1 add column f3 datetime not null; +ERROR 22007: Incorrect datetime value: '0000-00-00 00:00:00' for column 'f3' at row 1 +alter table t1 add column f3 date not null; +ERROR 22007: Incorrect date value: '0000-00-00' for column 'f3' at row 1 +alter table t1 add column f4 datetime not null default '2002-02-02', +add column f41 date not null; +ERROR 22007: Incorrect date value: '0000-00-00' for column 'f41' at row 1 +alter table t1 add column f4 datetime not null default '2002-02-02', +add column f41 date not null default '2002-02-02'; +select * from t1; +f1 f2 f21 f4 f41 +1 2000-01-01 00:00:00 2000-01-01 2002-02-02 00:00:00 2002-02-02 +drop table t1; +set sql_mode= @orig_sql_mode; |