sl@0: # 2001 September 15 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # This file implements regression tests for SQLite library. sl@0: # sl@0: # The focus of this file is testing that LIMIT and OFFSET work for sl@0: # unusual combinations SELECT statements. sl@0: # sl@0: # $Id: select8.test,v 1.1 2008/01/12 12:48:09 drh Exp $ sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: execsql { sl@0: CREATE TABLE songs(songid, artist, timesplayed); sl@0: INSERT INTO songs VALUES(1,'one',1); sl@0: INSERT INTO songs VALUES(2,'one',2); sl@0: INSERT INTO songs VALUES(3,'two',3); sl@0: INSERT INTO songs VALUES(4,'three',5); sl@0: INSERT INTO songs VALUES(5,'one',7); sl@0: INSERT INTO songs VALUES(6,'two',11); sl@0: } sl@0: set result [execsql { sl@0: SELECT DISTINCT artist,sum(timesplayed) AS total sl@0: FROM songs sl@0: GROUP BY LOWER(artist) sl@0: }] sl@0: puts result=$result sl@0: do_test select8-1.1 { sl@0: execsql { sl@0: SELECT DISTINCT artist,sum(timesplayed) AS total sl@0: FROM songs sl@0: GROUP BY LOWER(artist) sl@0: LIMIT 1 OFFSET 1 sl@0: } sl@0: } [lrange $result 2 3] sl@0: do_test select8-1.2 { sl@0: execsql { sl@0: SELECT DISTINCT artist,sum(timesplayed) AS total sl@0: FROM songs sl@0: GROUP BY LOWER(artist) sl@0: LIMIT 2 OFFSET 1 sl@0: } sl@0: } [lrange $result 2 5] sl@0: do_test select8-1.3 { sl@0: execsql { sl@0: SELECT DISTINCT artist,sum(timesplayed) AS total sl@0: FROM songs sl@0: GROUP BY LOWER(artist) sl@0: LIMIT -1 OFFSET 2 sl@0: } sl@0: } [lrange $result 4 end] sl@0: sl@0: sl@0: finish_test