summaryrefslogtreecommitdiff
path: root/mysql-test/t/create.test
diff options
context:
space:
mode:
authoranozdrin/alik@quad. <>2008-02-14 18:13:40 +0300
committeranozdrin/alik@quad. <>2008-02-14 18:13:40 +0300
commit6bf1306b137a7166bb8b3f8e76e3813eb2bc7891 (patch)
tree035ab98e4fada14efa08ef707a2910e40a220745 /mysql-test/t/create.test
parent7e88f7718c9c58556f0b717226b19ad4b4c94aca (diff)
downloadmariadb-git-6bf1306b137a7166bb8b3f8e76e3813eb2bc7891.tar.gz
A patch for Bug#18834: ALTER TABLE ADD INDEX on table with
two timestamp fields. The actual problem here was that CREATE TABLE allowed zero date as a default value for a TIMESTAMP column in NO_ZERO_DATE mode. The thing is that for TIMESTAMP date type specific rule is applied: column_name TIMESTAMP == column_name TIMESTAMP DEFAULT 0 whever for any other date data type column_name TYPE == column_name TYPE DEFAULT NULL The fix is to raise an error when we're in NO_ZERO_DATE mode and there is TIMESTAMP column w/o default value.
Diffstat (limited to 'mysql-test/t/create.test')
-rw-r--r--mysql-test/t/create.test64
1 files changed, 64 insertions, 0 deletions
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 09170cbc4f5..8912fd46b42 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -1385,4 +1385,68 @@ DROP TABLE t2;
--echo # -- End of test case for Bug#21380.
--echo
+--echo # --
+--echo # -- Bug#18834: ALTER TABLE ADD INDEX on table with two timestamp fields
+--echo # --
+--echo
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+DROP TABLE IF EXISTS t3;
+--enable_warnings
+
+--echo
+
+CREATE TABLE t1(c1 TIMESTAMP, c2 TIMESTAMP);
+
+--echo
+
+SET sql_mode = NO_ZERO_DATE;
+
+--echo
+--error ER_INVALID_DEFAULT
+CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP DEFAULT 0);
+
+--echo
+--error ER_INVALID_DEFAULT
+CREATE TABLE t2(c1 TIMESTAMP, c2 TIMESTAMP);
+
+--echo
+--echo # -- Check that NULL column still can be created.
+CREATE TABLE t2(c1 TIMESTAMP NULL);
+
+--echo
+--echo # -- Check ALTER TABLE.
+--error ER_INVALID_DEFAULT
+ALTER TABLE t1 ADD INDEX(c1);
+
+--echo
+--echo # -- Check DATETIME.
+SET sql_mode = '';
+
+--echo
+
+CREATE TABLE t3(c1 DATETIME NOT NULL);
+INSERT INTO t3 VALUES (0);
+
+--echo
+SET sql_mode = TRADITIONAL;
+
+--echo
+--error ER_TRUNCATED_WRONG_VALUE
+ALTER TABLE t3 ADD INDEX(c1);
+
+--echo
+--echo # -- Cleanup.
+
+SET sql_mode = '';
+DROP TABLE t1;
+DROP TABLE t2;
+DROP TABLE t3;
+
+--echo
+--echo # -- End of Bug#18834.
+--echo
+
--echo End of 5.1 tests