3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
12 # Test case for SQLITE_FCNTL_DATA_VERSION
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
18 # Construct a database and get its initial data version
20 do_test dataversion1-100 {
23 INSERT INTO t1(x) VALUES(99);
27 set dv1 [file_control_data_version db main]
29 # The data version does not change by ATTACH or by changes to
30 # other schemas within the same connection.
32 do_test dataversion1-101 {
34 ATTACH ':memory:' AS aux1;
35 CREATE TABLE aux1.t2(y);
36 CREATE TEMP TABLE t3(z);
38 file_control_data_version db main
41 # The data version does change when SQL modifies the table
42 do_test dataversion1-110 {
46 set dv2 [file_control_data_version db]
50 # But the data version is constant if there are changes to other
52 set dv1 [file_control_data_version db main]
53 do_test dataversion1-120 {
57 file_control_data_version db
60 # Changes to the database via another connection are not detected
61 # until there is a read transaction.
64 do_test dataversion1-130 {
69 do_test dataversion1-131 {
70 file_control_data_version db
72 do_test dataversion1-132 {
76 set dv2 [file_control_data_version db]
79 do_test dataversion1-133 {
80 db eval {SELECT * FROM t1}
81 set dv2 [file_control_data_version db]