SQLite

Check-in [c889331051]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Run trans.test and avtrans.test as part of the "wal" permutation.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | wal
Files: files | file ages | folders
SHA1: c8893310510148f7e71ede5691606b6fc1c3df4d
User & Date: dan 2010-04-27 06:49:34.000
Context
2010-04-27
14:37
Fix a problem with identifying a corrupt database in WAL mode. (check-in: c8658da446 user: dan tags: wal)
11:49
Add the xShmRelease() method to the VFS. The os_unix.c implementation of the shared memory logic is still non-functional. (check-in: ed715b47c5 user: drh tags: wal)
06:49
Run trans.test and avtrans.test as part of the "wal" permutation. (check-in: c889331051 user: dan tags: wal)
05:42
Fix a problem that occurs when one process causes the log-summary file to grow and then a second process attempts to read the database. (check-in: b51a5f8bc6 user: dan tags: wal)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/avtrans.test.
18
19
20
21
22
23
24


25
26
27
28
29
30
31
32
33
set testdir [file dirname $argv0]
source $testdir/tester.tcl


# Create several tables to work with.
#
do_test avtrans-1.0 {


  execsql {
    PRAGMA auto_vacuum=ON;
    CREATE TABLE one(a int PRIMARY KEY, b text);
    INSERT INTO one VALUES(1,'one');
    INSERT INTO one VALUES(2,'two');
    INSERT INTO one VALUES(3,'three');
    SELECT b FROM one ORDER BY a;
  }
} {one two three}







>
>
|
<







18
19
20
21
22
23
24
25
26
27

28
29
30
31
32
33
34
set testdir [file dirname $argv0]
source $testdir/tester.tcl


# Create several tables to work with.
#
do_test avtrans-1.0 {
  execsql { PRAGMA auto_vacuum=ON }
  wal_set_journal_mode
  execsql { 

    CREATE TABLE one(a int PRIMARY KEY, b text);
    INSERT INTO one VALUES(1,'one');
    INSERT INTO one VALUES(2,'two');
    INSERT INTO one VALUES(3,'three');
    SELECT b FROM one ORDER BY a;
  }
} {one two three}
44
45
46
47
48
49
50

51
52
53
54
55
56
57
  sqlite3 altdb test.db
  execsql {SELECT b FROM one ORDER BY a} altdb
} {one two three}
do_test avtrans-1.10 {
  execsql {SELECT b FROM two ORDER BY a} altdb
} {I V X}
integrity_check avtrans-1.11


# Basic transactions
#
do_test avtrans-2.1 {
  set v [catch {execsql {BEGIN}} msg]
  lappend v $msg
} {0 {}}







>







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
  sqlite3 altdb test.db
  execsql {SELECT b FROM one ORDER BY a} altdb
} {one two three}
do_test avtrans-1.10 {
  execsql {SELECT b FROM two ORDER BY a} altdb
} {I V X}
integrity_check avtrans-1.11
wal_check_journal_mode avtrans-1.12

# Basic transactions
#
do_test avtrans-2.1 {
  set v [catch {execsql {BEGIN}} msg]
  lappend v $msg
} {0 {}}
80
81
82
83
84
85
86

87
88
89
90
91
92
93
    BEGIN;
    SELECT a FROM one ORDER BY a;
    SELECT a FROM two ORDER BY a;
    END;
  }
} {1 2 3 1 5 10}
integrity_check avtrans-2.11


# Check the locking behavior
#
sqlite3_soft_heap_limit 0
do_test avtrans-3.1 {
  execsql {
    BEGIN;







>







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
    BEGIN;
    SELECT a FROM one ORDER BY a;
    SELECT a FROM two ORDER BY a;
    END;
  }
} {1 2 3 1 5 10}
integrity_check avtrans-2.11
wal_check_journal_mode avtrans-2.12

# Check the locking behavior
#
sqlite3_soft_heap_limit 0
do_test avtrans-3.1 {
  execsql {
    BEGIN;
909
910
911
912
913
914
915

916
917
918
919

920
921
        } [expr {$i%2==0}]
      } else {
        do_test avtrans-9.$i.5-$cnt {
           expr {$sqlite_fullsync_count==0}
        } {1}
      }
    }

  }
  set ::pager_old_format 0
}
integrity_check avtrans-10.1

   
finish_test







>




>


912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
        } [expr {$i%2==0}]
      } else {
        do_test avtrans-9.$i.5-$cnt {
           expr {$sqlite_fullsync_count==0}
        } {1}
      }
    }
    wal_check_journal_mode avtrans-9.$i-6.$cnt
  }
  set ::pager_old_format 0
}
integrity_check avtrans-10.1
wal_check_journal_mode avtrans-10.2
   
finish_test
Changes to test/permutations.test.
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
run_tests "wal" -description {
  Run tests with journal_mode=WAL
} -initialize {
  set ::savepoint6_iterations 100
} -shutdown {
  unset -nocomplain ::savepoint6_iterations
} -include {
  savepoint.test
  savepoint2.test
  savepoint6.test
}

# End of tests
#############################################################################

if {$::perm::testmode eq "targets"} { puts "" ; exit }








|
|
<







759
760
761
762
763
764
765
766
767

768
769
770
771
772
773
774
run_tests "wal" -description {
  Run tests with journal_mode=WAL
} -initialize {
  set ::savepoint6_iterations 100
} -shutdown {
  unset -nocomplain ::savepoint6_iterations
} -include {
  savepoint.test     savepoint2.test     savepoint6.test
  trans.test         avtrans.test

}

# End of tests
#############################################################################

if {$::perm::testmode eq "targets"} { puts "" ; exit }

Changes to test/trans.test.
15
16
17
18
19
20
21

22
23
24
25
26
27
28


set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Create several tables to work with.
#

do_test trans-1.0 {
  execsql {
    CREATE TABLE one(a int PRIMARY KEY, b text);
    INSERT INTO one VALUES(1,'one');
    INSERT INTO one VALUES(2,'two');
    INSERT INTO one VALUES(3,'three');
    SELECT b FROM one ORDER BY a;







>







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29


set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Create several tables to work with.
#
wal_set_journal_mode
do_test trans-1.0 {
  execsql {
    CREATE TABLE one(a int PRIMARY KEY, b text);
    INSERT INTO one VALUES(1,'one');
    INSERT INTO one VALUES(2,'two');
    INSERT INTO one VALUES(3,'three');
    SELECT b FROM one ORDER BY a;
42
43
44
45
46
47
48

49
50
51
52
53
54
55
  sqlite3 altdb test.db
  execsql {SELECT b FROM one ORDER BY a} altdb
} {one two three}
do_test trans-1.10 {
  execsql {SELECT b FROM two ORDER BY a} altdb
} {I V X}
integrity_check trans-1.11


# Basic transactions
#
do_test trans-2.1 {
  set v [catch {execsql {BEGIN}} msg]
  lappend v $msg
} {0 {}}







>







43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  sqlite3 altdb test.db
  execsql {SELECT b FROM one ORDER BY a} altdb
} {one two three}
do_test trans-1.10 {
  execsql {SELECT b FROM two ORDER BY a} altdb
} {I V X}
integrity_check trans-1.11
wal_check_journal_mode trans-1.12

# Basic transactions
#
do_test trans-2.1 {
  set v [catch {execsql {BEGIN}} msg]
  lappend v $msg
} {0 {}}
78
79
80
81
82
83
84

85
86
87
88
89
90
91
    BEGIN;
    SELECT a FROM one ORDER BY a;
    SELECT a FROM two ORDER BY a;
    END;
  }
} {1 2 3 1 5 10}
integrity_check trans-2.11


# Check the locking behavior
#
do_test trans-3.1 {
  execsql {
    BEGIN;
    UPDATE one SET a = 0 WHERE 0;







>







80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
    BEGIN;
    SELECT a FROM one ORDER BY a;
    SELECT a FROM two ORDER BY a;
    END;
  }
} {1 2 3 1 5 10}
integrity_check trans-2.11
wal_check_journal_mode trans-2.12

# Check the locking behavior
#
do_test trans-3.1 {
  execsql {
    BEGIN;
    UPDATE one SET a = 0 WHERE 0;
158
159
160
161
162
163
164

165
166
167
168
169
170
171
do_test trans-3.14 {
  set v [catch {execsql {
    SELECT a FROM one ORDER BY a;
  } db} msg]
  lappend v $msg
} {0 {1 2 3 4}}
integrity_check trans-3.15


do_test trans-4.1 {
  set v [catch {execsql {
    COMMIT;
  } db} msg]
  lappend v $msg
} {1 {cannot commit - no transaction is active}}







>







161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
do_test trans-3.14 {
  set v [catch {execsql {
    SELECT a FROM one ORDER BY a;
  } db} msg]
  lappend v $msg
} {0 {1 2 3 4}}
integrity_check trans-3.15
wal_check_journal_mode trans-3.16

do_test trans-4.1 {
  set v [catch {execsql {
    COMMIT;
  } db} msg]
  lappend v $msg
} {1 {cannot commit - no transaction is active}}
224
225
226
227
228
229
230


231
232
233
234
235
236
237
do_test trans-4.11 {
  set v [catch {execsql {
    SELECT a FROM one ORDER BY a;
  } altdb} msg]
  lappend v $msg
} {0 {1 2 3 4}}
integrity_check trans-4.12


do_test trans-4.98 {
  altdb close
  execsql {
    DROP TABLE one;
    DROP TABLE two;
  }
} {}







>
>







228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
do_test trans-4.11 {
  set v [catch {execsql {
    SELECT a FROM one ORDER BY a;
  } altdb} msg]
  lappend v $msg
} {0 {1 2 3 4}}
integrity_check trans-4.12
wal_check_journal_mode trans-4.13
wal_check_journal_mode trans-4.14 altdb
do_test trans-4.98 {
  altdb close
  execsql {
    DROP TABLE one;
    DROP TABLE two;
  }
} {}
771
772
773
774
775
776
777

778
779
780
781
782
783
784
    }
  } $checksum
}
do_test trans-7.14 {
  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
} $checksum2
integrity_check trans-7.15


# Arrange for another process to begin modifying the database but abort
# and die in the middle of the modification.  Then have this process read
# the database.  This process should detect the journal file and roll it
# back.  Verify that this happens correctly.
#
set fd [open test.tcl w]







>







777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
    }
  } $checksum
}
do_test trans-7.14 {
  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
} $checksum2
integrity_check trans-7.15
wal_check_journal_mode trans-7.16

# Arrange for another process to begin modifying the database but abort
# and die in the middle of the modification.  Then have this process read
# the database.  This process should detect the journal file and roll it
# back.  Verify that this happens correctly.
#
set fd [open test.tcl w]
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
  catch {exec [info nameofexec] test.tcl}
  execsql {SELECT md5sum(x,y,z) FROM t2}
} $checksum
do_test trans-8.5 {
  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
} $checksum2
integrity_check trans-8.6


# In the following sequence of tests, compute the MD5 sum of the content
# of a table, make lots of modifications to that table, then do a rollback.
# Verify that after the rollback, the MD5 checksum is unchanged.
#
do_test trans-9.1 {
  execsql {







|







827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
  catch {exec [info nameofexec] test.tcl}
  execsql {SELECT md5sum(x,y,z) FROM t2}
} $checksum
do_test trans-8.5 {
  execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
} $checksum2
integrity_check trans-8.6
wal_check_journal_mode trans-8.7

# In the following sequence of tests, compute the MD5 sum of the content
# of a table, make lots of modifications to that table, then do a rollback.
# Verify that after the rollback, the MD5 checksum is unchanged.
#
do_test trans-9.1 {
  execsql {
850
851
852
853
854
855
856

857
858
859
860
861
862
863
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    COMMIT;
    SELECT count(*) FROM t3;
  }
} {1024}


# The following procedure computes a "signature" for table "t3".  If
# T3 changes in any way, the signature should change.  
#
# This is used to test ROLLBACK.  We gather a signature for t3, then
# make lots of changes to t3, then rollback and take another signature.
# The two signatures should be the same.







>







857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    INSERT INTO t3 SELECT randstr(10,400) FROM t3;
    COMMIT;
    SELECT count(*) FROM t3;
  }
} {1024}
wal_check_journal_mode trans-9.1.1

# The following procedure computes a "signature" for table "t3".  If
# T3 changes in any way, the signature should change.  
#
# This is used to test ROLLBACK.  We gather a signature for t3, then
# make lots of changes to t3, then rollback and take another signature.
# The two signatures should be the same.
936
937
938
939
940
941
942


943
944
945
946
      } else {
        do_test trans-9.$i.5-$cnt {
          expr {$sqlite_fullsync_count==0}
        } {1}
      }
    }
  }


  set ::pager_old_format 0
}
   
finish_test







>
>




944
945
946
947
948
949
950
951
952
953
954
955
956
      } else {
        do_test trans-9.$i.5-$cnt {
          expr {$sqlite_fullsync_count==0}
        } {1}
      }
    }
  }

  wal_check_journal_mode trans-9.$i.6-$cnt
  set ::pager_old_format 0
}
   
finish_test