Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: third_party/sqlite/src/test/rdonly.test

Issue 6990047: Import SQLite 3.7.6.3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/sqlite/src/test/quota.test ('k') | third_party/sqlite/src/test/releasetest.tcl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2007 April 24 1 # 2007 April 24
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # This file implements regression tests for SQLite library. 11 # This file implements regression tests for SQLite library.
12 # 12 #
13 # This file implements tests to make sure SQLite treats a database 13 # This file implements tests to make sure SQLite treats a database
14 # as readonly if its write version is set to high. 14 # as readonly if its write version is set to high.
15 # 15 #
16 # $Id: rdonly.test,v 1.2 2008/07/08 10:19:58 danielk1977 Exp $ 16 # $Id: rdonly.test,v 1.2 2008/07/08 10:19:58 danielk1977 Exp $
17 17
18 set testdir [file dirname $argv0] 18 set testdir [file dirname $argv0]
19 source $testdir/tester.tcl 19 source $testdir/tester.tcl
20 20
21 # Do not use a codec for tests in this file, as the database file is
22 # manipulated directly using tcl scripts (using the [hexio_write] command).
23 #
24 do_not_use_codec
21 25
22 # Create a database. 26 # Create a database.
23 # 27 #
24 do_test rdonly-1.1 { 28 do_test rdonly-1.1 {
25 execsql { 29 execsql {
26 CREATE TABLE t1(x); 30 CREATE TABLE t1(x);
27 INSERT INTO t1 VALUES(1); 31 INSERT INTO t1 VALUES(1);
28 SELECT * FROM t1; 32 SELECT * FROM t1;
29 } 33 }
30 } {1} 34 } {1}
31 35
32 # Changes the write version from 1 to 2. Verify that the database 36 # Changes the write version from 1 to 3. Verify that the database
33 # can be read but not written. 37 # can be read but not written.
34 # 38 #
35 do_test rdonly-1.2 { 39 do_test rdonly-1.2 {
36 db close 40 db close
37 hexio_get_int [hexio_read test.db 18 1] 41 hexio_get_int [hexio_read test.db 18 1]
38 } 1 42 } 1
39 do_test rdonly-1.3 { 43 do_test rdonly-1.3 {
40 hexio_write test.db 18 02 44 hexio_write test.db 18 03
41 sqlite3 db test.db 45 sqlite3 db test.db
42 execsql { 46 execsql {
43 SELECT * FROM t1; 47 SELECT * FROM t1;
44 } 48 }
45 } {1} 49 } {1}
46 do_test rdonly-1.4 { 50 do_test rdonly-1.4 {
47 catchsql { 51 catchsql {
48 INSERT INTO t1 VALUES(2) 52 INSERT INTO t1 VALUES(2)
49 } 53 }
50 } {1 {attempt to write a readonly database}} 54 } {1 {attempt to write a readonly database}}
51 55
52 # Change the write version back to 1. Verify that the database 56 # Change the write version back to 1. Verify that the database
53 # is read-write again. 57 # is read-write again.
54 # 58 #
55 do_test rdonly-1.5 { 59 do_test rdonly-1.5 {
56 db close 60 db close
57 hexio_write test.db 18 01 61 hexio_write test.db 18 01
58 sqlite3 db test.db 62 sqlite3 db test.db
59 catchsql { 63 catchsql {
60 INSERT INTO t1 VALUES(2); 64 INSERT INTO t1 VALUES(2);
61 SELECT * FROM t1; 65 SELECT * FROM t1;
62 } 66 }
63 } {0 {1 2}} 67 } {0 {1 2}}
64 68
65 # Now, after connection [db] has loaded the database schema, modify the 69 # Now, after connection [db] has loaded the database schema, modify the
66 # write-version of the file (and the change-counter, so that the 70 # write-version of the file (and the change-counter, so that the
67 # write-version is reloaded). This way, SQLite does not discover that 71 # write-version is reloaded). This way, SQLite does not discover that
68 # the database is read-only until after it is locked. 72 # the database is read-only until after it is locked.
69 # 73 #
74 set ro_version 02
75 ifcapable wal { set ro_version 03 }
70 do_test rdonly-1.6 { 76 do_test rdonly-1.6 {
71 hexio_write test.db 18 02 ; # write-version 77 hexio_write test.db 18 $ro_version ; # write-version
72 hexio_write test.db 24 11223344 ; # change-counter 78 hexio_write test.db 24 11223344 ; # change-counter
73 catchsql { 79 catchsql {
74 INSERT INTO t1 VALUES(2); 80 INSERT INTO t1 VALUES(2);
75 } 81 }
76 } {1 {attempt to write a readonly database}} 82 } {1 {attempt to write a readonly database}}
77 83
78 finish_test 84 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/quota.test ('k') | third_party/sqlite/src/test/releasetest.tcl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698