]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the "PRAGMA data_version" command for checking to see if a database has
authordrh <drh@noemail.net>
Sat, 20 Dec 2014 14:50:28 +0000 (14:50 +0000)
committerdrh <drh@noemail.net>
Sat, 20 Dec 2014 14:50:28 +0000 (14:50 +0000)
been modified.

FossilOrigin-Name: de50f25ce3226fa4929b8236c72c88b739859d5f

1  2 
manifest
manifest.uuid
test/pragma3.test

diff --cc manifest
index 940c1319705535ca519219acfaf5d91c55e79def,affc6751c43f1948ca656cad95c827fe4377e043..b4b2c48ca5cf6d318ddc2e10844ce6a0e494837d
+++ b/manifest
@@@ -1,5 -1,5 +1,5 @@@
- C Simplify\sthe\simplementation\sof\sthe\s"header-value"\spragmas\s(schema_version,\nuser_version,\sfreelist_count,\sand\sapplication_id)\sby\smaking\sthem\smore\ntable-driven.
- D 2014-12-19T18:49:55.326
 -C Update\sthe\sPRAGMA\sdata_version\scommand\sso\sthat\sit\sreponse\sto\schanges\smade\nby\sa\sshared-cache\sdatabase\sconnection,\sand\salso\sto\schanges\smade\sby\sthe\ssame\ndatabase\sconnection.\s\sAdd\stest\scases\sto\sverify\sthe\snew\sbehavior.
 -D 2014-12-20T14:34:02.508
++C Add\sthe\s"PRAGMA\sdata_version"\scommand\sfor\schecking\sto\ssee\sif\sa\sdatabase\shas\nbeen\smodified.
++D 2014-12-20T14:50:28.363
  F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
  F Makefile.in 6c4f961fa91d0b4fa121946a19f9e5eac2f2f809
  F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@@ -785,6 -785,7 +785,7 @@@ F test/percentile.test b98fc868d71eb561
  F test/permutations.test 4e12d43f4639ea8a0e366d9c64e0009afe2eb544
  F test/pragma.test aa16dedfe01c02c8895169012f7dfde9c163f0d5
  F test/pragma2.test aea7b3d82c76034a2df2b38a13745172ddc0bc13
 -F test/pragma3.test af097524ab7fdac11d3a37a5bab4f947f2d5d16c
++F test/pragma3.test 1935dfdd0082250df4cf4caed52bdfef527c34ff
  F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552
  F test/printf2.test b4acd4bf8734243257f01ddefa17c4fb090acc8a
  F test/progress.test a282973d1d17f08071bc58a77d6b80f2a81c354d
@@@ -1233,7 -1234,7 +1234,8 @@@ F tool/vdbe_profile.tcl 67746953071a9f8
  F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
  F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
  F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
- P 8c5dd6cc259e0cdaaddaa52ccfa96fee6b166906
- R 8ba8633e296b4b7fe64ae8b30f249024
 -P c5fb7d6a106d46f10e71abe3a6d4243b21ed02a5
 -R 4d00079d15bfd5a1a2ef4485d7808f56
++P da27a09d1d991583b59997f6cc67efa28ffd9d6a 44ee538374940c50198949f2cbb9213ba2375b6a
++R 6a9e76520ab206bdf596f781a2c88e65
++T +closed 44ee538374940c50198949f2cbb9213ba2375b6a
  U drh
- Z d788c0d876adfa7410350841952e3917
 -Z 7090cd431f3e847d9d9c987c1e3b054c
++Z 9a9f87b94c56980445c2924a0392e880
diff --cc manifest.uuid
index e0e3164dcaeadc9851732ad03c4d6450b896fe57,5bbac1f6ef804e9ac1645df6fc62826c8b1d423b..59533b96a3f5e1afc1c2fc2475e05013cddd6814
@@@ -1,1 -1,1 +1,1 @@@
- da27a09d1d991583b59997f6cc67efa28ffd9d6a
 -44ee538374940c50198949f2cbb9213ba2375b6a
++de50f25ce3226fa4929b8236c72c88b739859d5f
index 0000000000000000000000000000000000000000,a070c9b42cdada7879b46026460111cbd17d9d71..5918d0f0ed19fdc52bb9ce6426f899f103b93271
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,158 +1,188 @@@
+ # 2014-12-19
+ #
+ # 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.
+ #
+ #***********************************************************************
+ # This file implements regression tests for SQLite library.
+ #
+ # This file implements tests for PRAGMA data_version command.
+ #
+ set testdir [file dirname $argv0]
+ source $testdir/tester.tcl
+ do_execsql_test pragma3-100 {
+   PRAGMA data_version;
+ } {1}
+ do_execsql_test pragma3-101 {
+   PRAGMA temp.data_version;
+ } {1}
+ # Writing to the pragma is a no-op 
+ do_execsql_test pragma3-102 {
+   PRAGMA main.data_version=1234;
+   PRAGMA main.data_version;
+ } {1 1}
+ # EVIDENCE-OF: R-27726-60934 The "PRAGMA data_version" command provides
+ # an indication that the database file has been modified.
+ #
+ # EVIDENCE-OF: R-30058-27547 The integer values returned by two
+ # invocations of "PRAGMA data_version" will be different if changes
+ # where committed to that database in between the two invocations.
+ #
+ # EVIDENCE-OF: R-10201-09349 The "PRAGMA data_version" command responses
+ # to changes committed by the same database connection, by database
+ # connections sharing a cache in shared cache mode, and by completely
+ # independent database connections including connections in separate
+ # threads and processes.
+ #
+ # In this test, it response to two separate changes on the same database
+ # connection.
+ #
+ do_execsql_test pragma3-110 {
+   CREATE TABLE t1(a);
+   INSERT INTO t1 VALUES(100),(200),(300);
+   SELECT * FROM t1;
+   PRAGMA data_version;
+ } {100 200 300 3}
+ sqlite3 db2 test.db
+ do_test pragma3-120 {
+   db2 eval {
+     SELECT * FROM t1;
+     PRAGMA data_version;
+   }
+ } {100 200 300 1}
+ do_execsql_test pragma3-130 {
+   INSERT INTO t1 VALUES(400),(500);
+   SELECT * FROM t1;
+   PRAGMA data_version;
+ } {100 200 300 400 500 4}
+ # EVIDENCE-OF: R-10201-09349 The "PRAGMA data_version" command responses
+ # to changes committed by the same database connection, by database
+ # connections sharing a cache in shared cache mode, and by completely
+ # independent database connections including connections in separate
+ # threads and processes.
+ #
+ # In these test, it response to changes in a different database connection
+ # part of the same process.
+ #
+ do_test pragma3-140 {
+   db2 eval {
+     SELECT * FROM t1;
+     PRAGMA data_version;
+     UPDATE t1 SET a=a+1;
+     SELECT * FROM t1;
+     PRAGMA data_version;
+   }
+ } {100 200 300 400 500 2 101 201 301 401 501 3}
+ do_execsql_test pragma3-150 {
+   SELECT * FROM t1;
+   PRAGMA data_version;
+ } {101 201 301 401 501 5}
+ # EVIDENCE-OF: R-10201-09349 The "PRAGMA data_version" command responses
+ # to changes committed by the same database connection, by database
+ # connections sharing a cache in shared cache mode, and by completely
+ # independent database connections including connections in separate
+ # threads and processes.
+ #
+ # This test verifies behavior when a separate process changes the database
+ # file.
+ #
+ do_test pragma3-200 {
+   set fd [open pragma3.txt wb]
+   puts $fd {
+      sqlite3 db test.db;
+      db eval {DELETE FROM t1 WHERE a>300};
+      db close;
+      exit;
+   }
+   close $fd
+   exec [info nameofexec] pragma3.txt
+   forcedelete pragma3.txt
+   db eval {
+     PRAGMA data_version;
+     SELECT * FROM t1;
+   }
+ } {6 101 201}
+ db2 close
+ db close
+ # EVIDENCE-OF: R-10201-09349 The "PRAGMA data_version" command responses
+ # to changes committed by the same database connection, by database
+ # connections sharing a cache in shared cache mode, and by completely
+ # independent database connections including connections in separate
+ # threads and processes.
+ #
+ # The next series of tests verifies the behavior for shared-cache
+ # database connections.
+ #
+ ifcapable shared_cache {
+   set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
+   sqlite3 db test.db
+   sqlite3 db2 test.db
+   do_test pragma3-300 {
+     db eval {
+       PRAGMA data_version;
+       CREATE TABLE t3(a,b,c);
+       PRAGMA data_version;
+     }
+   } {1 2}
+   do_test pragma3-310 {
+     db2 eval {
+       PRAGMA data_version;
+       INSERT INTO t3(a,b,c) VALUES('abc','def','ghi');
+       SELECT * FROM t3;
+       PRAGMA data_version;
+     }
+   } {2 abc def ghi 3}
+   do_test pragma3-320 {
+     db eval {
+       PRAGMA data_version;
+       SELECT * FROM t3;
+     }
+   } {3 abc def ghi}
+   db2 close
++  db close
+   sqlite3_enable_shared_cache $::enable_shared_cache
+ }
++# Make sure this also works in WAL mode
++#
++ifcapable wal {
++  sqlite3 db test.db
++  db eval {PRAGMA journal_mode=WAL}
++  sqlite3 db2 test.db
++  do_test pragma3-400 {
++    db eval {
++      PRAGMA data_version;
++      PRAGMA journal_mode;
++      SELECT * FROM t1;
++    }
++  } {3 wal 101 201}
++  do_test pragma3-410 {
++    db2 eval {
++      PRAGMA data_version;
++      PRAGMA journal_mode;
++      SELECT * FROM t1;
++    }
++  } {2 wal 101 201}
++  do_test pragma3-420 {
++    db eval {UPDATE t1 SET a=111*(a/100); PRAGMA data_version; SELECT * FROM t1}
++  } {4 111 222}
++  do_test pragma3-430 {
++    db2 eval {PRAGMA data_version; SELECT * FROM t1;}
++  } {3 111 222}
++  db2 close
++}
++
+ finish_test