From 756440febc24d57d6d85e343b969678c234b03bb Mon Sep 17 00:00:00 2001 From: drh <> Date: Fri, 16 Sep 2022 15:19:04 +0000 Subject: [PATCH] Corrections to the xRead method for databases in the os_kv.c VFS so that it correctly reads the header, and thus avoids unnecessary cache flushes. This changes also includes an optimization to the header read logic. FossilOrigin-Name: ef54961ce69fddb4cfeeff0860288de2858a6f7a5aa396691e8e99933eb9af54 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_kv.c | 8 +++++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 57b3e2ecad..62feced741 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sos_kv.c\sso\sthat\sit\suses\sSQLITE_FCNTL_SYNC\sand\shence\nworks\seven\swith\sPRAGMA\ssynchronous=OFF. -D 2022-09-16T11:37:01.212 +C Corrections\sto\sthe\sxRead\smethod\sfor\sdatabases\sin\sthe\sos_kv.c\sVFS\sso\sthat\sit\ncorrectly\sreads\sthe\sheader,\sand\sthus\savoids\sunnecessary\scache\sflushes.\s\sThis\nchanges\salso\sincludes\san\soptimization\sto\sthe\sheader\sread\slogic. +D 2022-09-16T15:19:04.113 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -574,7 +574,7 @@ F src/notify.c 89a97dc854c3aa62ad5f384ef50c5a4a11d70fcc69f86de3e991573421130ed6 F src/os.c 0eb831ba3575af5277e47f4edd14fdfc90025c67eb25ce5cda634518d308d4e9 F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 -F src/os_kv.c 554a2c109f8810b743af2eed4ba732d18dfdbc4d073e3a9bd8b8e828215a9692 +F src/os_kv.c 3a2d319988df9da8f3a4d0c753a1492542bd3017ff7ae5d07814460eac6b0b19 F src/os_setup.h 0711dbc4678f3ac52d7fe736951b6384a0615387c4ba5135a4764e4e31f4b6a6 F src/os_unix.c 0fa91925f0b8831fc0156a9c04d39d86f85baf9eef66c98712395e1715cb75cc F src/os_win.c e9454cb141908e8eef2102180bad353a36480612d5b736e4c2bd5777d9b25a34 @@ -2004,8 +2004,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P e334449912d5176e355d02024a07ed867741f71c9d10ce6744ca800414bf3eeb -R a55522768af3f3b5d07199ad1dd4c789 +P 21915af560b111aeeaee751790356151a5f063c2fc703dd4b35b22dc393409fb +R 64099072882bb903603d527810cdf234 U drh -Z d50c7a05ab573e361ead585b4e643b32 +Z 33c23cb0033c7cdf863f626ff2ea91a9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index c9139459b8..54e92cfb4b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -21915af560b111aeeaee751790356151a5f063c2fc703dd4b35b22dc393409fb \ No newline at end of file +ef54961ce69fddb4cfeeff0860288de2858a6f7a5aa396691e8e99933eb9af54 \ No newline at end of file diff --git a/src/os_kv.c b/src/os_kv.c index b99f5574c7..db95a305b7 100644 --- a/src/os_kv.c +++ b/src/os_kv.c @@ -700,7 +700,7 @@ static int kvvfsReadDb( unsigned int pgno; int got, n; char zKey[30]; - char aData[131073]; + char aData[133073]; assert( iOfst>=0 ); assert( iAmt>=0 ); SQLITE_KV_LOG(("xRead('%s-db',%d,%lld)\n", pFile->zClass, iAmt, iOfst)); @@ -723,9 +723,11 @@ static int kvvfsReadDb( }else{ aData[got] = 0; if( iOfst+iAmt<512 ){ - n = kvvfsDecode(aData, &aData[1000], 1000); + int k = iOfst+iAmt; + aData[k*2] = 0; + n = kvvfsDecode(aData, &aData[2000], sizeof(aData)-2000); if( n>=iOfst+iAmt ){ - memcpy(zBuf, &aData[1000+iOfst], iAmt); + memcpy(zBuf, &aData[2000+iOfst], iAmt); n = iAmt; }else{ n = 0;