Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Zero cached pages located beyond the end of the file before returning them. Ticket #2285. (CVS 3808) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5180810eeaa3dfe3d934af0732a920ae |
User & Date: | danielk1977 2007-04-05 05:46:14.000 |
Context
2007-04-05
| ||
08:40 | Catch an IO error case introduced by (3808). (CVS 3809) (check-in: 383a08e260 user: danielk1977 tags: trunk) | |
05:46 | Zero cached pages located beyond the end of the file before returning them. Ticket #2285. (CVS 3808) (check-in: 5180810eea user: danielk1977 tags: trunk) | |
2007-04-04
| ||
01:27 | Test coverage improvements. (CVS 3807) (check-in: 25f49acc56 user: drh tags: trunk) | |
Changes
Changes to src/pager.c.
︙ | ︙ | |||
14 15 16 17 18 19 20 | ** 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. ** | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ** 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.317 2007/04/05 05:46:14 danielk1977 Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" #include "os.h" #include "pager.h" #include <assert.h> #include <string.h> |
︙ | ︙ | |||
3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 | #ifdef SQLITE_CHECK_PAGES pPg->pageHash = pager_pagehash(pPg); #endif }else{ /* The requested page is in the page cache. */ assert(pPager->nRef>0 || pgno==1); TEST_INCR(pPager->nHit); page_ref(pPg); } *ppPage = pPg; return SQLITE_OK; } | > > > > > > > > | 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 | #ifdef SQLITE_CHECK_PAGES pPg->pageHash = pager_pagehash(pPg); #endif }else{ /* The requested page is in the page cache. */ assert(pPager->nRef>0 || pgno==1); if( pgno>sqlite3PagerPagecount(pPager) ){ /* This can happen after a truncation in exclusive mode. The pager ** cache contains pages that are located after the end of the ** database file. Zero such pages before returning. Not doing this ** was causing the problem reported in ticket #2285. */ memset(PGHDR_TO_DATA(pPg), 0, pPager->pageSize); } TEST_INCR(pPager->nHit); page_ref(pPg); } *ppPage = pPg; return SQLITE_OK; } |
︙ | ︙ |
Added test/tkt2285.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | # 2005 September 17 # # 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. Specifically. # it contains tests to verify that ticket #2285 has been fixed. # # $Id: tkt2285.test,v 1.1 2007/04/05 05:46:14 danielk1977 Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl ifcapable !tempdb { finish_test return } do_test tkt2285-1.1 { execsql { PRAGMA locking_mode = EXCLUSIVE; } execsql { BEGIN; CREATE TABLE abc(a, b, c); ROLLBACK; } } {} do_test tkt2285-1.2 { execsql { SELECT * FROM sqlite_master; } } {} ifcapable tempdb { do_test tkt2285-2.1 { execsql { BEGIN; CREATE TEMP TABLE abc(a, b, c); ROLLBACK; } } {} do_test tkt2285-2.2 { execsql { SELECT * FROM sqlite_temp_master; } } {} } finish_test |