Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Increase pager.c coverage a bit. Fix an assert failure that can occur following a "PRAGMA omit_readlock" command on a read-only database. (CVS 6152) |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
0f3f9011fa143f7b63c9bf79d3e41132 |
User & Date: | danielk1977 2009-01-09 17:11:05 |
Context
2009-01-09
| ||
21:41 | Coverage improvements in pragma.c. Change the __DARWIN__ macro to __APPLE__, which is available by default on Leopard. (CVS 6153) check-in: 64c56226 user: drh tags: trunk | |
17:11 | Increase pager.c coverage a bit. Fix an assert failure that can occur following a "PRAGMA omit_readlock" command on a read-only database. (CVS 6152) check-in: 0f3f9011 user: danielk1977 tags: trunk | |
14:29 | Fix two problems in test instrumentation that show up on some fulltests. (CVS 6151) check-in: c9179617 user: drh tags: trunk | |
Changes
Changes to src/pager.c.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 .... 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 .... 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 |
** The pager is used to access a database disk file. It implements ** atomic commit and rollback through the use of a journal file that ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** ** @(#) $Id: pager.c,v 1.543 2009/01/08 18:04:14 danielk1977 Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" /* ** Macros for troubleshooting. Normally turned off */ ................................................................................ assert( sqlite3PcacheRefCount(pPager->pPCache)==0 ); if( !pPager->noReadlock ){ rc = pager_wait_on_lock(pPager, SHARED_LOCK); if( rc!=SQLITE_OK ){ assert( pPager->state==PAGER_UNLOCK ); return pager_error(pPager, rc); } assert( pPager->state>=SHARED_LOCK ); } /* If a journal file exists, and there is no RESERVED lock on the ** database file, then it either needs to be played back or deleted. */ if( !isErrorReset ){ rc = hasHotJournal(pPager, &isHotJournal); if( rc!=SQLITE_OK ){ ................................................................................ memset(dbFileVers, 0, sizeof(dbFileVers)); } if( memcmp(pPager->dbFileVers, dbFileVers, sizeof(dbFileVers))!=0 ){ pager_reset(pPager); } } assert( pPager->exclusiveMode || pPager->state<=PAGER_SHARED ); if( pPager->state==PAGER_UNLOCK ){ pPager->state = PAGER_SHARED; } } failed: if( rc!=SQLITE_OK ){ /* pager_unlock() is a no-op for exclusive mode and in-memory databases. */ pager_unlock(pPager); } |
| | > > | < < < |
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 .... 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 .... 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 |
** The pager is used to access a database disk file. It implements ** atomic commit and rollback through the use of a journal file that ** is separate from the database file. The pager also implements file ** locking to prevent two processes from writing the same database ** file simultaneously, or one process from reading the database while ** another is writing. ** ** @(#) $Id: pager.c,v 1.544 2009/01/09 17:11:05 danielk1977 Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" /* ** Macros for troubleshooting. Normally turned off */ ................................................................................ assert( sqlite3PcacheRefCount(pPager->pPCache)==0 ); if( !pPager->noReadlock ){ rc = pager_wait_on_lock(pPager, SHARED_LOCK); if( rc!=SQLITE_OK ){ assert( pPager->state==PAGER_UNLOCK ); return pager_error(pPager, rc); } }else if( pPager->state==PAGER_UNLOCK ){ pPager->state = PAGER_SHARED; } assert( pPager->state>=SHARED_LOCK ); /* If a journal file exists, and there is no RESERVED lock on the ** database file, then it either needs to be played back or deleted. */ if( !isErrorReset ){ rc = hasHotJournal(pPager, &isHotJournal); if( rc!=SQLITE_OK ){ ................................................................................ memset(dbFileVers, 0, sizeof(dbFileVers)); } if( memcmp(pPager->dbFileVers, dbFileVers, sizeof(dbFileVers))!=0 ){ pager_reset(pPager); } } assert( pPager->exclusiveMode || pPager->state==PAGER_SHARED ); } failed: if( rc!=SQLITE_OK ){ /* pager_unlock() is a no-op for exclusive mode and in-memory databases. */ pager_unlock(pPager); } |
Changes to test/misc7.test.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 161 162 163 164 165 166 167 168 169 170 171 172 173 174 ... 463 464 465 466 467 468 469 470 471 472 473 474 475 |
# 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. # # $Id: misc7.test,v 1.25 2008/10/30 15:03:16 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl do_test misc7-1-misuse { c_misuse_test } {} ................................................................................ SELECT name FROM aux.sqlite_master; } } {hello} do_test misc7-7.2 { execsql { DETACH aux; } } {} # Test the UTF-16 version of the "out of memory" message (used when # malloc fails during sqlite3_open() ). # ifcapable utf16 { do_test misc7-8 { ................................................................................ # sqlite3_global_recover() is a no-op. But we might as well test it # if only to get the test coverage. # do_test misc7-20.1 { sqlite3_global_recover } {SQLITE_OK} db close file delete -force test.db finish_test |
| > > > > > > > > > > > > > > > > > > > > > > > > |
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 ... 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
# 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. # # $Id: misc7.test,v 1.26 2009/01/09 17:11:05 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl do_test misc7-1-misuse { c_misuse_test } {} ................................................................................ SELECT name FROM aux.sqlite_master; } } {hello} do_test misc7-7.2 { execsql { DETACH aux; } } {} do_test misc7-7.3 { db close sqlite3 db test.db -readonly 1 execsql { PRAGMA omit_readlock = 1; ATTACH 'test2.db' AS aux; SELECT name FROM aux.sqlite_master; SELECT name FROM aux.sqlite_master; } } {hello hello} do_test misc7-7.3 { db close sqlite3 db test.db set ::DB [sqlite3_connection_pointer db] list } {} # Test the UTF-16 version of the "out of memory" message (used when # malloc fails during sqlite3_open() ). # ifcapable utf16 { do_test misc7-8 { ................................................................................ # sqlite3_global_recover() is a no-op. But we might as well test it # if only to get the test coverage. # do_test misc7-20.1 { sqlite3_global_recover } {SQLITE_OK} # Try to open a really long file name. # do_test misc7-21.1 { set zFile [file join [pwd] "[string repeat abcde 104].db"] set rc [catch {sqlite3 db2 $zFile} msg] list $rc $msg } {1 {unable to open database file}} db close file delete -force test.db finish_test |
Changes to test/savepoint3.test.
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
71
72
73
74
75
76
77
78
79
80
|
# # 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. # #*********************************************************************** # # $Id: savepoint3.test,v 1.3 2009/01/07 08:12:16 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl source $testdir/malloc_common.tcl do_malloc_test savepoint3-1 -sqlprep { ................................................................................ COMMIT; } -cleanup { db eval { SAVEPOINT one; RELEASE one; } } finish_test |
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
..
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# # 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. # #*********************************************************************** # # $Id: savepoint3.test,v 1.4 2009/01/09 17:11:05 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl source $testdir/malloc_common.tcl do_malloc_test savepoint3-1 -sqlprep { ................................................................................ COMMIT; } -cleanup { db eval { SAVEPOINT one; RELEASE one; } } # The following test does a really big savepoint rollback. One involving # more than 4000 pages. The idea is to get a specific sqlite3BitvecSet() # operation in pagerPlaybackSavepoint() to fail. #do_malloc_test savepoint3-4 -sqlprep { # BEGIN; # CREATE TABLE t1(a, b); # CREATE INDEX i1 ON t1(a); # CREATE INDEX i2 ON t1(b); # INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500)); -- 1 # INSERT INTO t1 VALUES(randstr(500,500), randstr(500,500)); -- 2 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 4 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 8 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 16 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 32 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 64 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 128 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 256 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 512 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 1024 # INSERT INTO t1 SELECT randstr(500,500), randstr(500,500) FROM t1; -- 2048 # COMMIT; # BEGIN; # SAVEPOINT abc; # UPDATE t1 SET a = randstr(500,500); #} -sqlbody { # ROLLBACK TO abc; #} # Cause a specific malloc in savepoint rollback code to fail. # do_malloc_test savepoint3-4 -start 7 -sqlprep { PRAGMA auto_vacuum = incremental; PRAGMA cache_size = 1000; CREATE TABLE t1(a, b); CREATE TABLE t2(a, b); CREATE TABLE t3(a, b); INSERT INTO t1 VALUES(1, randstr(500,500)); INSERT INTO t1 VALUES(2, randstr(500,500)); INSERT INTO t1 VALUES(3, randstr(500,500)); DELETE FROM t1; BEGIN; INSERT INTO t1 VALUES(1, randstr(500,500)); INSERT INTO t1 VALUES(2, randstr(500,500)); INSERT INTO t1 VALUES(3, randstr(500,500)); DROP TABLE t3; -- Page 5 of the database file is now free. DROP TABLE t2; -- Page 4 of the database file is now free. SAVEPOINT abc; PRAGMA incremental_vacuum; } -sqlbody { ROLLBACK TO abc; } finish_test |