mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
More coverage for pager.c. (CVS 3778)
FossilOrigin-Name: 665b119a241a5a95f236b3ace1b25fc18ae6f0a3
This commit is contained in:
20
manifest
20
manifest
@@ -1,5 +1,5 @@
|
||||
C Fix\sa\slong-standing\smemory\sleak\sin\sthe\shash\stable.\s\sThe\sleak\sonly\sappears\nfollowing\sa\smalloc\sfailure\sof\sa\shash\sthat\scopies\sits\skeys,\swhich\srarely\nhappens\sand\sso\swe\shave\snot\spreviously\snoticed\sit.\s(CVS\s3777)
|
||||
D 2007-03-31T03:59:24
|
||||
C More\scoverage\sfor\spager.c.\s(CVS\s3778)
|
||||
D 2007-03-31T10:00:48
|
||||
F Makefile.in 2f2c3bf69faf0ae7b8e8af4f94f1986849034530
|
||||
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
|
||||
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
|
||||
@@ -86,7 +86,7 @@ F src/os_unix.c 4291be23eec73d1ec04010ae702364b781b5f773
|
||||
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
|
||||
F src/os_win.c c3a8403ea28bbb89d6507fa984c5919bd3fe7539
|
||||
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
||||
F src/pager.c 70de94d2681ea8f677fead0e21fcc39efb6bebb5
|
||||
F src/pager.c 5d07eba846ef4f2067e6640d3f941dbf7668b8f6
|
||||
F src/pager.h e79a24cf200b8771366217f5bca414f5b7823f42
|
||||
F src/parse.y 207ab04273ae13aa4a729b96008d294d5f334ab3
|
||||
F src/pragma.c 3b992b5b2640d6ae25cef05aa6a42cd1d6c43234
|
||||
@@ -195,7 +195,7 @@ F test/delete3.test 555e84a00a99230b7d049d477a324a631126a6ab
|
||||
F test/descidx1.test 2177c4ad55edcf56ad5f4c6490f307d7774e8a10
|
||||
F test/descidx2.test eb3a2882ec58aa6e1e8131d9bb54436e5b4a3ce2
|
||||
F test/descidx3.test 3a55b8d73bc3e9ad084e0da7fec781cf0d2a0356
|
||||
F test/diskfull.test 2321eae64325102e1c5fb2f92a99c5c1f94bb95a
|
||||
F test/diskfull.test f592f37d9ee9d32155e0d30e4e35ec4a28c9ee93
|
||||
F test/distinctagg.test 2b89d1c5220d966a30ba4b40430338669301188b
|
||||
F test/enc.test 7a03417a1051fe8bc6c7641cf4c8c3f7e0066d52
|
||||
F test/enc2.test 45710bacfa9df29720bc84c067dfdf8c8ddfb797
|
||||
@@ -274,7 +274,7 @@ F test/misc3.test 7bd937e2c62bcc6be71939faf068d506467b1e03
|
||||
F test/misc4.test b043a05dea037cca5989f3ae09552fa16119bc80
|
||||
F test/misc5.test c7d2d2a5a20dc37d3605a8067f0df5af2240122e
|
||||
F test/misc6.test 3de55ec5cadf466ada587173faa5d6a4790a8bb7
|
||||
F test/misc7.test 6f59801b47e042e353a71d282f697782baac2f9d
|
||||
F test/misc7.test 8663e29f1a57c55321d4e6a8b2b9203d33254c69
|
||||
F test/misuse.test 30b3a458e5a70c31e74c291937b6c82204c59f33
|
||||
F test/notnull.test 44d600f916b770def8b095a9962dbe3be5a70d82
|
||||
F test/null.test 9503e1f63e959544c006d9f01709c5b5eab67d54
|
||||
@@ -285,7 +285,7 @@ F test/pagesize.test 05c74ea49f790734ec1e9ab765d9bf1cce79b8f2
|
||||
F test/pragma.test 4d2696d0c5bfc4ef28324684c2f9162243800496
|
||||
F test/printf.test cdd8e20dd901382a385afcbaa777b9377815c2ad
|
||||
F test/progress.test 8b22b4974b0a95272566385f8cb8c341c7130df8 x
|
||||
F test/quick.test c3eb0c3e37f165eed629cf806f43b4e4e1a3213e
|
||||
F test/quick.test c81ee93163f550e7ab420c7881d0dd415bad46f4
|
||||
F test/quote.test 5891f2338980916cf7415484b4ce785294044adb
|
||||
F test/reindex.test 38b138abe36bf9a08c791ed44d9f76cd6b97b78b
|
||||
F test/rollback.test 673cd8c44c685ad54987fe7f0eeba84efa09685d
|
||||
@@ -447,7 +447,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
|
||||
P dce4cb84930116db99275f77141fd933bc84288e
|
||||
R 77a1b633072f6a8b2b599f4a3d3304a7
|
||||
U drh
|
||||
Z cf5aee56787fd88ebb5c4a271134a18c
|
||||
P 2aae1964572f4d4d1eae090a997e0bd9a82a69b2
|
||||
R b247f1fbf3d4ee87e5ed24496e82da0b
|
||||
U danielk1977
|
||||
Z d6a6a23d64b55f3f47e9a0fdb32d08db
|
||||
|
@@ -1 +1 @@
|
||||
2aae1964572f4d4d1eae090a997e0bd9a82a69b2
|
||||
665b119a241a5a95f236b3ace1b25fc18ae6f0a3
|
21
src/pager.c
21
src/pager.c
@@ -18,7 +18,7 @@
|
||||
** file simultaneously, or one process from reading the database while
|
||||
** another is writing.
|
||||
**
|
||||
** @(#) $Id: pager.c,v 1.311 2007/03/30 20:43:42 drh Exp $
|
||||
** @(#) $Id: pager.c,v 1.312 2007/03/31 10:00:48 danielk1977 Exp $
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_DISKIO
|
||||
#include "sqliteInt.h"
|
||||
@@ -606,6 +606,7 @@ static int readMasterJournal(OsFile *pJrnl, char **pzMaster){
|
||||
**
|
||||
*/
|
||||
static int seekJournalHdr(Pager *pPager){
|
||||
int rc;
|
||||
i64 offset = 0;
|
||||
i64 c = pPager->journalOff;
|
||||
if( c ){
|
||||
@@ -1673,7 +1674,7 @@ int sqlite3PagerOpen(
|
||||
Pager *pPager = 0;
|
||||
char *zFullPathname = 0;
|
||||
int nameLen; /* Compiler is wrong. This is always initialized before use */
|
||||
OsFile *fd;
|
||||
OsFile *fd = 0;
|
||||
int rc = SQLITE_OK;
|
||||
int i;
|
||||
int tempFile = 0;
|
||||
@@ -1694,15 +1695,13 @@ int sqlite3PagerOpen(
|
||||
assert( pTsd );
|
||||
#endif
|
||||
|
||||
/* If malloc() has already failed return SQLITE_NOMEM. Before even
|
||||
** testing for this, set *ppPager to NULL so the caller knows the pager
|
||||
** structure was never allocated.
|
||||
/* We used to test if malloc() had already failed before proceeding.
|
||||
** But the way this function is used in SQLite means that can never
|
||||
** happen. Furthermore, if the malloc-failed flag is already set,
|
||||
** either the call to sqliteStrDup() or sqliteMalloc() below will
|
||||
** fail shortly and SQLITE_NOMEM returned anyway.
|
||||
*/
|
||||
*ppPager = 0;
|
||||
if( sqlite3MallocFailed() ){
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
memset(&fd, 0, sizeof(fd));
|
||||
|
||||
/* Open the pager file and set zFullPathname to point at malloc()ed
|
||||
** memory containing the complete filename (i.e. including the directory).
|
||||
@@ -2686,6 +2685,10 @@ int sqlite3PagerReleaseMemory(int nReq){
|
||||
** This function is called to obtain the shared lock required before
|
||||
** data may be read from the pager cache. If the shared lock has already
|
||||
** been obtained, this function is a no-op.
|
||||
**
|
||||
** Immediately after obtaining the shared lock (if required), this function
|
||||
** checks for a hot-journal file. If one is found, an emergency rollback
|
||||
** is performed immediately.
|
||||
*/
|
||||
static int pagerSharedLock(Pager *pPager){
|
||||
int rc = SQLITE_OK;
|
||||
|
@@ -12,7 +12,7 @@
|
||||
# focus of this file is testing for correct handling of disk full
|
||||
# errors.
|
||||
#
|
||||
# $Id: diskfull.test,v 1.4 2007/03/15 12:51:17 drh Exp $
|
||||
# $Id: diskfull.test,v 1.5 2007/03/31 10:00:48 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -53,27 +53,64 @@ set sqlite_diskfull_pending 0
|
||||
set sqlite_io_error_hit 0
|
||||
integrity_check diskfull-1.6
|
||||
|
||||
set go 1
|
||||
set i 0
|
||||
while {$go} {
|
||||
incr i
|
||||
do_test diskfull-2.$i.1 {
|
||||
set sqlite_diskfull_pending $i
|
||||
set sqlite_diskfull 0
|
||||
set r [catchsql {VACUUM}]
|
||||
if {!$sqlite_diskfull} {
|
||||
proc do_diskfull_test {prefix sql} {
|
||||
set ::go 1
|
||||
set ::sql $sql
|
||||
set ::i 52
|
||||
while {$::go} {
|
||||
incr ::i
|
||||
do_test ${prefix}.$::i.1 {
|
||||
set ::sqlite_diskfull_pending $::i
|
||||
set ::sqlite_diskfull 0
|
||||
set r [catchsql $::sql]
|
||||
if {!$::sqlite_diskfull} {
|
||||
set r {1 {database or disk is full}}
|
||||
set go 0
|
||||
set ::go 0
|
||||
}
|
||||
if {$r=="1 {disk I/O error}"} {
|
||||
set r {1 {database or disk is full}}
|
||||
}
|
||||
set r
|
||||
} {1 {database or disk is full}}
|
||||
set sqlite_diskfull_pending 0
|
||||
set ::sqlite_diskfull_pending 0
|
||||
db close
|
||||
sqlite3 db test.db
|
||||
integrity_check diskfull-2.$i.2
|
||||
integrity_check ${prefix}.$::i.2
|
||||
}
|
||||
}
|
||||
|
||||
do_diskfull_test diskfull-2 VACUUM
|
||||
|
||||
# db close
|
||||
# file delete -force test.db
|
||||
# file delete -force test.db-journal
|
||||
# sqlite3 db test.db
|
||||
#
|
||||
# do_test diskfull-3.1 {
|
||||
# execsql {
|
||||
# PRAGMA default_cache_size = 10;
|
||||
# CREATE TABLE t3(a, b, UNIQUE(a, b));
|
||||
# INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );
|
||||
# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
|
||||
# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
|
||||
# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
|
||||
# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
|
||||
# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
|
||||
# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
|
||||
# INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
|
||||
# UPDATE t3
|
||||
# SET b = (SELECT a FROM t3 WHERE rowid = (SELECT max(rowid)-1 FROM t3))
|
||||
# WHERE rowid = (SELECT max(rowid) FROM t3);
|
||||
# PRAGMA cache_size;
|
||||
# }
|
||||
# } {10}
|
||||
# breakpoint
|
||||
# do_diskfull_test diskfull-3.2 {
|
||||
# BEGIN;
|
||||
# INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );
|
||||
# UPDATE t3 SET a = b;
|
||||
# COMMIT;
|
||||
# }
|
||||
|
||||
finish_test
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library.
|
||||
#
|
||||
# $Id: misc7.test,v 1.8 2007/03/30 18:21:53 danielk1977 Exp $
|
||||
# $Id: misc7.test,v 1.9 2007/03/31 10:00:49 danielk1977 Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@@ -293,6 +293,40 @@ do_test misc7-15.2 {
|
||||
}
|
||||
} {}
|
||||
|
||||
db close
|
||||
file delete -force test.db
|
||||
file delete -force test.db-journal
|
||||
sqlite3 db test.db
|
||||
|
||||
do_ioerr_test misc7-16 -sqlprep {
|
||||
PRAGMA cache_size = 10;
|
||||
PRAGMA default_cache_size = 10;
|
||||
CREATE TABLE t3(a, b, UNIQUE(a, b));
|
||||
INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );
|
||||
INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
|
||||
INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
|
||||
INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
|
||||
INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
|
||||
INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
|
||||
UPDATE t3
|
||||
SET b = 'hello world'
|
||||
WHERE rowid >= (SELECT max(rowid)-1 FROM t3);
|
||||
} -tclbody {
|
||||
set rc [catch {db eval {
|
||||
BEGIN;
|
||||
PRAGMA cache_size = 10;
|
||||
INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );
|
||||
UPDATE t3 SET a = b;
|
||||
COMMIT;
|
||||
}} msg]
|
||||
|
||||
if {!$rc || ($rc && [string first "columns" $msg]==0)} {
|
||||
set msg
|
||||
} else {
|
||||
error $msg
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#***********************************************************************
|
||||
# This file runs all tests.
|
||||
#
|
||||
# $Id: quick.test,v 1.50 2007/03/26 13:48:14 drh Exp $
|
||||
# $Id: quick.test,v 1.51 2007/03/31 10:00:49 danielk1977 Exp $
|
||||
|
||||
proc lshift {lvar} {
|
||||
upvar $lvar l
|
||||
@@ -50,6 +50,7 @@ set EXCLUDE {
|
||||
malloc2.test
|
||||
malloc3.test
|
||||
memleak.test
|
||||
misc7.test
|
||||
misuse.test
|
||||
quick.test
|
||||
speed1.test
|
||||
|
Reference in New Issue
Block a user