CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
rowallock.test68 linesDownload Raw Back to test
1 2# 2015-05-283#4# The author disclaims copyright to this source code.  In place of5# a legal notice, here is a blessing:6#7#    May you do good and not evil.8#    May you find forgiveness for yourself and forgive others.9#    May you share freely, never taking more than you give.10#11#***********************************************************************12# This file implements regression tests for SQLite library.  The13# focus of this file is testing locks on read-only WAL-mode databases.14 15set testdir [file dirname $argv0]16source $testdir/tester.tcl17source $testdir/lock_common.tcl18set testprefix rowallock19 20set mmap_res 100000021ifcapable !mmap {22  set mmap_res 023}24 25do_multiclient_test tn {26  code2 { db2 close }27  code3 { db3 close }28  29  do_execsql_test 1.$tn.1 {30    PRAGMA page_size = 4096;31    CREATE TABLE t1(a, b);32    CREATE TABLE t2(a, b);33    INSERT INTO t1 VALUES(1, 2), (3, 4);34    PRAGMA journal_mode = wal;35  } {wal}36 37  code1 { 38    db close 39    sqlite3 db test.db -readonly 140  }41 42  do_execsql_test 1.$tn.2 {43    PRAGMA mmap_size = 1000000;44  } $mmap_res45  do_execsql_test 1.$tn.2.1 {46    SELECT * FROM t1;47  } {1 2 3 4}48 49  do_catchsql_test 1.$tn.3 {50    INSERT INTO t1 VALUES(5, 6);51  } {1 {attempt to write a readonly database}}52 53  do_test 1.$tn.4 {54    code2 { sqlite3 db2 test.db }55    sql2 { INSERT INTO t1 VALUES(5, 6); }56    code2 { db2 close }57    file exists test.db-wal58  } {1}59 60  do_test 1.$tn.5 {61    sql1 { SELECT * FROM t2 }62    code1 { db close }63    file exists test.db-wal64  } {1}65}66 67finish_test68