]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Zero cached pages located beyond the end of the file before returning them. Ticket...
authordanielk1977 <danielk1977@noemail.net>
Thu, 5 Apr 2007 05:46:14 +0000 (05:46 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Thu, 5 Apr 2007 05:46:14 +0000 (05:46 +0000)
FossilOrigin-Name: 5180810eeaa3dfe3d934af0732a920ae117ec69f

manifest
manifest.uuid
src/pager.c
test/tkt2285.test [new file with mode: 0644]

index cdbf60b74e1f02e181748352a4374d10a4297e47..53516e84338a3a8f003e1494cc656938a0887645 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Test\scoverage\simprovements.\s(CVS\s3807)
-D 2007-04-04T01:27:44
+C Zero\scached\spages\slocated\sbeyond\sthe\send\sof\sthe\sfile\sbefore\sreturning\sthem.\sTicket\s#2285.\s(CVS\s3808)
+D 2007-04-05T05:46:14
 F Makefile.in 29fbf08ce0989973bfed0b5a052a6bdf3e60fd0a
 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -86,7 +86,7 @@ F src/os_unix.c 13c6f73a7b0c2c6c131c97ea26274db101b594cd
 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
 F src/os_win.c c9a99524d6b2bdec636264cad1b67553925e3309
 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c 30e4a54e4ce9817839043eaa8968aace95f73ed9
+F src/pager.c 1808ab8f0d96f9db663ae72f1430d7f03e944183
 F src/pager.h e79a24cf200b8771366217f5bca414f5b7823f42
 F src/parse.y 207ab04273ae13aa4a729b96008d294d5f334ab3
 F src/pragma.c 3b992b5b2640d6ae25cef05aa6a42cd1d6c43234
@@ -340,6 +340,7 @@ F test/tkt2141.test 78fb8ea2e7e38f7e5b3e649ca9426928056ef55c
 F test/tkt2192.test 480d0e017ddb01a46ee20809427370f343bb3c03
 F test/tkt2213.test 8cf7c446e1fcd0627fffe7fc19046eb24ac7333b
 F test/tkt2251.test 3f0549213386ed911715665a908ff2bb7a871002
+F test/tkt2285.test c618085f0c13ec3347e607f83c34ada0721b4bfa
 F test/trace.test 75ffc1b992c780d054748a656e3e7fd674f18567
 F test/trans.test 3fe1b9e03b523482eee2b869858c5c1eca7b218b
 F test/trigger1.test 2c79e2bf76350811e362814e98779c120b6a9421
@@ -449,7 +450,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 9e004c519a30257fe3230ac7af630d296e139c9e
-R c3d1ddced52ccaeeb6e02437b488e0f6
-U drh
-Z e64f6bfd901042c7a2493a1d94243acf
+P 25f49acc5662ed8dd321b83a60aeeab93a37e129
+R 251ec34a8be2bb7fab2cf227d3aa0f5e
+U danielk1977
+Z cf8f427e30b9108b742d861c8c1c1fa0
index 893d8bf025394e99d857b4aeda4e2756be710f52..36d33793836ddb7841a71b219aa09f4cd620175e 100644 (file)
@@ -1 +1 @@
-25f49acc5662ed8dd321b83a60aeeab93a37e129
\ No newline at end of file
+5180810eeaa3dfe3d934af0732a920ae117ec69f
\ No newline at end of file
index 27d659d69e4f100dd3d92ce5957101b64fd83b00..19ebc8746581e665afb93f14fe9fd30baa2ab434 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.316 2007/04/02 11:22:22 drh Exp $
+** @(#) $Id: pager.c,v 1.317 2007/04/05 05:46:14 danielk1977 Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -3028,6 +3028,14 @@ int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag){
   }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);
   }
diff --git a/test/tkt2285.test b/test/tkt2285.test
new file mode 100644 (file)
index 0000000..55f0b4c
--- /dev/null
@@ -0,0 +1,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
+