mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-14 00:22:38 +03:00
Improve the testability of the merge-sort logic.
FossilOrigin-Name: b5179baf87aa00ed5cecbdcaa65bee10e112a9e9
This commit is contained in:
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Performance\simprovements\sto\sthe\sexternal\smerge-sorter.\s\sKeep\scontent\son\san\nin-memory\slinked\slists\srather\sthan\san\sephemeral\stable\sprior\sto\sspilling\sto\ndisk.\s\sUse\sthe\sexternal\smerge-sorter\sto\simplement\sORDER\sBY\sand\sGROUP\sBY\nin\saddition\sto\sCREATE\sINDEX.
|
C Improve\sthe\stestability\sof\sthe\smerge-sort\slogic.
|
||||||
D 2011-09-03T17:07:26.674
|
D 2011-09-04T01:11:46.977
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in d314143fa6be24828021d3f583ad37d9afdce505
|
F Makefile.in d314143fa6be24828021d3f583ad37d9afdce505
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -179,7 +179,7 @@ F src/printf.c 585a36b6a963df832cfb69505afa3a34ed5ef8a1
|
|||||||
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
|
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
|
||||||
F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4
|
F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4
|
||||||
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
|
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
|
||||||
F src/select.c 32d0f4e5513362706b8973e7f1b87cd0885dfbf5
|
F src/select.c bf7b7ea6befb483619da5f597b0864668b828c3c
|
||||||
F src/shell.c bbe7818ff5bc8614105ceb81ad67b8bdc0b671dd
|
F src/shell.c bbe7818ff5bc8614105ceb81ad67b8bdc0b671dd
|
||||||
F src/sqlite.h.in 0a6c9c23337fd1352c5c75a613ff9533aa7d91cb
|
F src/sqlite.h.in 0a6c9c23337fd1352c5c75a613ff9533aa7d91cb
|
||||||
F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93
|
F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93
|
||||||
@@ -245,7 +245,7 @@ F src/vdbeapi.c 11dc47987abacb76ad016dcf5abc0dc422482a98
|
|||||||
F src/vdbeaux.c e58acbc5ea3823922a0cd8fa21f94f39af51ee88
|
F src/vdbeaux.c e58acbc5ea3823922a0cd8fa21f94f39af51ee88
|
||||||
F src/vdbeblob.c f024f0bf420f36b070143c32b15cc7287341ffd3
|
F src/vdbeblob.c f024f0bf420f36b070143c32b15cc7287341ffd3
|
||||||
F src/vdbemem.c 5e6effb96dd53d233361cbfaa3f0a43b9af689e9
|
F src/vdbemem.c 5e6effb96dd53d233361cbfaa3f0a43b9af689e9
|
||||||
F src/vdbesort.c e6d6f0c2aa003f7cbdea8c9be47a15a8e854fb97
|
F src/vdbesort.c 4ceadaa20c2a428ea2a5066f6d7d91d7a8118077
|
||||||
F src/vdbetrace.c 5d0dc3d5fd54878cc8d6d28eb41deb8d5885b114
|
F src/vdbetrace.c 5d0dc3d5fd54878cc8d6d28eb41deb8d5885b114
|
||||||
F src/vtab.c 901791a47318c0562cd0c676a2c6ff1bc530e582
|
F src/vtab.c 901791a47318c0562cd0c676a2c6ff1bc530e582
|
||||||
F src/wal.c 3154756177d6219e233d84291d5b05f4e06ff5e9
|
F src/wal.c 3154756177d6219e233d84291d5b05f4e06ff5e9
|
||||||
@@ -961,7 +961,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5
|
|||||||
F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
|
F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
|
||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2
|
F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2
|
||||||
P 61bda876af6df3170263d41d2933168305de58d2 99e34bdce4ccca15b79159b03b96787e7a7ff85b
|
P 4c43e8b2d2c1d8dcba3cd1c3f2ec4e19ab419430
|
||||||
R da1f20303c5b87a4ef556300a531567d
|
R 983c9c689f2d53c2e02840decc5ec993
|
||||||
U drh
|
U drh
|
||||||
Z 01e7a916345d0e3901e7a472c5d2f441
|
Z ae9009821df61dee832eb776e8a5bada
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
4c43e8b2d2c1d8dcba3cd1c3f2ec4e19ab419430
|
b5179baf87aa00ed5cecbdcaa65bee10e112a9e9
|
||||||
@@ -900,7 +900,7 @@ static void generateSortTail(
|
|||||||
regRowid = sqlite3GetTempReg(pParse);
|
regRowid = sqlite3GetTempReg(pParse);
|
||||||
}
|
}
|
||||||
if( p->selFlags & SF_UseSorter ){
|
if( p->selFlags & SF_UseSorter ){
|
||||||
int regSortOut = sqlite3GetTempReg(pParse);
|
int regSortOut = ++pParse->nMem;
|
||||||
int ptab2 = pParse->nTab++;
|
int ptab2 = pParse->nTab++;
|
||||||
sqlite3VdbeAddOp3(v, OP_OpenPseudo, ptab2, regSortOut, pOrderBy->nExpr+2);
|
sqlite3VdbeAddOp3(v, OP_OpenPseudo, ptab2, regSortOut, pOrderBy->nExpr+2);
|
||||||
addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak);
|
addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak);
|
||||||
|
|||||||
@@ -239,15 +239,10 @@ static int vdbeSorterReadVarint(
|
|||||||
){
|
){
|
||||||
u8 aVarint[9]; /* Buffer large enough for a varint */
|
u8 aVarint[9]; /* Buffer large enough for a varint */
|
||||||
i64 iOff = *piOffset; /* Offset in file to read from */
|
i64 iOff = *piOffset; /* Offset in file to read from */
|
||||||
int nRead = 9; /* Number of bytes to read from file */
|
|
||||||
int rc; /* Return code */
|
int rc; /* Return code */
|
||||||
|
|
||||||
assert( iEof>iOff );
|
assert( iEof>iOff );
|
||||||
if( (iEof-iOff)<nRead ){
|
rc = sqlite3OsRead(pFile, aVarint, 9, iOff);
|
||||||
nRead = iEof-iOff;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = sqlite3OsRead(pFile, aVarint, nRead, iOff);
|
|
||||||
if( rc==SQLITE_OK ){
|
if( rc==SQLITE_OK ){
|
||||||
*piOffset += getVarint(aVarint, (u64 *)piVal);
|
*piOffset += getVarint(aVarint, (u64 *)piVal);
|
||||||
}
|
}
|
||||||
@@ -333,7 +328,7 @@ static int vdbeSorterCompare(
|
|||||||
/* This call cannot fail. As the memory is already allocated. */
|
/* This call cannot fail. As the memory is already allocated. */
|
||||||
r2 = sqlite3VdbeRecordUnpack(pKeyInfo, nKey2, pKey2, aSpace, nSpace);
|
r2 = sqlite3VdbeRecordUnpack(pKeyInfo, nKey2, pKey2, aSpace, nSpace);
|
||||||
assert( r2 && (r2->flags & UNPACKED_NEED_FREE)==0 );
|
assert( r2 && (r2->flags & UNPACKED_NEED_FREE)==0 );
|
||||||
assert( r2==aSpace );
|
assert( r2==(UnpackedRecord*)aSpace );
|
||||||
}else{
|
}else{
|
||||||
r2 = (UnpackedRecord *)aSpace;
|
r2 = (UnpackedRecord *)aSpace;
|
||||||
assert( !bOmitRowid );
|
assert( !bOmitRowid );
|
||||||
@@ -387,10 +382,15 @@ static int vdbeSorterDoCompare(VdbeCursor *pCsr, int iOut){
|
|||||||
iRes = i1;
|
iRes = i1;
|
||||||
}else{
|
}else{
|
||||||
int res;
|
int res;
|
||||||
int rc = vdbeSorterCompare(
|
int rc;
|
||||||
|
assert( pCsr->pSorter->aSpace!=0 ); /* allocated in vdbeSorterMerge() */
|
||||||
|
rc = vdbeSorterCompare(
|
||||||
pCsr, 0, p1->aKey, p1->nKey, p2->aKey, p2->nKey, &res
|
pCsr, 0, p1->aKey, p1->nKey, p2->aKey, p2->nKey, &res
|
||||||
);
|
);
|
||||||
if( rc!=SQLITE_OK ) return rc;
|
/* The vdbeSorterCompare() call cannot fail since pCsr->pSorter->aSpace
|
||||||
|
** has already been allocated. */
|
||||||
|
assert( rc==SQLITE_OK );
|
||||||
|
|
||||||
if( res<=0 ){
|
if( res<=0 ){
|
||||||
iRes = i1;
|
iRes = i1;
|
||||||
}else{
|
}else{
|
||||||
@@ -606,6 +606,7 @@ static int vdbeSorterListToPMA(sqlite3 *db, VdbeCursor *pCsr){
|
|||||||
i64 iOff = pSorter->iWriteOff;
|
i64 iOff = pSorter->iWriteOff;
|
||||||
SorterRecord *p;
|
SorterRecord *p;
|
||||||
SorterRecord *pNext = 0;
|
SorterRecord *pNext = 0;
|
||||||
|
static const char eightZeros[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
pSorter->nPMA++;
|
pSorter->nPMA++;
|
||||||
rc = vdbeSorterWriteVarint(pSorter->pTemp1, pSorter->nInMemory, &iOff);
|
rc = vdbeSorterWriteVarint(pSorter->pTemp1, pSorter->nInMemory, &iOff);
|
||||||
@@ -629,6 +630,11 @@ static int vdbeSorterListToPMA(sqlite3 *db, VdbeCursor *pCsr){
|
|||||||
));
|
));
|
||||||
|
|
||||||
pSorter->iWriteOff = iOff;
|
pSorter->iWriteOff = iOff;
|
||||||
|
if( rc==SQLITE_OK ){
|
||||||
|
/* Terminate each file with 8 extra bytes so that from any offset
|
||||||
|
** in the file we can always read 9 bytes without a SHORT_READ error */
|
||||||
|
rc = sqlite3OsWrite(pSorter->pTemp1, eightZeros, 8, iOff);
|
||||||
|
}
|
||||||
pSorter->pRecord = p;
|
pSorter->pRecord = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user