]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add new OS file method to return the sector-size of the underlying storage: sqlite3Os...
authordanielk1977 <danielk1977@noemail.net>
Mon, 19 Mar 2007 05:54:48 +0000 (05:54 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Mon, 19 Mar 2007 05:54:48 +0000 (05:54 +0000)
FossilOrigin-Name: 5752d84d374205e011d49b0221d6237967fe0743

12 files changed:
manifest
manifest.uuid
src/os.c
src/os.h
src/os_common.h
src/os_os2.c
src/os_unix.c
src/os_win.c
src/pager.c
src/test6.c
src/test_async.c
test/crash2.test

index a1f1e8d28a0b56941c0b56ecb011979bcf714426..1ae29a1ab635ea43ac53825cba25424ae33d75fa 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sdocumentation\sof\sthe\sREPLACE,\sTRIM,\sLTRIM,\sand\sRTRIM\sfunctions.\s(CVS\s3699)
-D 2007-03-17T18:22:58
+C Add\snew\sOS\sfile\smethod\sto\sreturn\sthe\ssector-size\sof\sthe\sunderlying\sstorage:\ssqlite3OsSectorSize()\s(CVS\s3700)
+D 2007-03-19T05:54:49
 F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -75,18 +75,18 @@ F src/legacy.c 2631df6a861f830d6b1c0fe92b9fdd745b2c0cd6
 F src/loadext.c bbfdbf452c71b6f2723375478a365788498ec3cd
 F src/main.c af8922e0205cf618392de2836c9efad71786d0d6
 F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
-F src/os.c 59f05de8c5777c34876607114a2fbe55ae578235
-F src/os.h 17fc73165cb7436aa79492d2dff754baec74fcb9
-F src/os_common.h 970899e83de0ba177d6fbdf9d700457fa3c6df8c
-F src/os_os2.c 8ee8207fe218a1acf3a31d59753e165e5c23bb95
+F src/os.c 6df3e9c23eaa982d3e66ef770ad2519de5dd4d97
+F src/os.h ec780b3561d0bb887d13f193a1a889872c44a236
+F src/os_common.h aa3ef56941dcaf480b6f055a615674fe4909edbc
+F src/os_os2.c 175101ffc2142c3fc7962ed7a171806f28f95363
 F src/os_os2.h e5f17dd69333632bbc3112881ea407c37d245eb3
 F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
 F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
-F src/os_unix.c a3b26ad8270aea899f9d65fd2e6a176b05d2ef8f
+F src/os_unix.c 33ee7c1483fbd4d67cf5638c87622c277442b744
 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
-F src/os_win.c 8736cf3a49fd651a6538857480f302807d57814c
+F src/os_win.c f3ca3e08167eb3382781b840e787809eccb626dc
 F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
-F src/pager.c ccca82d0f6644b95fd4f985d7049f1505443f048
+F src/pager.c 097923484be9edfb238920ad61583ad98ef3bbb3
 F src/pager.h 8881591ca23d1e5fd83c95fa8317245fbcf64227
 F src/parse.y bcfe366c1fd61cfc40e5344eb69a31997a821af0
 F src/pragma.c b52dcf2fbb46f3266f9d00b88054c684df3af2e7
@@ -106,10 +106,10 @@ F src/test2.c 59085c04e22a22bed9f1078ab318adc34c1229f3
 F src/test3.c ed494a126221c4b9f66f8f0445554ad749764709
 F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
 F src/test5.c 7162f8526affb771c4ed256826eee7bb9eca265f
-F src/test6.c edbd903a4886c171f199048af58c3aa5b2a86712
+F src/test6.c 5957d249d437e4db74045ce2f1f661648d94bf94
 F src/test7.c 03fa8d787f6aebc6d1f72504d52f33013ad2c8e3
 F src/test8.c 628ec89f9fbf3bfb9c58a503d845a0719595d0ad
-F src/test_async.c e3deaedd4d86a56391b81808fde9e44fbd92f1d3
+F src/test_async.c 33eb896746b512078a83cd5424de37445bb30de2
 F src/test_autoext.c 855157d97aa28cf84233847548bfacda21807436
 F src/test_loadext.c 22065d601a18878e5542191001f0eaa5d77c0ed8
 F src/test_md5.c 6c42bc0a3c0b54be34623ff77a0eec32b2fa96e3
@@ -184,7 +184,7 @@ F test/conflict.test 8a59399f61a14296a9bfed02e0570590a8a79cba
 F test/corrupt.test 18c7a995b1af76a8c8600b996257f2c7b7bff083
 F test/corrupt2.test 572f8df0303d0ce63ddad5c5c9101a83a345ae46
 F test/crash.test 167eb4652eccbedb199b6f21850346c3f5d779fb
-F test/crash2.test 10be14f91865c6959db6764a7dd478c6561bf4c1
+F test/crash2.test 18bbb71c41de2b7892562679f3cdb72b86d4cd27
 F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2
 F test/date.test 63cc718e1d209b10c6b7be8ce72b11addb9f1e04
 F test/default.test 252298e42a680146b1dd64f563b95bdf088d94fb
@@ -437,7 +437,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 6fe13eeade4fc7099fbda1e6520640927c08debc
-R e59c456a15c824af13e66ea80698a647
-U drh
-Z 83430ba34df4fa316ba8687bbb9080e3
+P d42c9636205a1a649cffcaeabff2b9b32016db31
+R aace24c3ad1a66792ced6daa5ca6df05
+U danielk1977
+Z a82901bb045246e4e447c22d214c62f4
index b1c23dbc8a48b1353d131e674d341b416259f741..66f0c8e970e7d0f0cf56804e8844e73b021813c7 100644 (file)
@@ -1 +1 @@
-d42c9636205a1a649cffcaeabff2b9b32016db31
\ No newline at end of file
+5752d84d374205e011d49b0221d6237967fe0743
\ No newline at end of file
index ec482fe0e7c2754eb4a80be142784ba22170eb36..b60831d6aa448d34293d394023f2dfb438d4b667 100644 (file)
--- a/src/os.c
+++ b/src/os.c
@@ -75,6 +75,9 @@ int sqlite3OsLockState(OsFile *id){
 int sqlite3OsCheckReservedLock(OsFile *id){
   return id->pMethod->xCheckReservedLock(id);
 }
+int sqlite3OsSectorSize(OsFile *id){
+  return id->pMethod->xSectorSize(id);
+}
 
 #ifdef SQLITE_ENABLE_REDEF_IO
 /*
index 0fe7b156ee917c7319efcf7ad83d11d56703b64f..b0afe2f68417b9daecf966630ec18f5ea0b2b6b5 100644 (file)
--- a/src/os.h
+++ b/src/os.h
@@ -216,6 +216,7 @@ struct IoMethod {
   int (*xUnlock)(OsFile*, int);
   int (*xLockState)(OsFile *id);
   int (*xCheckReservedLock)(OsFile *id);
+  int (*xSectorSize)(OsFile *id);
 };
 
 /*
@@ -346,6 +347,7 @@ int sqlite3OsFileExists(const char*);
 char *sqlite3OsFullPathname(const char*);
 int sqlite3OsIsDirWritable(char*);
 int sqlite3OsSyncDirectory(const char*);
+int sqlite3OsSectorSize(OsFile *id);
 int sqlite3OsTempFileName(char*);
 int sqlite3OsRandomSeed(char*);
 int sqlite3OsSleep(int ms);
index ef340b8401e5a7357909e08ad214b66c1730f6be..89bdeabe04bf9d85f225543a35f78bf3f1eca3ca 100644 (file)
@@ -190,3 +190,14 @@ void sqlite3GenericFree(void *p){
 /* Never actually used, but needed for the linker */
 int sqlite3GenericAllocationSize(void *p){ return 0; }
 #endif
+
+/*
+** The default size of a disk sector
+*/
+#ifndef PAGER_SECTOR_SIZE
+# define PAGER_SECTOR_SIZE 512
+#endif
+static int osGenericSectorSize(OsFile *id){
+  return PAGER_SECTOR_SIZE;
+}
+
index ee50c3dec2b672b1ca35f8501e14d08f44785fbe..a2cade29f1401061eee1b3194ea7e9e751a6974a 100644 (file)
@@ -751,6 +751,7 @@ static const IoMethod sqlite3Os2IoMethod = {
   os2Unlock,
   os2LockState,
   os2CheckReservedLock,
+  osGenericSectorSize,
 };
 
 /*
index 5508240feb82f6584bafdf66793dccc685e22976..42d988403ee20934d006b2f33c7358f7194a35f0 100644 (file)
@@ -2355,6 +2355,7 @@ static const IoMethod sqlite3UnixIoMethod = {
   unixUnlock,
   unixLockState,
   unixCheckReservedLock,
+  osGenericSectorSize,
 };
 
 #ifdef SQLITE_ENABLE_LOCKING_STYLE
@@ -2377,6 +2378,7 @@ static const IoMethod sqlite3AFPLockingUnixIoMethod = {
     afpUnixUnlock,
     unixLockState,
     afpUnixCheckReservedLock,
+    osGenericSectorSize,
 };
 
 /*
@@ -2398,6 +2400,7 @@ static const IoMethod sqlite3FlockLockingUnixIoMethod = {
     flockUnixUnlock,
     unixLockState,
     flockUnixCheckReservedLock,
+    osGenericSectorSize,
 };
 
 /*
@@ -2419,6 +2422,7 @@ static const IoMethod sqlite3DotlockLockingUnixIoMethod = {
     dotlockUnixUnlock,
     unixLockState,
     dotlockUnixCheckReservedLock,
+    osGenericSectorSize,
 };
 
 /*
@@ -2440,6 +2444,7 @@ static const IoMethod sqlite3NolockLockingUnixIoMethod = {
   nolockUnixUnlock,
   unixLockState,
   nolockUnixCheckReservedLock,
+  osGenericSectorSize,
 };
 
 #endif /* SQLITE_ENABLE_LOCKING_STYLE */
index 2fcc245709f5a50f6c346fe988b1f288486e10e7..bc348bbc30855a684f741a1d9f3a5222bd1200b8 100644 (file)
@@ -1473,6 +1473,7 @@ static const IoMethod sqlite3WinIoMethod = {
   winUnlock,
   winLockState,
   winCheckReservedLock,
+  osGenericSectorSize,
 };
 
 /*
index b795fd3bf50eb037ccf789e5f6edaa7291d056f2..0565898c834e71fe1df1a93e221a1764882de6e8 100644 (file)
@@ -18,7 +18,7 @@
 ** file simultaneously, or one process from reading the database while
 ** another is writing.
 **
-** @(#) $Id: pager.c,v 1.288 2007/03/15 12:51:16 drh Exp $
+** @(#) $Id: pager.c,v 1.289 2007/03/19 05:54:49 danielk1977 Exp $
 */
 #ifndef SQLITE_OMIT_DISKIO
 #include "sqliteInt.h"
@@ -349,13 +349,6 @@ static const unsigned char aJournalMagic[] = {
 # define MEMDB pPager->memDb
 #endif
 
-/*
-** The default size of a disk sector
-*/
-#ifndef PAGER_SECTOR_SIZE
-# define PAGER_SECTOR_SIZE 512
-#endif
-
 /*
 ** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is
 ** reserved for working around a windows/posix incompatibility). It is
@@ -1394,7 +1387,7 @@ end_playback:
   ** back a journal created by a process with a different PAGER_SECTOR_SIZE
   ** value. Reset it to the correct value for this process.
   */
-  pPager->sectorSize = PAGER_SECTOR_SIZE;
+  pPager->sectorSize = sqlite3OsSectorSize(pPager->fd);
   return rc;
 }
 
@@ -1738,7 +1731,10 @@ int sqlite3pager_open(
   /* pPager->pFirstSynced = 0; */
   /* pPager->pLast = 0; */
   pPager->nExtra = FORCE_ALIGNMENT(nExtra);
-  pPager->sectorSize = PAGER_SECTOR_SIZE;
+  assert(fd||memDb);
+  if( !memDb ){
+    pPager->sectorSize = sqlite3OsSectorSize(fd);
+  }
   /* pPager->pBusyHandler = 0; */
   /* memset(pPager->aHash, 0, sizeof(pPager->aHash)); */
   *ppPager = pPager;
index 1743342070176743467ab55089821ab2e547a692..743663a1cf45717ffce414d2eedbe87848c8f79b 100644 (file)
@@ -478,6 +478,13 @@ int crashFileHandle(OsFile *id){
   return 0;
 }
 
+/*
+** Return the simulated file-system sector size.
+*/
+int crashSectorSize(OsFile *id){
+  return BLOCKSIZE;
+}
+
 /*
 ** This vector defines all the methods that can operate on an OsFile
 ** for the crash tester.
@@ -497,6 +504,7 @@ static const IoMethod crashIoMethod = {
   crashUnlock,
   crashLockState,
   crashCheckReservedLock,
+  crashSectorSize,
 };
 
 
index f5167341c1635f14c6e136a5996a5a56772a852c..c2750722760e16fa1287f27ae4f0beabce64b877 100644 (file)
@@ -650,6 +650,13 @@ static int asyncCheckReservedLock(OsFile *id){
   return rc>SHARED_LOCK;
 }
 
+static int asyncSectorSize(OsFile *id){
+  /* TODO: This is tricky to implement, as this backend might not have
+  ** an open file handle at this point.
+  */
+  return 512;
+}
+
 /* 
 ** This is broken. But sqlite3OsLockState() is only used for testing anyway.
 */
@@ -697,7 +704,8 @@ static int asyncOpenFile(
     asyncLock,
     asyncUnlock,
     asyncLockState,
-    asyncCheckReservedLock
+    asyncCheckReservedLock,
+    asyncSectorSize,
   };
 
   if( openForWriting && SQLITE_ASYNC_TWO_FILEHANDLES ){
index 07e555665b9b99b6050547fcc3f5234d2c3e8a7c..6083de60be05200711fbcfc8c33eb788c8a31b6a 100644 (file)
@@ -16,7 +16,7 @@
 # specifically, the tests in this file verify this functionality
 # for storage mediums with various sector sizes.
 #
-# $Id: crash2.test,v 1.1 2007/03/17 10:28:05 danielk1977 Exp $
+# $Id: crash2.test,v 1.2 2007/03/19 05:54:50 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl