summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authormalff/marcsql@weblab.(none) <>2007-01-03 11:47:01 -0700
committermalff/marcsql@weblab.(none) <>2007-01-03 11:47:01 -0700
commit236000ae6689c345d71e837c2b1b95f91c656e5b (patch)
tree0736c3510c9bc70507f88e0efd9b6c478d22349f /mysql-test
parentba7a03759bb4d70d951138fda64cab87d1f95e61 (diff)
downloadmariadb-git-236000ae6689c345d71e837c2b1b95f91c656e5b.tar.gz
Bug#6298 (LIMIT #, -1 no longer works to set start with no end limit)
With MySQL 3.23 and 4.0, the syntax 'LIMIT N, -1' is accepted, and returns all the rows located after row N. This behavior, however, is not the intended result, and defeats the purpose of LIMIT, which is to constrain the size of a result set. With MySQL 4.1 and later, this construct is correctly detected as a syntax error. This fix does not change the production code, and only adds a new test case to improve test coverage in this area, to enforce in the test suite the intended behavior.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/select.result6
-rw-r--r--mysql-test/t/select.test20
2 files changed, 26 insertions, 0 deletions
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 44063c1e890..a7f6f638966 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -3611,3 +3611,9 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 range si,ai si 5 NULL 2 Using where
1 SIMPLE t3 eq_ref PRIMARY,ci PRIMARY 4 test.t2.a 1 Using where
DROP TABLE t1,t2,t3;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1(a int);
+INSERT into t1 values (1), (2), (3);
+SELECT * FROM t1 LIMIT 2, -1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1' at line 1
+DROP TABLE t1;
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 0c82cef867f..332389220f6 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -3092,3 +3092,23 @@ SELECT t3.a FROM t1,t2,t3
t3.c IN ('bb','ee');
DROP TABLE t1,t2,t3;
+
+#
+# Bug#6298: LIMIT #, -1 no longer works to set start with no end limit
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1(a int);
+INSERT into t1 values (1), (2), (3);
+
+# LIMIT N, -1 was accepted by accident in 4.0, but was not intended.
+# This test verifies that this illegal construct is now properly detected.
+
+--error ER_PARSE_ERROR
+SELECT * FROM t1 LIMIT 2, -1;
+
+DROP TABLE t1;
+