4d9c1dd262
FossilOrigin-Name: a195d74ff9ce836447dba4da7edcc6f1cdae5574
77 lines
2.1 KiB
Plaintext
77 lines
2.1 KiB
Plaintext
# 2009 February 24
|
|
#
|
|
# 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 "SELECT count(*)" statements.
|
|
#
|
|
# $Id: count.test,v 1.1 2009/02/24 10:48:28 danielk1977 Exp $
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
|
|
set iTest 0
|
|
foreach zIndex [list {
|
|
/* no-op */
|
|
} {
|
|
CREATE INDEX i1 ON t1(a);
|
|
}] {
|
|
incr iTest
|
|
do_test count-1.$iTest.1 {
|
|
execsql {
|
|
DROP TABLE IF EXISTS t1;
|
|
CREATE TABLE t1(a, b);
|
|
}
|
|
execsql $zIndex
|
|
execsql {
|
|
INSERT INTO t1 VALUES(1, 2);
|
|
INSERT INTO t1 VALUES(3, 4);
|
|
SELECT count(*) FROM t1;
|
|
}
|
|
} {2}
|
|
|
|
do_test count-1.$iTest.2 {
|
|
execsql {
|
|
INSERT INTO t1 SELECT * FROM t1; -- 4
|
|
INSERT INTO t1 SELECT * FROM t1; -- 8
|
|
INSERT INTO t1 SELECT * FROM t1; -- 16
|
|
INSERT INTO t1 SELECT * FROM t1; -- 32
|
|
INSERT INTO t1 SELECT * FROM t1; -- 64
|
|
INSERT INTO t1 SELECT * FROM t1; -- 128
|
|
INSERT INTO t1 SELECT * FROM t1; -- 256
|
|
SELECT count(*) FROM t1;
|
|
}
|
|
} {256}
|
|
|
|
do_test count-1.$iTest.3 {
|
|
execsql {
|
|
INSERT INTO t1 SELECT * FROM t1; -- 512
|
|
INSERT INTO t1 SELECT * FROM t1; -- 1024
|
|
INSERT INTO t1 SELECT * FROM t1; -- 2048
|
|
INSERT INTO t1 SELECT * FROM t1; -- 4096
|
|
SELECT count(*) FROM t1;
|
|
}
|
|
} {4096}
|
|
|
|
do_test count-1.$iTest.4 {
|
|
execsql {
|
|
BEGIN;
|
|
INSERT INTO t1 SELECT * FROM t1; -- 8192
|
|
INSERT INTO t1 SELECT * FROM t1; -- 16384
|
|
INSERT INTO t1 SELECT * FROM t1; -- 32768
|
|
INSERT INTO t1 SELECT * FROM t1; -- 65536
|
|
COMMIT;
|
|
SELECT count(*) FROM t1;
|
|
}
|
|
} {65536}
|
|
}
|
|
|
|
finish_test
|
|
|