From 2626b22230060a8f338002ca1e49b8bd9bfdc432 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 8 Oct 2019 19:45:17 +0000 Subject: [PATCH] Store 64-bit offset values in osinst log files. FossilOrigin-Name: 74d975c69abf1b8b8699e4f6539a4e411913196c90061e2c1246d25c16693ae0 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/test_osinst.c | 45 +++++++++++++++++++++++++++++++-------------- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 986f6bb5b9..9dc66ae309 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sattempting\sto\sread\s0\sbytes\sfrom\sa\sfile\sin\sthe\sosinst\svtab\scode. -D 2019-10-07T10:29:18.641 +C Store\s64-bit\soffset\svalues\sin\sosinst\slog\sfiles. +D 2019-10-08T19:45:17.191 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -568,7 +568,7 @@ F src/test_multiplex.c e054459f7633f3ff8ce1245da724f9a8be189e4e F src/test_multiplex.h 5436d03f2d0501d04f3ed50a75819e190495b635 F src/test_mutex.c 7f4337ba23ee6b1d2ec81c189653608cb069926a F src/test_onefile.c f31e52e891c5fef6709b9fcef54ce660648a34172423a9cbdf4cbce3ba0049f4 -F src/test_osinst.c 446494a025eb5ece24de6a9a1b97b1e390c27d59ccf42d1e5cddd61c16f811c4 +F src/test_osinst.c 0a58f8a4b03274c84c97a1060dd702004f8f2f6d9af2dba9b4daa93786bf697a F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00 F src/test_quota.c 6cb9297115b551f433a9ad1741817a9831abed99 F src/test_quota.h 2a8ad1952d1d2ca9af0ce0465e56e6c023b5e15d @@ -1847,7 +1847,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P ed3499a1a5c0f860b940af0edc6a6184d834001a68d59b36b0e1b21d2e6579ca -R 167c91f002f8b3259c9adc1d3ec59b39 +P 1fb76c3e7d904cd2754270997d3d0c86237b0a630d6b1417578a8191e6e1687f +R 3cd7734ca3a0cffa4c22dd2b9933bced U dan -Z 798e91aaa2dcc84e3d48ac174ec14d84 +Z 83be8f87e7b61aedcd3403b05fb69071 diff --git a/manifest.uuid b/manifest.uuid index 4ee4f3bbe9..15f5f822eb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1fb76c3e7d904cd2754270997d3d0c86237b0a630d6b1417578a8191e6e1687f \ No newline at end of file +74d975c69abf1b8b8699e4f6539a4e411913196c90061e2c1246d25c16693ae0 \ No newline at end of file diff --git a/src/test_osinst.c b/src/test_osinst.c index 91e1036916..6044445e5e 100644 --- a/src/test_osinst.c +++ b/src/test_osinst.c @@ -249,7 +249,7 @@ static sqlite3_uint64 vfslog_time(){ #endif static void vfslog_call( -sqlite3_vfs *, int, int, sqlite3_uint64, sqlite3_int64, int, int, int); +sqlite3_vfs *, int, int, sqlite3_uint64, sqlite3_int64, int, int, sqlite_int64); static void vfslog_string(sqlite3_vfs *, const char *); /* @@ -284,7 +284,7 @@ static int vfslogRead( t = vfslog_time(); rc = p->pReal->pMethods->xRead(p->pReal, zBuf, iAmt, iOfst); t2 = vfslog_time() - t; - vfslog_call(p->pVfslog, OS_READ, p->iFileId, t, t2, rc, iAmt, (int)iOfst); + vfslog_call(p->pVfslog, OS_READ, p->iFileId, t, t2, rc, iAmt, iOfst); return rc; } @@ -303,7 +303,7 @@ static int vfslogWrite( t = vfslog_time(); rc = p->pReal->pMethods->xWrite(p->pReal, z, iAmt, iOfst); t2 = vfslog_time() - t; - vfslog_call(p->pVfslog, OS_WRITE, p->iFileId, t, t2, rc, iAmt, (int)iOfst); + vfslog_call(p->pVfslog, OS_WRITE, p->iFileId, t, t2, rc, iAmt, iOfst); return rc; } @@ -317,7 +317,7 @@ static int vfslogTruncate(sqlite3_file *pFile, sqlite_int64 size){ t = vfslog_time(); rc = p->pReal->pMethods->xTruncate(p->pReal, size); t2 = vfslog_time() - t; - vfslog_call(p->pVfslog, OS_TRUNCATE, p->iFileId, t, t2, rc, 0, (int)size); + vfslog_call(p->pVfslog, OS_TRUNCATE, p->iFileId, t, t2, rc, 0, size); return rc; } @@ -345,7 +345,7 @@ static int vfslogFileSize(sqlite3_file *pFile, sqlite_int64 *pSize){ t = vfslog_time(); rc = p->pReal->pMethods->xFileSize(p->pReal, pSize); t2 = vfslog_time() - t; - vfslog_call(p->pVfslog, OS_FILESIZE, p->iFileId, t, t2, rc, 0, (int)*pSize); + vfslog_call(p->pVfslog, OS_FILESIZE, p->iFileId, t, t2, rc, 0, *pSize); return rc; } @@ -537,7 +537,7 @@ static int vfslogAccess( t = vfslog_time(); rc = REALVFS(pVfs)->xAccess(REALVFS(pVfs), zPath, flags, pResOut); t2 = vfslog_time() - t; - vfslog_call(pVfs, OS_ACCESS, 0, t, t2, rc, flags, *pResOut); + vfslog_call(pVfs, OS_ACCESS, 0, t, t2, rc, flags, (sqlite3_int64)*pResOut); vfslog_string(pVfs, zPath); return rc; } @@ -651,6 +651,13 @@ static void vfslogPut32bits(unsigned char *p, unsigned int v){ p[3] = (unsigned char)v; } +static void vfslogPut64bits(unsigned char *p, sqlite3_int64 v){ + vfslogPut32bits(p, (v >> 32) & 0xFFFFFFFF); + vfslogPut32bits(&p[4], v & 0xFFFFFFFF); +} + +#define VFSLOG_RECORD_SIZE 36 + static void vfslog_call( sqlite3_vfs *pVfs, int eEvent, @@ -659,23 +666,23 @@ static void vfslog_call( sqlite3_int64 nClick, int return_code, int size, - int offset + sqlite3_int64 offset ){ VfslogVfs *p = (VfslogVfs *)pVfs; unsigned char *zRec; - if( (32+p->nBuf)>sizeof(p->aBuf) ){ + if( (VFSLOG_RECORD_SIZE+p->nBuf)>sizeof(p->aBuf) ){ vfslog_flush(p); } zRec = (unsigned char *)&p->aBuf[p->nBuf]; vfslogPut32bits(&zRec[0], eEvent); vfslogPut32bits(&zRec[4], iFileid); - vfslogPut32bits(&zRec[8], (unsigned int)((tStamp>>32)&0xffffffff)); - vfslogPut32bits(&zRec[12], (unsigned int)(tStamp&0xffffffff)); + vfslogPut64bits(&zRec[8], (sqlite3_int64)tStamp); vfslogPut32bits(&zRec[16], (unsigned int)(nClick&0xffffffff)); vfslogPut32bits(&zRec[20], return_code); vfslogPut32bits(&zRec[24], size); - vfslogPut32bits(&zRec[28], offset); - p->nBuf += 32; + vfslogPut64bits(&zRec[28], offset); + + p->nBuf += VFSLOG_RECORD_SIZE; } static void vfslog_string(sqlite3_vfs *pVfs, const char *zStr){ @@ -979,7 +986,7 @@ static int vlogNext(sqlite3_vtab_cursor *pCursor){ sqlite3_free(pCsr->zTransient); pCsr->zTransient = 0; - nRead = 32; + nRead = VFSLOG_RECORD_SIZE; if( pCsr->iOffset+nRead<=p->nByte ){ int eEvent; rc = p->pFd->pMethods->xRead(p->pFd, pCsr->aBuf, nRead, pCsr->iOffset); @@ -1067,7 +1074,17 @@ static int vlogColumn( case 2: { unsigned int v1 = get32bits(&pCsr->aBuf[8]); unsigned int v2 = get32bits(&pCsr->aBuf[12]); - sqlite3_result_int64(ctx,(((sqlite3_int64)v1) << 32) + (sqlite3_int64)v2); + sqlite3_result_int64( + ctx,(((sqlite3_int64)v1) << 32) + (sqlite3_int64)v2 + ); + break; + } + case 6: { + unsigned int v1 = get32bits(&pCsr->aBuf[28]); + unsigned int v2 = get32bits(&pCsr->aBuf[32]); + sqlite3_result_int64( + ctx,(((sqlite3_int64)v1) << 32) + (sqlite3_int64)v2 + ); break; } default: { -- 2.39.5