summaryrefslogtreecommitdiff
path: root/mysql-test/t/strict.test
diff options
context:
space:
mode:
authorunknown <ramil/ram@mysql.com/myoffice.izhnet.ru>2006-07-12 11:38:11 +0500
committerunknown <ramil/ram@mysql.com/myoffice.izhnet.ru>2006-07-12 11:38:11 +0500
commit97a3d52682e9e92d2526b5260521d3a35bdce311 (patch)
tree4d9763aadeb02a1ab65d1606d49622eea1ad9360 /mysql-test/t/strict.test
parent4d71b8f8f91fae06641a4913c3cfba6ba8929f57 (diff)
downloadmariadb-git-97a3d52682e9e92d2526b5260521d3a35bdce311.tar.gz
Fix for bug #19370: DateTime datatype in MySQL has two bugs in it
mysql-test/r/date_formats.result: Fix for bug #19370: DateTime datatype in MySQL has two bugs in it - results adjusted mysql-test/r/strict.result: Fix for bug #19370: DateTime datatype in MySQL has two bugs in it - results adjusted mysql-test/r/type_datetime.result: Fix for bug #19370: DateTime datatype in MySQL has two bugs in it - results adjusted mysql-test/t/strict.test: Fix for bug #19370: DateTime datatype in MySQL has two bugs in it - tests adjusted sql-common/my_time.c: Fix for bug #19370: DateTime datatype in MySQL has two bugs in it - Regardless of the title of the bug the only real bug is that it doesn't make sense to have only some invalid parts in a date. E.g. a valid day among invalid years or months is totally ambiguous and we should refuse to guess what it means. To fix it, we add a check that both the year is zero and either day or month are zero (year and (day or month)), and if they are then we reject such dates. Doing so should adequately fix the reported problem.
Diffstat (limited to 'mysql-test/t/strict.test')
-rw-r--r--mysql-test/t/strict.test18
1 files changed, 16 insertions, 2 deletions
diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test
index ce269b42ee9..6f22b81172d 100644
--- a/mysql-test/t/strict.test
+++ b/mysql-test/t/strict.test
@@ -13,7 +13,9 @@ DROP TABLE IF EXISTS t1;
# Test INSERT with DATE
CREATE TABLE t1 (col1 date);
-INSERT INTO t1 VALUES('2004-01-01'),('0000-10-31'),('2004-02-29');
+INSERT INTO t1 VALUES('2004-01-01'),('2004-02-29');
+--error 1292
+INSERT INTO t1 VALUES('0000-10-31');
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid date value>
@@ -97,7 +99,9 @@ set @@sql_mode='ansi,traditional';
# Test INSERT with DATETIME
CREATE TABLE t1 (col1 datetime);
-INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('0000-10-31 15:30:00'),('2004-02-29 15:30:00');
+INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('2004-02-29 15:30:00');
+--error 1292
+INSERT INTO t1 VALUES('0000-10-31 15:30:00');
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid datetime value>
@@ -190,6 +194,7 @@ INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid date value>
+--error 1292
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
--error 1292
@@ -211,6 +216,7 @@ INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid datetime value>
+--error 1292
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
--error 1292
@@ -264,6 +270,8 @@ INSERT INTO t1 (col3) VALUES (CAST('2004-10-15 10:15' AS DATETIME));
## Test INSERT with CAST AS DATE into DATE
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid date value>
+
+--error 1292
INSERT INTO t1 (col1) VALUES(CAST('0000-10-31' AS DATE));
--error 1292
@@ -290,6 +298,8 @@ INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE));
## Test INSERT with CAST AS DATETIME into DATETIME
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid datetime value>
+
+--error 1292
INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
--error 1292
@@ -356,6 +366,8 @@ INSERT INTO t1 (col3) VALUES (CONVERT('2004-10-15 10:15',DATETIME));
## Test INSERT with CONVERT to DATE into DATE
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid date value>
+
+--error 1292
INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE));
--error 1292
@@ -381,6 +393,8 @@ INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE));
## Test INSERT with CONVERT to DATETIME into DATETIME
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid datetime value>
+
+--error 1292
INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
--error 1292