summaryrefslogtreecommitdiff
path: root/mysql-test/t/parser.test
diff options
context:
space:
mode:
authordavi@mysql.com/endora.local <>2007-11-30 09:34:25 -0200
committerdavi@mysql.com/endora.local <>2007-11-30 09:34:25 -0200
commitee9bafc1c5021d92cdadb690970ab01ccfce7c27 (patch)
tree02defae9c9814164e0ec041937d3ea70f216bb7a /mysql-test/t/parser.test
parentd179bb64c261a02a21ffcc50bed8bc93dba606cf (diff)
downloadmariadb-git-ee9bafc1c5021d92cdadb690970ab01ccfce7c27.tar.gz
Bug#22312 Syntax error in expression with INTERVAL()
Parser rejects valid INTERVAL() expressions when associated with arithmetic operators. The problem is the way in which the expression and interval grammar rules were organized caused shift/reduce conflicts. The solution is to tweak the interval rules to avoid shift/reduce conflicts by removing the broken interval_expr rule and explicitly specify it's content where necessary. Original fix by Davi Arnaut, revised and improved rules by Marc Alff
Diffstat (limited to 'mysql-test/t/parser.test')
-rw-r--r--mysql-test/t/parser.test28
1 files changed, 28 insertions, 0 deletions
diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test
index 79c9129bb74..9170308a4f2 100644
--- a/mysql-test/t/parser.test
+++ b/mysql-test/t/parser.test
@@ -629,3 +629,31 @@ select atan(10, 20 "p2");
-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT
select atan(10 AS p1, 20 AS p2);
+#
+# Bug#22312 Syntax error in expression with INTERVAL()
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
+SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE;
+SELECT "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
+SELECT 1 + INTERVAL(1,0,1,2) + 1;
+SELECT INTERVAL(1^1,0,1,2) + 1;
+SELECT INTERVAL(1,0+1,2,3) * 5.5;
+SELECT INTERVAL(3,3,1+3,4+4) / 0.5;
+SELECT (INTERVAL(1,0,1,2) + 5) * 7 + INTERVAL(1,0,1,2) / 2;
+SELECT INTERVAL(1,0,1,2) + 1, 5 * INTERVAL(1,0,1,2);
+SELECT INTERVAL(0,(1*5)/2) + INTERVAL(5,4,3);
+
+--disable_warnings
+SELECT 1^1 + INTERVAL 1+1 SECOND & 1 + INTERVAL 1+1 SECOND;
+SELECT 1%2 - INTERVAL 1^1 SECOND | 1%2 - INTERVAL 1^1 SECOND;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b DATETIME);
+INSERT INTO t1 VALUES (INTERVAL(3,2,1) + 1, "1997-12-31 23:59:59" + INTERVAL 1 SECOND);
+SELECT * FROM t1 WHERE a = INTERVAL(3,2,1) + 1;
+DROP TABLE t1;