summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@macbook.gmz>2007-02-06 11:08:57 +0200
committerunknown <gkodinov/kgeorge@macbook.gmz>2007-02-06 11:08:57 +0200
commitc35ceeca9e11062516bd93d10d89ac818a6e1f23 (patch)
tree2c29aa1d71aa6438281906e4da3ddab01ebbe7ba /mysql-test
parent1534bb792ba4b8ca5806ed2953274c31fc8c8e44 (diff)
downloadmariadb-git-c35ceeca9e11062516bd93d10d89ac818a6e1f23.tar.gz
Bug #22344: InnoDB keys act strange on datetime vs timestamp comparison
Ignoring error codes from type conversion allows default (wrong) values to go unnoticed in the formation of index search conditions. Fixed by correctly checking for conversion errors. mysql-test/r/select.result: Bug #22344: InnoDB keys act strange on datetime vs timestamp comparison - test case mysql-test/t/select.test: Bug #22344: InnoDB keys act strange on datetime vs timestamp comparison - test case sql/field.h: Bug #22344: InnoDB keys act strange on datetime vs timestamp comparison - don't ignore coversion errors sql/field_conv.cc: Bug #22344: InnoDB keys act strange on datetime vs timestamp comparison - don't ignore coversion errors sql/item.cc: Bug #22344: InnoDB keys act strange on datetime vs timestamp comparison - don't ignore coversion errors
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/select.result28
-rw-r--r--mysql-test/t/select.test23
2 files changed, 51 insertions, 0 deletions
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index f3938fd6413..96af58789ec 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -3728,3 +3728,31 @@ WHERE ID_better=1 AND ID1_with_null IS NULL AND
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref idx1,idx2 idx2 4 const 1 Using where
DROP TABLE t1;
+CREATE TABLE t1 (a INT, ts TIMESTAMP, KEY ts(ts));
+INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00");
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+CREATE TABLE t2 (a INT, dt1 DATETIME, dt2 DATETIME, PRIMARY KEY (a));
+INSERT INTO t2 VALUES (30, "2006-01-01 00:00:00", "2999-12-31 00:00:00");
+INSERT INTO t2 SELECT a+1,dt1,dt2 FROM t2;
+ANALYZE TABLE t2;
+Table Op Msg_type Msg_text
+test.t2 analyze status OK
+EXPLAIN
+SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30
+AND t1.ts BETWEEN t2.dt1 AND t2.dt2
+AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1
+1 SIMPLE t1 range ts ts 4 NULL 1 Using where
+Warnings:
+Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1
+SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30
+AND t1.ts BETWEEN t2.dt1 AND t2.dt2
+AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";
+a ts a dt1 dt2
+30 2006-01-03 23:00:00 30 2006-01-01 00:00:00 2999-12-31 00:00:00
+Warnings:
+Warning 1292 Incorrect datetime value: '2999-12-31 00:00:00' for column 'ts' at row 1
+DROP TABLE t1,t2;
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 19c7d742f5b..dfa3c1ac2a4 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -3207,3 +3207,26 @@ EXPLAIN SELECT * FROM t1
(ID2_with_null=1 OR ID2_with_null=2);
DROP TABLE t1;
+
+#
+# Bug #22344: InnoDB keys act strange on datetime vs timestamp comparison
+#
+CREATE TABLE t1 (a INT, ts TIMESTAMP, KEY ts(ts));
+INSERT INTO t1 VALUES (30,"2006-01-03 23:00:00"), (31,"2006-01-03 23:00:00");
+ANALYZE TABLE t1;
+
+CREATE TABLE t2 (a INT, dt1 DATETIME, dt2 DATETIME, PRIMARY KEY (a));
+INSERT INTO t2 VALUES (30, "2006-01-01 00:00:00", "2999-12-31 00:00:00");
+INSERT INTO t2 SELECT a+1,dt1,dt2 FROM t2;
+ANALYZE TABLE t2;
+
+EXPLAIN
+SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30
+ AND t1.ts BETWEEN t2.dt1 AND t2.dt2
+ AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";
+
+SELECT * FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=30
+ AND t1.ts BETWEEN t2.dt1 AND t2.dt2
+ AND t1.ts BETWEEN "2006-01-01" AND "2006-12-31";
+
+DROP TABLE t1,t2;