=== modified file 'mysql-test/r/type_timestamp.result' --- mysql-test/r/type_timestamp.result 2012-10-17 12:43:56 +0000 +++ mysql-test/r/type_timestamp.result 2014-03-13 12:53:35 +0000 @@ -645,3 +645,75 @@ MAX(dt) = '2011-01-06 12:34:30' 1 DROP TABLE t1; End of 5.5 tests +# Test for bug#11747847 - 34280: create table fails if NO_ZERO_DATE +# or NO_ZERO_IN_DATE SQL mode is set. +DROP TABLE IF EXISTS t1, t2, t3; +SET @org_mode=@@sql_mode; +#Table creation in strict mode +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +ERROR 42000: Invalid default value for 'c1' +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +ERROR 42000: Invalid default value for 'c1' +SET @@sql_mode='NO_ZERO_IN_DATE,STRICT_ALL_TABLES'; +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +ERROR 42000: Invalid default value for 'c1' +#Table creation in non-strict mode but with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE'; +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +CREATE TABLE t2 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +SET @@sql_mode='NO_ZERO_IN_DATE'; +CREATE TABLE t3 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +DROP TABLE t1, t2, t3; +#Table creation with out any SQL modes +SET @@sql_mode=''; +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +CREATE TABLE t2 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +CREATE TABLE t3 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +Warnings: +Warning 1264 Out of range value for column 'c1' at row 1 +DROP TABLE t1, t2, t3; +CREATE TABLE t1 (c1 INT); +#Alter table in strict mode with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT 0; +ERROR 42000: Invalid default value for 'c2' +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT '0000-00-00'; +ERROR 42000: Invalid default value for 'c2' +SET @@sql_mode='NO_ZERO_IN_DATE,STRICT_ALL_TABLES'; +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT '2012-02-00'; +ERROR 42000: Invalid default value for 'c2' +#Alter table in non-strict mode but with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE'; +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT 0; +Warnings: +Warning 1264 Out of range value for column 'c2' at row 1 +ALTER TABLE t1 ADD c3 TIMESTAMP DEFAULT '0000-00-00'; +Warnings: +Warning 1264 Out of range value for column 'c2' at row 1 +Warning 1264 Out of range value for column 'c3' at row 1 +SET @@sql_mode='NO_ZERO_IN_DATE'; +ALTER TABLE t1 ADD c4 TIMESTAMP DEFAULT '2012-02-00'; +Warnings: +Warning 1264 Out of range value for column 'c4' at row 1 +DROP TABLE t1; +CREATE TABLE t1 (c1 INT); +#Alter table with out any SQL modes +SET @@sql_mode=''; +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT 0; +ALTER TABLE t1 ADD c3 TIMESTAMP DEFAULT '0000-00-00'; +ALTER TABLE t1 ADD c4 TIMESTAMP DEFAULT '2012-02-00'; +Warnings: +Warning 1264 Out of range value for column 'c4' at row 1 +DROP TABLE t1; +SET @@sql_mode= @org_mode; +# END of Test for bug#11747847 - 34280 +# +# End of 5.6 tests +# === modified file 'mysql-test/t/type_timestamp.test' --- mysql-test/t/type_timestamp.test 2012-10-17 12:43:56 +0000 +++ mysql-test/t/type_timestamp.test 2014-03-13 12:54:47 +0000 @@ -446,3 +446,72 @@ SELECT MAX(dt) = '2011-01-06 12:34:30' F DROP TABLE t1; --echo End of 5.5 tests + +--echo # +--echo # Test for bug#11747847 - 34280: create table fails if NO_ZERO_DATE +--echo # or NO_ZERO_IN_DATE SQL mode is set. + +--disable_warnings +DROP TABLE IF EXISTS t1, t2, t3; +--enable_warnings +SET @org_mode=@@sql_mode; + +--echo #Table creation in strict mode +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +--error ER_INVALID_DEFAULT +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +--error ER_INVALID_DEFAULT +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +SET @@sql_mode='NO_ZERO_IN_DATE,STRICT_ALL_TABLES'; +--error ER_INVALID_DEFAULT +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); + +--echo #Table creation in non-strict mode but with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE'; +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +CREATE TABLE t2 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +SET @@sql_mode='NO_ZERO_IN_DATE'; +CREATE TABLE t3 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +DROP TABLE t1, t2, t3; + +--echo #Table creation with out any SQL modes +SET @@sql_mode=''; +CREATE TABLE t1 (c1 TIMESTAMP DEFAULT 0); +CREATE TABLE t2 (c1 TIMESTAMP DEFAULT '0000-00-00 00:00:00'); +CREATE TABLE t3 (c1 TIMESTAMP DEFAULT '2012-02-00 12:12:12'); +DROP TABLE t1, t2, t3; + +CREATE TABLE t1 (c1 INT); +--echo #Alter table in strict mode with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE,STRICT_ALL_TABLES'; +--error ER_INVALID_DEFAULT +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT 0; +--error ER_INVALID_DEFAULT +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT '0000-00-00'; +SET @@sql_mode='NO_ZERO_IN_DATE,STRICT_ALL_TABLES'; +--error ER_INVALID_DEFAULT +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT '2012-02-00'; + +--echo #Alter table in non-strict mode but with NO_ZERO_DATE/NO_ZERO_IN_DATE +SET @@sql_mode='NO_ZERO_DATE'; +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT 0; +ALTER TABLE t1 ADD c3 TIMESTAMP DEFAULT '0000-00-00'; +SET @@sql_mode='NO_ZERO_IN_DATE'; +ALTER TABLE t1 ADD c4 TIMESTAMP DEFAULT '2012-02-00'; +DROP TABLE t1; + +CREATE TABLE t1 (c1 INT); +--echo #Alter table with out any SQL modes +SET @@sql_mode=''; +ALTER TABLE t1 ADD c2 TIMESTAMP DEFAULT 0; +ALTER TABLE t1 ADD c3 TIMESTAMP DEFAULT '0000-00-00'; +ALTER TABLE t1 ADD c4 TIMESTAMP DEFAULT '2012-02-00'; +DROP TABLE t1; + +SET @@sql_mode= @org_mode; +--echo # END of Test for bug#11747847 - 34280 + +--echo # +--echo # End of 5.6 tests +--echo # +