libdb/test/sql/bdb_logsize.test
2011-09-13 13:44:24 -04:00

93 lines
2.2 KiB
Text

#
# 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 the pragma
# journal_size_limit, which has been redefined for Berekeley DB to set
# the size of log files, and how often those logfiles can be removed
# after a checkpoint.
#
set testdir [file dirname $argv0]/../../lang/sql/sqlite/test
source $testdir/tester.tcl
reset_db
# Test that pragma journal_size_limit works as expected.
#
set ::logsize 2097152
# Returns default value of 2MB
do_test logsize-1.1 {
execsql {
PRAGMA journal_size_limit;
}
} $logsize
# Changes log size to 10K
do_test logsize-1.2 {
execsql {
PRAGMA journal_size_limit=10240;
}
} {10240}
# Ignores values that are too small
do_test logsize-1.3 {
execsql {
PRAGMA journal_size_limit=10;
}
} {10240}
# Resets to the default when given a value of -1
do_test logsize-1.4 {
execsql {
PRAGMA journal_size_limit=-1;
}
} $::logsize
set ::logfile test.db-journal/log.0000000001
# Check that the first log is 10K after setting
# logs to 10K
do_test logsize-2.0 {
execsql {
PRAGMA page_size=1024;
PRAGMA journal_size_limit=10240;
CREATE TABLE test(a varchar[100], b varchar[100], c varchar[100]);
}
# Find the first log file
set ::logfile [lindex [glob test.db-journal/log.*] 0]
expr [file size $::logfile]/1024
} [expr 10240/1024]
# Check that the ninth log is the default after changing logs
# to the default
do_test logsize-2.1 {
set counter 1
while { [file exists $::logfile] == 1 } {
set counter [expr $counter + 1]
set ::logfile test.db-journal/log.000000000$counter
}
set counter [expr $counter + 1]
set ::logfile test.db-journal/log.000000000$counter
execsql {
PRAGMA journal_size_limit=-1;
}
while { [file exists $::logfile] == 0 } {
execsql {
CREATE TABLE test2(int);
DROP TABLE test2;
}
}
expr [file size $::logfile]/1024
} [expr $::logsize/1024]
# Test that the first log file has been removed
do_test logsize-2.2 {
file exists test.db-journal/log.0000000001
} {0}
finish_test