From bf09093f6459e89eb03bb1bf15aa93e5c83f9d04 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 8 Aug 2011 19:26:13 +0000 Subject: [PATCH] Remove redundant parameter from vdbeSorterInitMerge() in vdbesort.c. FossilOrigin-Name: eec8c0df075d3a54ad71a2854b170f3ed307d068 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbesort.c | 50 +++++++++++++++++++++++++++++++++----------------- 3 files changed, 40 insertions(+), 24 deletions(-) diff --git a/manifest b/manifest index 7c553cd034..19ef397817 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sfault-injection\sand\sother\stests\s(and\sfixes)\sto\simprove\scoverage\sof\svdbesort.c. -D 2011-08-08T16:44:25.654 +C Remove\sredundant\sparameter\sfrom\svdbeSorterInitMerge()\sin\svdbesort.c. +D 2011-08-08T19:26:13.264 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c1d7a7f4fd8da6b1815032efca950e3d5125407e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -245,7 +245,7 @@ F src/vdbeapi.c 11dc47987abacb76ad016dcf5abc0dc422482a98 F src/vdbeaux.c 8fb978eb73a97b34d352dd3ef3bff35b1b3fa7e9 F src/vdbeblob.c f024f0bf420f36b070143c32b15cc7287341ffd3 F src/vdbemem.c 0498796b6ffbe45e32960d6a1f5adfb6e419883b -F src/vdbesort.c e9a7d969bd5a85fc7b9f42865a71b834d26442be +F src/vdbesort.c 6498ab415733d0c534d86b86238e8263e19105fe F src/vdbetrace.c 5d0dc3d5fd54878cc8d6d28eb41deb8d5885b114 F src/vtab.c 901791a47318c0562cd0c676a2c6ff1bc530e582 F src/wal.c 0c70ad7b1cac6005fa5e2cbefd23ee05e391c290 @@ -955,7 +955,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk 11760e1b94a5d3dcd42378f3cc18544c06cfa576 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh 2ebae31e1eb352696f3c2f7706a34c084b28c262 -P 038ec9ea92f7661358580d999adc400da14d47f0 -R bca0e64155bd4edc59b1ae2d567af815 +P 0e6defa6aa540b413ea3f4bb6dcd86364d547067 +R a42b0b764e1daab6a572493624ec8887 U dan -Z 7ff7f4144c189044a56c845ca9d84e7e +Z bf599f79a5376801fe18942866ce9ad0 diff --git a/manifest.uuid b/manifest.uuid index 365d6d9407..0da63a4489 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0e6defa6aa540b413ea3f4bb6dcd86364d547067 \ No newline at end of file +eec8c0df075d3a54ad71a2854b170f3ed307d068 \ No newline at end of file diff --git a/src/vdbesort.c b/src/vdbesort.c index 369b4d9f55..e7cb3aae0f 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -174,6 +174,14 @@ static int vdbeSorterIterNext( return rc; } +/* +** Write a single varint, value iVal, to file-descriptor pFile. Return +** SQLITE_OK if successful, or an SQLite error code if some error occurs. +** +** The value of *piOffset when this function is called is used as the byte +** offset in file pFile to write to. Before returning, *piOffset is +** incremented by the number of bytes written. +*/ static int vdbeSorterWriteVarint( sqlite3_file *pFile, i64 iVal, @@ -190,6 +198,17 @@ static int vdbeSorterWriteVarint( return rc; } +/* +** Read a single varint from file-descriptor pFile. Return SQLITE_OK if +** successful, or an SQLite error code if some error occurs. +** +** The value of *piOffset when this function is called is used as the +** byte offset in file pFile from whence to read the varint. If successful +** (i.e. if no IO error occurs), then *piOffset is set to the offset of +** the first byte past the end of the varint before returning. *piVal is +** set to the integer value read. If an error occurs, the final values of +** both *piOffset and *piVal are undefined. +*/ static int vdbeSorterReadVarint( sqlite3_file *pFile, i64 iEof, /* Total number of bytes in file */ @@ -487,31 +506,28 @@ int sqlite3VdbeSorterWrite(sqlite3 *db, VdbeCursor *pCsr, int nKey){ } /* -** Helper function for sqlite3VdbeSorterRewind(). +** Helper function for sqlite3VdbeSorterRewind(). */ static int vdbeSorterInitMerge( - sqlite3 *db, - VdbeCursor *pCsr, - int iFirst, + sqlite3 *db, /* Database handle */ + VdbeCursor *pCsr, /* Cursor handle for this sorter */ i64 *pnByte /* Sum of bytes in all opened PMAs */ ){ VdbeSorter *pSorter = pCsr->pSorter; - int rc = SQLITE_OK; - int i; - i64 nByte = 0; - - /* Initialize as many iterators as possible. */ - for(i=iFirst; - rc==SQLITE_OK && inPMA && (i-iFirst)aIter[i - iFirst]; + int rc = SQLITE_OK; /* Return code */ + int i; /* Used to iterator through aIter[] */ + i64 nByte = 0; /* Total bytes in all opened PMAs */ + + /* Initialize the iterators. */ + for(i=0; rc==SQLITE_OK && iaIter[i]; rc = vdbeSorterIterInit(db, pSorter, pSorter->iReadOff, pIter, &nByte); pSorter->iReadOff = pIter->iEof; + assert( pSorter->iReadOff<=pSorter->iWriteOff ); + if( pSorter->iReadOff>=pSorter->iWriteOff ) break; } - assert( i>iFirst ); - /* Populate the aTree[] array. */ + /* Initialize the aTree[] array. */ for(i=pSorter->nTree-1; rc==SQLITE_OK && i>0; i--){ rc = vdbeSorterDoCompare(pCsr, i); } @@ -573,7 +589,7 @@ int sqlite3VdbeSorterRewind(sqlite3 *db, VdbeCursor *pCsr, int *pbEof){ ** initialize interators for SORTER_MAX_MERGE_COUNT of them. These PMAs ** are merged into a single PMA that is written to file pTemp2. */ - rc = vdbeSorterInitMerge(db, pCsr, iNew*SORTER_MAX_MERGE_COUNT, &nWrite); + rc = vdbeSorterInitMerge(db, pCsr, &nWrite); assert( rc!=SQLITE_OK || pSorter->aIter[ pSorter->aTree[1] ].pFile ); if( rc!=SQLITE_OK || pSorter->nPMA<=SORTER_MAX_MERGE_COUNT ){ break; -- 2.47.2