2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A# The author disclaims copyright to this source code. In place of
2N/A# a legal notice, here is a blessing:
2N/A# May you do good and not evil.
2N/A# May you find forgiveness for yourself and forgive others.
2N/A# May you share freely, never taking more than you give.
2N/A#***********************************************************************
2N/A# This file implements regression tests for SQLite library. The
2N/A# focus of this file is testing the VACUUM statement.
2N/Aset testdir [file dirname $argv0]
2N/Aproc cksum {{db db}} {
2N/A set txt [$db eval {SELECT name, type, sql FROM sqlite_master}]\n
2N/A foreach tbl [$db eval {SELECT name FROM sqlite_master WHERE type='table'}] {
2N/A append txt [$db eval "SELECT * FROM $tbl"]\n
2N/A foreach prag {default_synchronous default_cache_size} {
2N/A append txt $prag-[$db eval "PRAGMA $prag"]\n
2N/A set cksum [string length $txt]-[md5 $txt]
2N/A CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
2N/A INSERT INTO t1 VALUES(NULL,randstr(10,100),randstr(5,50));
2N/A INSERT INTO t1 VALUES(123456,randstr(10,100),randstr(5,50));
2N/A INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
2N/A INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
2N/A INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
2N/A INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
2N/A INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
2N/A INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
2N/A INSERT INTO t1 SELECT NULL, b||'-'||rowid, c||'-'||rowid FROM t1;
2N/A CREATE INDEX i1 ON t1(b,c);
2N/A CREATE TABLE t2 AS SELECT * FROM t1;
2N/A CREATE TABLE t2 AS SELECT * FROM t1;
2N/A CREATE TABLE t3 AS SELECT * FROM t1;
2N/A CREATE VIEW v1 AS SELECT b, c FROM t3;
2N/A CREATE TRIGGER r1 AFTER DELETE ON t2 BEGIN
2N/A} {1 {cannot VACUUM from within a transaction}}
2N/Acatch {db eval COMMIT}
2N/A CREATE TABLE t4 AS SELECT * FROM t1;
2N/A CREATE TABLE t5 AS SELECT * FROM t1;
2N/A set ::cksum [cksum db2]
2N/A catch {db2 eval {SELECT count(*) FROM sqlite_master}}
2N/A# Ticket #427. Make sure VACUUM works when the EMPTY_RESULT_CALLBACKS
2N/A# pragma is turned on.
2N/A PRAGMA empty_result_callbacks=on;
2N/A# Ticket #464. Make sure VACUUM works with the sqlite_compile() API.
2N/A set VM [sqlite_compile $DB {VACUUM} TAIL]
2N/A sqlite_step $VM N VALUES COLNAMES
2N/A# Ticket #515. VACUUM after deleting and recreating the table that
2N/A CREATE TABLE Test (TestID int primary key);
2N/A INSERT INTO Test VALUES (NULL);
2N/A CREATE VIEW viewTest AS SELECT * FROM Test;
2N/A CREATE TEMP TABLE tempTest (TestID int primary key, Test2 int NULL);
2N/A INSERT INTO tempTest SELECT TestID, 1 FROM Test;
2N/A CREATE TABLE Test(TestID int primary key, Test2 int NULL);
2N/A INSERT INTO Test SELECT * FROM tempTest;