1*b7654111Sdrh# 2001 September 15 2*b7654111Sdrh# 3*b7654111Sdrh# The author disclaims copyright to this source code. In place of 4*b7654111Sdrh# a legal notice, here is a blessing: 5*b7654111Sdrh# 6*b7654111Sdrh# May you do good and not evil. 7*b7654111Sdrh# May you find forgiveness for yourself and forgive others. 8*b7654111Sdrh# May you share freely, never taking more than you give. 9*b7654111Sdrh# 10*b7654111Sdrh#*********************************************************************** 11*b7654111Sdrh# This file implements regression tests for SQLite library. 12*b7654111Sdrh# 13*b7654111Sdrh# The focus of this file is testing that LIMIT and OFFSET work for 14*b7654111Sdrh# unusual combinations SELECT statements. 15*b7654111Sdrh# 16*b7654111Sdrh# $Id: select8.test,v 1.1 2008/01/12 12:48:09 drh Exp $ 17*b7654111Sdrh 18*b7654111Sdrhset testdir [file dirname $argv0] 19*b7654111Sdrhsource $testdir/tester.tcl 20*b7654111Sdrh 21*b7654111Sdrhexecsql { 22*b7654111Sdrh CREATE TABLE songs(songid, artist, timesplayed); 23*b7654111Sdrh INSERT INTO songs VALUES(1,'one',1); 24*b7654111Sdrh INSERT INTO songs VALUES(2,'one',2); 25*b7654111Sdrh INSERT INTO songs VALUES(3,'two',3); 26*b7654111Sdrh INSERT INTO songs VALUES(4,'three',5); 27*b7654111Sdrh INSERT INTO songs VALUES(5,'one',7); 28*b7654111Sdrh INSERT INTO songs VALUES(6,'two',11); 29*b7654111Sdrh} 30*b7654111Sdrhset result [execsql { 31*b7654111Sdrh SELECT DISTINCT artist,sum(timesplayed) AS total 32*b7654111Sdrh FROM songs 33*b7654111Sdrh GROUP BY LOWER(artist) 34*b7654111Sdrh}] 35*b7654111Sdrhdo_test select8-1.1 { 36*b7654111Sdrh execsql { 37*b7654111Sdrh SELECT DISTINCT artist,sum(timesplayed) AS total 38*b7654111Sdrh FROM songs 39*b7654111Sdrh GROUP BY LOWER(artist) 40*b7654111Sdrh LIMIT 1 OFFSET 1 41*b7654111Sdrh } 42*b7654111Sdrh} [lrange $result 2 3] 43*b7654111Sdrhdo_test select8-1.2 { 44*b7654111Sdrh execsql { 45*b7654111Sdrh SELECT DISTINCT artist,sum(timesplayed) AS total 46*b7654111Sdrh FROM songs 47*b7654111Sdrh GROUP BY LOWER(artist) 48*b7654111Sdrh LIMIT 2 OFFSET 1 49*b7654111Sdrh } 50*b7654111Sdrh} [lrange $result 2 5] 51*b7654111Sdrhdo_test select8-1.3 { 52*b7654111Sdrh execsql { 53*b7654111Sdrh SELECT DISTINCT artist,sum(timesplayed) AS total 54*b7654111Sdrh FROM songs 55*b7654111Sdrh GROUP BY LOWER(artist) 56*b7654111Sdrh LIMIT -1 OFFSET 2 57*b7654111Sdrh } 58*b7654111Sdrh} [lrange $result 4 end] 59*b7654111Sdrh 60*b7654111Sdrh 61*b7654111Sdrhfinish_test 62