mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
Allow negative values for LIMIT and OFFSET. Add tests for negative LIMITs
and OFFSETs. Make the OFFSET work even if LIMIT is 0 or negative. (CVS 1052) FossilOrigin-Name: e6a752bfef24f773973c151c6262ff331a9dc57a
This commit is contained in:
@ -12,7 +12,7 @@
|
||||
# focus of this file is testing the LIMIT ... OFFSET ... clause
|
||||
# of SELECT statements.
|
||||
#
|
||||
# $Id: limit.test,v 1.7 2003/02/20 00:44:53 drh Exp $
|
||||
# $Id: limit.test,v 1.8 2003/07/16 02:19:38 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -163,4 +163,44 @@ do_test limit-5.5 {
|
||||
}
|
||||
} {1000 1528204 593161 0 3107 505 1005}
|
||||
|
||||
# There is some contraversy about whether LIMIT 0 should be the same as
|
||||
# no limit at all or if LIMIT 0 should result in zero output rows.
|
||||
#
|
||||
do_test limit-6.1 {
|
||||
execsql {
|
||||
BEGIN;
|
||||
CREATE TABLE t6(a);
|
||||
INSERT INTO t6 VALUES(1);
|
||||
INSERT INTO t6 VALUES(2);
|
||||
INSERT INTO t6 SELECT a+2 FROM t6;
|
||||
COMMIT;
|
||||
SELECT * FROM t6;
|
||||
}
|
||||
} {1 2 3 4}
|
||||
do_test limit-6.2 {
|
||||
execsql {
|
||||
SELECT * FROM t6 LIMIT -1 OFFSET -1;
|
||||
}
|
||||
} {1 2 3 4}
|
||||
do_test limit-6.3 {
|
||||
execsql {
|
||||
SELECT * FROM t6 LIMIT 2 OFFSET -123;
|
||||
}
|
||||
} {1 2}
|
||||
do_test limit-6.4 {
|
||||
execsql {
|
||||
SELECT * FROM t6 LIMIT -432 OFFSET 2;
|
||||
}
|
||||
} {3 4}
|
||||
do_test limit-6.5 {
|
||||
execsql {
|
||||
SELECT * FROM t6 LIMIT 0
|
||||
}
|
||||
} {1 2 3 4}
|
||||
do_test limit-6.6 {
|
||||
execsql {
|
||||
SELECT * FROM t6 LIMIT 0 OFFSET 1
|
||||
}
|
||||
} {2 3 4}
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user