Update contrib.
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 # $Id: shared2.test,v 1.5 2007/08/23 02:47:54 drh Exp $
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
18 ifcapable !shared_cache {
22 set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
24 # Test that if we delete all rows from a table any read-uncommitted
25 # cursors are correctly invalidated. Test on both table and index btrees.
30 # Set up some data. Table "numbers" has 64 rows after this block
34 CREATE TABLE numbers(a PRIMARY KEY, b);
35 INSERT INTO numbers(oid) VALUES(NULL);
36 INSERT INTO numbers(oid) SELECT NULL FROM numbers;
37 INSERT INTO numbers(oid) SELECT NULL FROM numbers;
38 INSERT INTO numbers(oid) SELECT NULL FROM numbers;
39 INSERT INTO numbers(oid) SELECT NULL FROM numbers;
40 INSERT INTO numbers(oid) SELECT NULL FROM numbers;
41 INSERT INTO numbers(oid) SELECT NULL FROM numbers;
42 UPDATE numbers set a = oid, b = 'abcdefghijklmnopqrstuvwxyz0123456789';
47 # Put connection 2 in read-uncommitted mode and start a SELECT on table
48 # 'numbers'. Half way through the SELECT, use connection 1 to delete the
49 # contents of this table.
51 pragma read_uncommitted = 1;
53 set count [execsql {SELECT count(*) FROM numbers} db2]
54 db2 eval {SELECT a FROM numbers ORDER BY oid} {
65 # Same test as 1.2, except scan using the index this time.
69 set count [execsql {SELECT count(*) FROM numbers} db2]
70 db2 eval {SELECT a, b FROM numbers ORDER BY a} {
80 #---------------------------------------------------------------------------
81 # These tests, shared2.2.*, test the outcome when data is added to or
82 # removed from a table due to a rollback while a read-uncommitted
83 # cursor is scanning it.
87 INSERT INTO numbers VALUES(1, 'Medium length text field');
88 INSERT INTO numbers VALUES(2, 'Medium length text field');
89 INSERT INTO numbers VALUES(3, 'Medium length text field');
90 INSERT INTO numbers VALUES(4, 'Medium length text field');
92 DELETE FROM numbers WHERE (a%2)=0;
96 SELECT a FROM numbers ORDER BY a;
100 execsql {ROLLBACK} db1
105 do_test shared2-2.2 {
108 INSERT INTO numbers VALUES(5, 'Medium length text field');
109 INSERT INTO numbers VALUES(6, 'Medium length text field');
113 SELECT a FROM numbers ORDER BY a;
117 execsql {ROLLBACK} db1
126 do_test shared2-3.2 {
127 sqlite3_enable_shared_cache 1
130 sqlite3_enable_shared_cache $::enable_shared_cache