From: mistachkin Date: Mon, 23 Jan 2017 21:12:15 +0000 (+0000) Subject: Experimental changes to permit a VFS to directly override the initial page size. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6a16fcefa89df1a679aeec9c64284cae54f21d17;p=thirdparty%2Fsqlite.git Experimental changes to permit a VFS to directly override the initial page size. FossilOrigin-Name: 6413172435babe9097e4f961d4b88ddf68e2159d --- diff --git a/manifest b/manifest index f8cd52fc5b..6733594cf0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Document\sthe\s--mmap\soption\sin\sthe\s--help\sscreen\sfor\skvtest.\s\sEnhance\skvtest\sso\nthat\snumeric\sarguments\scan\shave\ssuffixes\slike\s"K"\sor\s"M".\s\sAdd\skvtest\sto\sthe\nunix\smakefiles. -D 2017-01-23T19:11:38.113 +C Experimental\schanges\sto\spermit\sa\sVFS\sto\sdirectly\soverride\sthe\sinitial\spage\ssize. +D 2017-01-23T21:12:15.244 F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -375,9 +375,9 @@ F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c 30e2c43e4955db990e5b5a81e901f8aa74cc8820 -F src/os_win.c cf90abd4e50d9f56d2c20ce8e005aff55d7bd8e9 +F src/os_win.c a55b09ae1cab1a221cea3461c202168587af110c F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c 9dc72d23eebbdf992bd69f2ab954d0d3a27c7340 +F src/pager.c b0ab0c7e028a741140e4e6d6d8a52afa80b77c6f F src/pager.h d1e944291030351f362a0a7da9b5c3e34e603e39 F src/parse.y 29153738a7322054359320eb00b5a4cd44389f20 F src/pcache.c 51070ec9b8251bbf9c6ea3d35fd96a458752929e @@ -392,7 +392,7 @@ F src/resolve.c f9bc0de45a30a450da47b3766de00be89bf9be79 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 3856db523b942062bca8722ba03b61c324ff94d6 F src/shell.c 59de9acab4423a536277653f2a9dcdd1307989f3 -F src/sqlite.h.in 1971ab9709e010d52a02a1a6276d5a2f9b947476 +F src/sqlite.h.in 89b948cfa352cca946a5b20d9378df30d612f282 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae F src/sqliteInt.h 525c061ae9aafc8d4720a018d82f0936d9eee5ab @@ -1547,7 +1547,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 4948f7e6d2a1cfce36a7aab2f5b65be07c285ac3 -R 9f530d22e2b0a16555eacd054431a10f -U drh -Z 4864426d37a32c6f04be82da7889e371 +P 175bda87288c7ce15b163316159f53a60822ccad +R 05a49ef0621a4d438c613d21cd9494c5 +T *branch * pagePerSector +T *sym-pagePerSector * +T -sym-trunk * +U mistachkin +Z d580907a4e3e3f7a77c49fbb8487d254 diff --git a/manifest.uuid b/manifest.uuid index 82e31c7d74..99df932dad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -175bda87288c7ce15b163316159f53a60822ccad \ No newline at end of file +6413172435babe9097e4f961d4b88ddf68e2159d \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 2cb5f7b0c8..eb603b2eca 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -307,6 +307,7 @@ struct winVfsAppData { #define WINFILE_RDONLY 0x02 /* Connection is read only */ #define WINFILE_PERSIST_WAL 0x04 /* Persistent WAL mode */ #define WINFILE_PSOW 0x10 /* SQLITE_IOCAP_POWERSAFE_OVERWRITE */ +#define WINFILE_PPS 0x20 /* SQLITE_IOCAP_PAGE_PER_SECTOR */ /* * The size of the buffer used by sqlite3_win32_write_debug(). @@ -3468,6 +3469,11 @@ static int winFileControl(sqlite3_file *id, int op, void *pArg){ OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h)); return SQLITE_OK; } + case SQLITE_FCNTL_PAGE_PER_SECTOR: { + winModeBit(pFile, WINFILE_PPS, (int*)pArg); + OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h)); + return SQLITE_OK; + } case SQLITE_FCNTL_VFSNAME: { *(char**)pArg = sqlite3_mprintf("%s", pFile->pVfs->zName); OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h)); @@ -3559,6 +3565,7 @@ static int winSectorSize(sqlite3_file *id){ static int winDeviceCharacteristics(sqlite3_file *id){ winFile *p = (winFile*)id; return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | + ((p->ctrlFlags & WINFILE_PPS)?SQLITE_IOCAP_PAGE_PER_SECTOR:0) | ((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0); } @@ -5107,6 +5114,9 @@ static int winOpen( if( sqlite3_uri_boolean(zName, "psow", SQLITE_POWERSAFE_OVERWRITE) ){ pFile->ctrlFlags |= WINFILE_PSOW; } + if( sqlite3_uri_boolean(zName, "pps", 0) ){ + pFile->ctrlFlags |= WINFILE_PPS; + } pFile->lastErrno = NO_ERROR; pFile->zPath = zName; #if SQLITE_MAX_MMAP_SIZE>0 diff --git a/src/pager.c b/src/pager.c index 5813b4db47..9c3977d555 100644 --- a/src/pager.c +++ b/src/pager.c @@ -4763,7 +4763,9 @@ int sqlite3PagerOpen( if( !readOnly ){ setSectorSize(pPager); assert(SQLITE_DEFAULT_PAGE_SIZE<=SQLITE_MAX_DEFAULT_PAGE_SIZE); - if( szPageDfltsectorSize ){ + if( iDc&SQLITE_IOCAP_PAGE_PER_SECTOR ){ + szPageDflt = (u32)pPager->sectorSize; + }else if( szPageDfltsectorSize ){ if( pPager->sectorSize>SQLITE_MAX_DEFAULT_PAGE_SIZE ){ szPageDflt = SQLITE_MAX_DEFAULT_PAGE_SIZE; }else{ diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 87d5d121cb..d9546622e0 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -579,7 +579,9 @@ int sqlite3_exec( ** flag indicates that a file cannot be deleted when open. The ** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on ** read-only media and cannot be changed even by processes with -** elevated privileges. +** elevated privileges. The SQLITE_IOCAP_PAGE_PER_SECTOR flag indicates +** the initial page size for new databases should set to the sector size +** reported by the VFS. */ #define SQLITE_IOCAP_ATOMIC 0x00000001 #define SQLITE_IOCAP_ATOMIC512 0x00000002 @@ -595,6 +597,7 @@ int sqlite3_exec( #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 #define SQLITE_IOCAP_IMMUTABLE 0x00002000 +#define SQLITE_IOCAP_PAGE_PER_SECTOR 0x00004000 /* ** CAPI3REF: File Locking Levels @@ -729,6 +732,7 @@ struct sqlite3_file { **
  • [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN] **
  • [SQLITE_IOCAP_POWERSAFE_OVERWRITE] **
  • [SQLITE_IOCAP_IMMUTABLE] +**
  • [SQLITE_IOCAP_PAGE_PER_SECTOR] ** ** ** The SQLITE_IOCAP_ATOMIC property means that all writes of @@ -1012,6 +1016,15 @@ struct sqlite3_io_methods { ** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by ** the RBU extension only. All other VFS should return SQLITE_NOTFOUND for ** this opcode. +** +**
  • [[SQLITE_FCNTL_PAGE_PER_SECTOR]] +** ^The [SQLITE_FCNTL_PAGE_PER_SECTOR] opcode is used to set or query the +** persistent "page-per-sector" or "PPS" setting. The PPS setting determines +** the [SQLITE_IOCAP_PAGE_PER_SECTOR] bit of the xDeviceCharacteristics +** methods. The fourth parameter to [sqlite3_file_control()] for this opcode +** should be a pointer to an integer. That integer is 0 to disable +** page-per-sector mode or 1 to enable page-per-sector mode. If the integer +** is -1, then it is overwritten with the current page-per-sector mode setting. ** */ #define SQLITE_FCNTL_LOCKSTATE 1 @@ -1043,6 +1056,7 @@ struct sqlite3_io_methods { #define SQLITE_FCNTL_JOURNAL_POINTER 28 #define SQLITE_FCNTL_WIN32_GET_HANDLE 29 #define SQLITE_FCNTL_PDB 30 +#define SQLITE_FCNTL_PAGE_PER_SECTOR 31 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE