# 2001 November 6 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing the LIMIT ... OFFSET ... clause # of SELECT statements. # # $Id: limit.test,v 1.1 2001/11/06 14:10:42 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Build some test data # set fd [open data1.txt w] for {set i 1} {$i<=32} {incr i} { for {set j 0} {pow(2,$j)<$i} {incr j} {} puts $fd "[expr {32-$i}]\t[expr {10-$j}]" } close $fd execsql { CREATE TABLE t1(x int, y int); COPY t1 FROM 'data1.txt' } file delete data1.txt do_test limit-1.0 { execsql {SELECT count(*) FROM t1} } {32} do_test limit-1.1 { execsql {SELECT count(*) FROM t1 LIMIT 5} } {32} do_test limit-1.2 { execsql {SELECT x FROM t1 ORDER BY x LIMIT 5} } {0 1 2 3 4} do_test limit-1.3 { execsql {SELECT x FROM t1 ORDER BY x LIMIT 5 OFFSET 5} } {5 6 7 8 9} do_test limit-1.4 { execsql {SELECT x FROM t1 ORDER BY x LIMIT 50 OFFSET 30} } {30 31} do_test limit-1.5 { execsql {SELECT x FROM t1 ORDER BY x LIMIT 50 OFFSET 50} } {} do_test limit-1.6 { execsql {SELECT * FROM t1 a, t1 b ORDER BY a.x, b.x LIMIT 5} } {0 5 0 5 0 5 1 5 0 5 2 5 0 5 3 5 0 5 4 5} do_test limit-1.7 { execsql {SELECT * FROM t1 a, t1 b ORDER BY a.x, b.x LIMIT 5 OFFSET 32} } {1 5 0 5 1 5 1 5 1 5 2 5 1 5 3 5 1 5 4 5} finish_test