2007-06-24 12:00:42 +04:00
|
|
|
# 2002 March 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.
|
|
|
|
#
|
|
|
|
# This file implements tests for the PRAGMA command.
|
|
|
|
#
|
2007-10-09 12:29:32 +04:00
|
|
|
# $Id: pragma2.test,v 1.4 2007/10/09 08:29:33 danielk1977 Exp $
|
2007-06-24 12:00:42 +04:00
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
|
|
|
|
# Test organization:
|
|
|
|
#
|
|
|
|
# pragma2-1.*: Test freelist_count pragma on the main database.
|
|
|
|
# pragma2-2.*: Test freelist_count pragma on an attached database.
|
|
|
|
# pragma2-3.*: Test trying to write to the freelist_count is a no-op.
|
|
|
|
#
|
|
|
|
|
2007-09-12 21:01:45 +04:00
|
|
|
ifcapable !pragma||!schema_pragmas {
|
2007-06-24 12:00:42 +04:00
|
|
|
finish_test
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
# Delete the preexisting database to avoid the special setup
|
|
|
|
# that the "all.test" script does.
|
|
|
|
#
|
|
|
|
db close
|
|
|
|
file delete test.db test.db-journal
|
|
|
|
file delete test3.db test3.db-journal
|
|
|
|
sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
|
2007-06-27 14:20:00 +04:00
|
|
|
db eval {PRAGMA auto_vacuum=0}
|
2007-06-24 12:00:42 +04:00
|
|
|
|
|
|
|
do_test pragma2-1.1 {
|
|
|
|
execsql {
|
|
|
|
PRAGMA freelist_count;
|
|
|
|
}
|
|
|
|
} {0}
|
|
|
|
do_test pragma2-1.2 {
|
|
|
|
execsql {
|
|
|
|
CREATE TABLE abc(a, b, c);
|
|
|
|
PRAGMA freelist_count;
|
|
|
|
}
|
|
|
|
} {0}
|
|
|
|
do_test pragma2-1.3 {
|
|
|
|
execsql {
|
|
|
|
DROP TABLE abc;
|
|
|
|
PRAGMA freelist_count;
|
|
|
|
}
|
|
|
|
} {1}
|
|
|
|
do_test pragma2-1.4 {
|
|
|
|
execsql {
|
|
|
|
PRAGMA main.freelist_count;
|
|
|
|
}
|
|
|
|
} {1}
|
|
|
|
|
|
|
|
file delete -force test2.db
|
|
|
|
file delete -force test2.db-journal
|
|
|
|
|
2007-10-09 12:29:32 +04:00
|
|
|
ifcapable attach {
|
|
|
|
do_test pragma2-2.1 {
|
|
|
|
execsql {
|
|
|
|
ATTACH 'test2.db' AS aux;
|
|
|
|
PRAGMA aux.auto_vacuum=OFF;
|
|
|
|
PRAGMA aux.freelist_count;
|
|
|
|
}
|
|
|
|
} {0}
|
|
|
|
do_test pragma2-2.2 {
|
|
|
|
execsql {
|
|
|
|
CREATE TABLE aux.abc(a, b, c);
|
|
|
|
PRAGMA aux.freelist_count;
|
|
|
|
}
|
|
|
|
} {0}
|
|
|
|
do_test pragma2-2.3 {
|
|
|
|
set ::val [string repeat 0123456789 1000]
|
|
|
|
execsql {
|
|
|
|
INSERT INTO aux.abc VALUES(1, 2, $::val);
|
|
|
|
PRAGMA aux.freelist_count;
|
|
|
|
}
|
|
|
|
} {0}
|
|
|
|
do_test pragma2-2.4 {
|
|
|
|
expr {[file size test2.db] / 1024}
|
|
|
|
} {11}
|
|
|
|
do_test pragma2-2.5 {
|
|
|
|
execsql {
|
|
|
|
DELETE FROM aux.abc;
|
|
|
|
PRAGMA aux.freelist_count;
|
|
|
|
}
|
|
|
|
} {9}
|
|
|
|
|
|
|
|
do_test pragma2-3.1 {
|
|
|
|
execsql {
|
|
|
|
PRAGMA aux.freelist_count;
|
|
|
|
PRAGMA main.freelist_count;
|
|
|
|
PRAGMA freelist_count;
|
|
|
|
}
|
|
|
|
} {9 1 1}
|
|
|
|
do_test pragma2-3.2 {
|
|
|
|
execsql {
|
|
|
|
PRAGMA freelist_count = 500;
|
|
|
|
PRAGMA freelist_count;
|
|
|
|
}
|
|
|
|
} {1 1}
|
|
|
|
do_test pragma2-3.3 {
|
|
|
|
execsql {
|
|
|
|
PRAGMA aux.freelist_count = 500;
|
|
|
|
PRAGMA aux.freelist_count;
|
|
|
|
}
|
|
|
|
} {9 9}
|
|
|
|
}
|
2007-06-24 12:00:42 +04:00
|
|
|
|
|
|
|
finish_test
|