sqlite/ext/ota/ota4.test
dan 75fda9b395 Remove "PRAGMA ota_mode".
FossilOrigin-Name: 1c111447a07687c30ed4ad5a6c27a169c85b7ea6
2015-02-03 15:56:08 +00:00

129 lines
2.9 KiB
Plaintext

# 2014 August 30
#
# 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.
#
#***********************************************************************
#
# Test some properties of the pager_ota_mode and ota_mode pragmas.
#
if {![info exists testdir]} {
set testdir [file join [file dirname [info script]] .. .. test]
}
source $testdir/tester.tcl
set ::testprefix ota4
#-------------------------------------------------------------------------
# The following tests aim to verify some properties of the pager_ota_mode
# pragma:
#
# 1. Cannot set the pager_ota_mode flag on a WAL mode database.
#
# 2. Or if there is an open read transaction.
#
# 3. Cannot start a transaction with pager_ota_mode set if there
# is a WAL file in the file-system.
#
# 4. Or if the wal-mode flag is set in the database file header.
#
# 5. Cannot open a transaction with pager_ota_mode set if the database
# file has been modified by a rollback mode client since the *-oal
# file was started.
#
do_execsql_test 1.1.1 {
PRAGMA journal_mode = wal;
SELECT * FROM sqlite_master;
} {wal}
do_catchsql_test 1.1.2 {
PRAGMA pager_ota_mode = 1
} {1 {cannot set pager_ota_mode in wal mode}}
do_execsql_test 1.2.1 {
PRAGMA journal_mode = delete;
BEGIN;
SELECT * FROM sqlite_master;
} {delete}
do_catchsql_test 1.2.2 {
PRAGMA pager_ota_mode = 1
} {1 {cannot set pager_ota_mode with open transaction}}
do_execsql_test 1.2.3 {
COMMIT;
} {}
do_execsql_test 1.3.1 {
PRAGMA journal_mode = wal;
CREATE TABLE t1(a, b);
INSERT INTO t1 VALUES(1, 2);
} {wal}
do_test 1.3.2 {
forcecopy test.db-wal test.db-bak
execsql {
PRAGMA journal_mode = delete;
PRAGMA pager_ota_mode = 1;
}
forcecopy test.db-bak test.db-wal
catchsql {
SELECT * FROM sqlite_master
}
} {1 {unable to open database file}}
do_test 1.4.1 {
db close
forcedelete test.db-wal test.db-oal
sqlite3 db test.db
execsql {
PRAGMA journal_mode = wal;
PRAGMA pager_ota_mode = 1;
}
catchsql {
SELECT * FROM sqlite_master;
}
} {1 {unable to open database file}}
do_test 1.5.1 {
forcedelete test.db-oal
reset_db
execsql {
PRAGMA journal_mode = delete;
CREATE TABLE t1(a, b);
INSERT INTO t1 VALUES(1, 2);
}
execsql {
PRAGMA pager_ota_mode = 1;
INSERT INTO t1 VALUES(3, 4);
}
db close
sqlite3 db test.db
execsql {
SELECT * FROM t1;
}
} {1 2}
do_execsql_test 1.5.2 {
PRAGMA pager_ota_mode = 1;
SELECT * FROM t1;
INSERT INTO t1 VALUES(5, 6);
} {1 2 3 4}
do_test 5.3 {
db close
sqlite3 db test.db
execsql {
INSERT INTO t1 VALUES(7, 8);
SELECT * FROM t1;
}
} {1 2 7 8}
do_catchsql_test 1.5.4 {
PRAGMA pager_ota_mode = 1;
SELECT * FROM t1;
} {1 {database is locked}}
finish_test