]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Do not use the page containing locks for anything to avoid problems with
authordrh <drh@noemail.net>
Tue, 15 Jun 2004 01:40:29 +0000 (01:40 +0000)
committerdrh <drh@noemail.net>
Tue, 15 Jun 2004 01:40:29 +0000 (01:40 +0000)
the manditory file locking on windows. (CVS 1595)

FossilOrigin-Name: 5a814202777f381caf5337b37e11c9ab8b8f554a

manifest
manifest.uuid
src/btree.c
src/os.h
src/pager.c

index b3e9a71e7d8fed0dc1e61784259cdd3c7a11b821..32b9f3e97706892d54a1aa08692353777575150c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sthe\ssqlite3OsFileModTime()\sinterface.\s\sBut\sit\sis\sstill\sunused.\s\sThe\nchange\scounter\sin\spage\s1\sis\salways\sincremented.\s(CVS\s1594)
-D 2004-06-15T00:29:04
+C Do\snot\suse\sthe\spage\scontaining\slocks\sfor\sanything\sto\savoid\sproblems\swith\nthe\smanditory\sfile\slocking\son\swindows.\s(CVS\s1595)
+D 2004-06-15T01:40:29
 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -26,7 +26,7 @@ F sqlite.def fc4f5734786fe4743cfe2aa98eb2da4b089edb5f
 F sqlite.pc.in 30552343140c53304c2a658c080fbe810cd09ca2
 F src/attach.c 93b8ecec4a8d7b4e9f2479e2327d90c9d01765e8
 F src/auth.c 204e1e9c45e64315589bc8b62cba5d9de29b6a3c
-F src/btree.c 1bed18993e54483de8ff869142e82c48847e1d50
+F src/btree.c a9aabed057eacdaf617caeddc7b136bd831ab22c
 F src/btree.h 32f96abef464cf8765b23ca669acfe90d191fcc5
 F src/build.c 916a84fa5f8bfd44dbe14c3d7c923dd07ee7373f
 F src/date.c 65b483caeb0e4dd663667d2f927caa058168ebff
@@ -40,7 +40,7 @@ F src/insert.c 68c7f3ddd6a7f1e5596d6996da1a2861b3789a3a
 F src/legacy.c ad23746f15f67e34577621b1875f639c94839e1f
 F src/main.c a62c08c9d315c3ebc58bfb6b52ab5953ee8a3089
 F src/md5.c d77a389955759c8329bb357e3d71bac3d6eb710b
-F src/os.h be7323afb3d371bcab438556ddb5fda397e3d815
+F src/os.h 1cb5f0293a30288451fe3c0c73815cf208212ed1
 F src/os_common.h ba1b7306e16e2091718f2c48db0fe6c1d7a31bb8
 F src/os_mac.c 129029f9faecf1133edcf72eaedd54c1c838b140
 F src/os_mac.h 51d2445f47e182ed32d3bd6937f81070c6fd9bd4
@@ -48,7 +48,7 @@ F src/os_unix.c 7eac2e840300848818f53e6e78cd19d128e936bd
 F src/os_unix.h 1cd6133cf66dea704b8646b70b2dfdcbdd9b3738
 F src/os_win.c a60f9ebfb0ce3e5b2ce259f981af59a50b24fc8d
 F src/os_win.h 004eec47b1780fcaf07420ddc2072294b698d48c
-F src/pager.c d42af374b23b50805b42c08cbba5bd70dd73964f
+F src/pager.c bf81f3c8105f8b257ee07575d0040ee2c3822a51
 F src/pager.h bc58d32a9dee464f7268fb68652c130a4216e438
 F src/parse.y 097438674976355a10cf177bd97326c548820b86
 F src/pragma.c e288bd122d3ca41ec2032475abde1ff5fa3095f4
@@ -223,7 +223,7 @@ F www/support.tcl 1801397edd271cc39a2aadd54e701184b5181248
 F www/tclsqlite.tcl 19191cf2a1010eaeff74c51d83fd5f5a4d899075
 F www/vdbe.tcl 59288db1ac5c0616296b26dce071c36cb611dfe9
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P af6edd2c0ad160435acd5bfa7af36c4f394f0bb8
-R 8390b0ef3815bc1230f728916c2a8366
+P 186c6f93e12978907c5f0ff81d90bdf7367b9274
+R 39de485059268cbc8025aa3dc3a9cdaa
 U drh
-Z b91d1156cec1d19e076cf36f8583344f
+Z f0561e35a6d128f341936bb7b7366398
index 48538b215af48162ce7503354491d94d45748805..351e16561dce23b51cdbdfed846a2d5632269ecc 100644 (file)
@@ -1 +1 @@
-186c6f93e12978907c5f0ff81d90bdf7367b9274
\ No newline at end of file
+5a814202777f381caf5337b37e11c9ab8b8f554a
\ No newline at end of file
index b35eed10cdcceecc730f73b9736f57f8a8141f3e..eeabab175ada548961a4a06b3c392dd3b7ea56ac 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.166 2004/06/14 06:03:57 danielk1977 Exp $
+** $Id: btree.c,v 1.167 2004/06/15 01:40:29 drh Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** For a detailed discussion of BTrees, refer to
 #include "sqliteInt.h"
 #include "pager.h"
 #include "btree.h"
+#include "os.h"
 #include <assert.h>
 
 
@@ -4146,6 +4147,10 @@ char *sqlite3BtreeIntegrityCheck(Btree *pBt, int *aRoot, int nRoot){
   }
   sCheck.anRef = sqliteMallocRaw( (sCheck.nPage+1)*sizeof(sCheck.anRef[0]) );
   for(i=0; i<=sCheck.nPage; i++){ sCheck.anRef[i] = 0; }
+  i = PENDING_BYTE/pBt->pageSize + 1;
+  if( i<=sCheck.nPage ){
+    sCheck.anRef[i] = 1;
+  }
   sCheck.zErrMsg = 0;
 
   /* Check the integrity of the freelist
index c7ae01ed7b860e7a632814965b3a45b2c4b2caad..225c2d8628104e35d82fdef38bbc204fa6771c9b 100644 (file)
--- a/src/os.h
+++ b/src/os.h
 #define EXCLUSIVE_LOCK  4
 
 /*
-** Windows file locking notes:
+** File Locking Notes:  (Mostly about windows but also some info for Unix)
 **
 ** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because
 ** those functions are not available.  So we use only LockFile() and
 ** UnlockFile().
 **
 ** LockFile() prevents not just writing but also reading by other processes.
-** (This is a design error on the part of Windows, but there is nothing
-** we can do about that.)  So the region used for locking is at the
-** end of the file where it is unlikely to ever interfere with an
-** actual read attempt.
-**
 ** A SHARED_LOCK is obtained by locking a single randomly-chosen 
 ** byte out of a specific range of bytes. The lock byte is obtained at 
 ** random so two separate readers can probably access the file at the 
 ** These #defines are available in os.h so that Unix can use the same
 ** byte ranges for locking.  This leaves open the possiblity of having
 ** clients on win95, winNT, and unix all talking to the same shared file
-** and all locking correctly.
+** and all locking correctly.  To do so would require that samba (or whatever
+** tool is being used for file sharing) implements locks correctly between
+** windows and unix.  I'm guessing that isn't likely to happen, but by
+** using the same locking range we are at least open to the possibility.
 **
 ** Locking in windows is manditory.  For this reason, we cannot store
 ** actual data in the bytes used for locking.  The pager never allocates
-** the pages involved in locking therefore.
+** the pages involved in locking therefore.  SHARED_SIZE is selected so
+** that all locks will fit on a single page even at the minimum page size.
+** PENDING_BYTE defines the beginning of the locks.  By default PENDING_BYTE
+** is set high so that we don't have to allocate an unused page except
+** for very large databases.  But one should test the page skipping logic 
+** by setting PENDING_BYTE low and running the entire regression suite.
+**
+** Changing the value of PENDING_BYTE results in a subtly incompatible
+** file format.  Depending on how it is changed, you might not notice
+** the incompatibility right away, even running a full regression test.
+** The default location of PENDING_BYTE is the first byte past the
+** 1GB boundary.
+**
 */
-#define SHARED_SIZE       10238
-#define SHARED_FIRST      (0x3fffffff - (SHARED_SIZE - 1))
-#define RESERVED_BYTE     (SHARED_FIRST - 1)
-#define PENDING_BYTE      (RESERVED_BYTE - 1)
+#define PENDING_BYTE      0x40000000  /* First byte past the 1GB boundary */
+/* #define PENDING_BYTE     0x5400   // Page 20 - for testing */
+#define RESERVED_BYTE     (PENDING_BYTE+1)
+#define SHARED_FIRST      (PENDING_BYTE+2)
+#define SHARED_SIZE       510
 
 
 int sqlite3OsDelete(const char*);
index d80e23628efb45f2b4a5705ba3a466f75a19be3b..334f578d0eb2e81a380d0b1be5be1e94027b1607 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.126 2004/06/14 06:03:57 danielk1977 Exp $
+** @(#) $Id: pager.c,v 1.127 2004/06/15 01:40:29 drh Exp $
 */
 #include "os.h"         /* Must be first to enable large file support */
 #include "sqliteInt.h"
@@ -1205,6 +1205,9 @@ int sqlite3pager_pagecount(Pager *pPager){
     return 0;
   }
   n /= SQLITE_PAGE_SIZE;
+  if( !pPager->memDb && n==PENDING_BYTE/SQLITE_PAGE_SIZE ){
+    n++;
+  }
   if( pPager->state!=PAGER_UNLOCK ){
     pPager->dbSize = n;
   }
@@ -2209,6 +2212,9 @@ int sqlite3pager_write(void *pData){
   */
   if( pPager->dbSize<(int)pPg->pgno ){
     pPager->dbSize = pPg->pgno;
+    if( !pPager->memDb && pPager->dbSize==PENDING_BYTE/pPager->pageSize ){
+      pPager->dbSize++;
+    }
   }
   return rc;
 }