1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/select8.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,62 @@
1.4 +# 2001 September 15
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +# This file implements regression tests for SQLite library.
1.15 +#
1.16 +# The focus of this file is testing that LIMIT and OFFSET work for
1.17 +# unusual combinations SELECT statements.
1.18 +#
1.19 +# $Id: select8.test,v 1.1 2008/01/12 12:48:09 drh Exp $
1.20 +
1.21 +set testdir [file dirname $argv0]
1.22 +source $testdir/tester.tcl
1.23 +
1.24 +execsql {
1.25 + CREATE TABLE songs(songid, artist, timesplayed);
1.26 + INSERT INTO songs VALUES(1,'one',1);
1.27 + INSERT INTO songs VALUES(2,'one',2);
1.28 + INSERT INTO songs VALUES(3,'two',3);
1.29 + INSERT INTO songs VALUES(4,'three',5);
1.30 + INSERT INTO songs VALUES(5,'one',7);
1.31 + INSERT INTO songs VALUES(6,'two',11);
1.32 +}
1.33 +set result [execsql {
1.34 + SELECT DISTINCT artist,sum(timesplayed) AS total
1.35 + FROM songs
1.36 + GROUP BY LOWER(artist)
1.37 +}]
1.38 +puts result=$result
1.39 +do_test select8-1.1 {
1.40 + execsql {
1.41 + SELECT DISTINCT artist,sum(timesplayed) AS total
1.42 + FROM songs
1.43 + GROUP BY LOWER(artist)
1.44 + LIMIT 1 OFFSET 1
1.45 + }
1.46 +} [lrange $result 2 3]
1.47 +do_test select8-1.2 {
1.48 + execsql {
1.49 + SELECT DISTINCT artist,sum(timesplayed) AS total
1.50 + FROM songs
1.51 + GROUP BY LOWER(artist)
1.52 + LIMIT 2 OFFSET 1
1.53 + }
1.54 +} [lrange $result 2 5]
1.55 +do_test select8-1.3 {
1.56 + execsql {
1.57 + SELECT DISTINCT artist,sum(timesplayed) AS total
1.58 + FROM songs
1.59 + GROUP BY LOWER(artist)
1.60 + LIMIT -1 OFFSET 2
1.61 + }
1.62 +} [lrange $result 4 end]
1.63 +
1.64 +
1.65 +finish_test