1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-30 19:03:16 +03:00

Add the SQLITE_IOCAP_BYPASS device characteristic. Do not allow the

SQLITE_DIRECT_OVERFLOW_READ optimization if that capability is missing.

FossilOrigin-Name: f50ae00ce9ff572e6bd5e2788602ba356383526ab7289622a32fbf52926c6df0
This commit is contained in:
drh
2024-10-22 18:00:26 +00:00
parent 76e48f4d66
commit c8284c766a
6 changed files with 36 additions and 17 deletions

View File

@ -1,5 +1,5 @@
C Do\snot\stypedef\sTcl_Size\sif\sit\sis\salready\s#defined.
D 2024-10-22T16:19:14.101
C Add\sthe\sSQLITE_IOCAP_BYPASS\sdevice\scharacteristic.\s\sDo\snot\sallow\sthe\nSQLITE_DIRECT_OVERFLOW_READ\soptimization\sif\sthat\scapability\sis\smissing.
D 2024-10-22T18:00:26.006
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -756,10 +756,10 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63
F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06
F src/os_kv.c 4d39e1f1c180b11162c6dc4aa8ad34053873a639bac6baae23272fc03349986a
F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d872107
F src/os_unix.c 14d0f80e4779f5f76bcc71e7af97e3efe318fa3d0b22335623c59fab7d39302b
F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a
F src/os_unix.c 60dd0dbbcf82a351f62da9719bc652e866050413618c37b111e8a6e4087730ae
F src/os_win.c e682c5d822b0a4a8faa1e74aebb36c6b62a23b8f8a96cdc6cf224c1a5d830812
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
F src/pager.c b08600ebf0db90b6d1e9b8b6577c6fa3877cbe1a100bd0b2899e4c6e9adad4b3
F src/pager.c a621100d4b19251d9825fe0a560c12da6ad02b9bf89d6d34b2c77cfbfadf6333
F src/pager.h 4b1140d691860de0be1347474c51fee07d5420bd7f802d38cbab8ea4ab9f538a
F src/parse.y a7a8d42eeff01d267444ddb476029b0b1726fb70ae3d77984140f17ad02e2d61
F src/pcache.c 588cc3c5ccaaadde689ed35ce5c5c891a1f7b1f4d1f56f6cf0143b74d8ee6484
@ -774,7 +774,7 @@ F src/resolve.c c8a5372b97b2a2e972a280676f06ddb5b74e885d3b1f5ce383f839907b57ef68
F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
F src/select.c 4b14337a2742f0c0beeba490e9a05507e9b4b12184b9cd12773501d08d48e3fe
F src/shell.c.in 0662f9bcf0725461778d0254a06150e5d61c08c5a87a7281ccdf45552050c79d
F src/sqlite.h.in add9e064d6b42af8f1a4a3322bddadec76696e520aedebd83e0d3211c15ac999
F src/sqlite.h.in 26f82d2ad6f1285b4d7f6d7c2067310a177cf39c5ffa139d724c7d8efba5cb17
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 3f046c04ea3595d6bfda99b781926b17e672fd6d27da2ba6d8d8fc39981dcb54
F src/sqliteInt.h baae24292817e13e7fe748851c62efc381dcc4dac241b1182eac3d2f05eae52c
@ -2219,8 +2219,11 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P e2bd3219d9f7bab377ebcfa9a737ca59899c68dad1e3d1d16347bbfdd25652ee
R ca8802466a5e5918921ffde8ccadae70
P 53491688cf622ca317b3ff56156e601c2bdfffc94e4fe471ca82d5ba1d9e875f
R 5dd71efbba0819b90a27d697905cee09
T *branch * bypass-iocap
T *sym-bypass-iocap *
T -sym-trunk *
U drh
Z ec07baffb11da349364a8e022541c4d6
Z 80285e6bf3f9959bc9d1afa1996b9b4a
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
53491688cf622ca317b3ff56156e601c2bdfffc94e4fe471ca82d5ba1d9e875f
f50ae00ce9ff572e6bd5e2788602ba356383526ab7289622a32fbf52926c6df0

View File

@ -4128,6 +4128,7 @@ static void setDeviceCharacteristics(unixFile *pFd){
if( pFd->ctrlFlags & UNIXFILE_PSOW ){
pFd->deviceCharacteristics |= SQLITE_IOCAP_POWERSAFE_OVERWRITE;
}
pFd->deviceCharacteristics |= SQLITE_IOCAP_BYPASS;
pFd->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;
}

View File

@ -3660,7 +3660,7 @@ static int winSectorSize(sqlite3_file *id){
*/
static int winDeviceCharacteristics(sqlite3_file *id){
winFile *p = (winFile*)id;
return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |
return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN | SQLITE_IOCAP_BYPASS |
((p->ctrlFlags & WINFILE_PSOW)?SQLITE_IOCAP_POWERSAFE_OVERWRITE:0);
}

View File

@ -808,18 +808,26 @@ static const unsigned char aJournalMagic[] = {
** Return true if page pgno can be read directly from the database file
** by the b-tree layer. This is the case if:
**
** * the database file is open,
** * there are no dirty pages in the cache, and
** * the desired page is not currently in the wal file.
** (1) the database file is open
** (2) the VFS for the database has BYPASS capability
** (3) there are no dirty pages in the cache, and
** (4) the desired page is not currently in the wal file.
*/
int sqlite3PagerDirectReadOk(Pager *pPager, Pgno pgno){
if( pPager->fd->pMethods==0 ) return 0;
if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0;
assert( pPager!=0 );
assert( pPager->fd!=0 );
if( pPager->fd->pMethods==0 ) return 0; /* Case (1) */
assert( pPager->fd->pMethods->xDeviceCharacteristics!=0 );
if( (pPager->fd->pMethods->xDeviceCharacteristics(pPager->fd)
& SQLITE_IOCAP_BYPASS)==0 ){
return 0; /* Case (2) */
}
if( sqlite3PCacheIsDirty(pPager->pPCache) ) return 0; /* Failed (3) */
#ifndef SQLITE_OMIT_WAL
if( pPager->pWal ){
u32 iRead = 0;
(void)sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
return iRead==0;
return iRead==0; /* Condition (4) */
}
#endif
return 1;

View File

@ -652,6 +652,11 @@ int sqlite3_exec(
** filesystem supports doing multiple write operations atomically when those
** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and
** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].
**
** The SQLITE_IOCAP_BYPASS property means that it is ok for the
** B-tree layer to bypass the pager and VFS and read content directly
** from the filesystem (the SQLITE_DIRECT_OVERFLOW_READ optimization)
** when that is beneficial for performance.
*/
#define SQLITE_IOCAP_ATOMIC 0x00000001
#define SQLITE_IOCAP_ATOMIC512 0x00000002
@ -668,6 +673,7 @@ int sqlite3_exec(
#define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
#define SQLITE_IOCAP_IMMUTABLE 0x00002000
#define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000
#define SQLITE_IOCAP_BYPASS 0x00008000
/*
** CAPI3REF: File Locking Levels
@ -814,6 +820,7 @@ struct sqlite3_file {
** <li> [SQLITE_IOCAP_POWERSAFE_OVERWRITE]
** <li> [SQLITE_IOCAP_IMMUTABLE]
** <li> [SQLITE_IOCAP_BATCH_ATOMIC]
** <li> [SQLITE_IOCAP_BYPASS]
** </ul>
**
** The SQLITE_IOCAP_ATOMIC property means that all writes of