-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.
-D 2011-09-03T17:07:26.674
+C Improve\sthe\stestability\sof\sthe\smerge-sort\slogic.
+D 2011-09-04T01:11:46.977
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in d314143fa6be24828021d3f583ad37d9afdce505
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
F src/resolve.c 36368f44569208fa074e61f4dd0b6c4fb60ca2b4
F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
-F src/select.c 32d0f4e5513362706b8973e7f1b87cd0885dfbf5
+F src/select.c bf7b7ea6befb483619da5f597b0864668b828c3c
F src/shell.c bbe7818ff5bc8614105ceb81ad67b8bdc0b671dd
F src/sqlite.h.in 0a6c9c23337fd1352c5c75a613ff9533aa7d91cb
F src/sqlite3ext.h 1a1a4f784aa9c3b00edd287940197de52487cd93
F src/vdbeaux.c e58acbc5ea3823922a0cd8fa21f94f39af51ee88
F src/vdbeblob.c f024f0bf420f36b070143c32b15cc7287341ffd3
F src/vdbemem.c 5e6effb96dd53d233361cbfaa3f0a43b9af689e9
-F src/vdbesort.c e6d6f0c2aa003f7cbdea8c9be47a15a8e854fb97
+F src/vdbesort.c 4ceadaa20c2a428ea2a5066f6d7d91d7a8118077
F src/vdbetrace.c 5d0dc3d5fd54878cc8d6d28eb41deb8d5885b114
F src/vtab.c 901791a47318c0562cd0c676a2c6ff1bc530e582
F src/wal.c 3154756177d6219e233d84291d5b05f4e06ff5e9
F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2
-P 61bda876af6df3170263d41d2933168305de58d2 99e34bdce4ccca15b79159b03b96787e7a7ff85b
-R da1f20303c5b87a4ef556300a531567d
+P 4c43e8b2d2c1d8dcba3cd1c3f2ec4e19ab419430
+R 983c9c689f2d53c2e02840decc5ec993
U drh
-Z 01e7a916345d0e3901e7a472c5d2f441
+Z ae9009821df61dee832eb776e8a5bada
-4c43e8b2d2c1d8dcba3cd1c3f2ec4e19ab419430
\ No newline at end of file
+b5179baf87aa00ed5cecbdcaa65bee10e112a9e9
\ No newline at end of file
regRowid = sqlite3GetTempReg(pParse);
}
if( p->selFlags & SF_UseSorter ){
- int regSortOut = sqlite3GetTempReg(pParse);
+ int regSortOut = ++pParse->nMem;
int ptab2 = pParse->nTab++;
sqlite3VdbeAddOp3(v, OP_OpenPseudo, ptab2, regSortOut, pOrderBy->nExpr+2);
addr = 1 + sqlite3VdbeAddOp2(v, OP_SorterSort, iTab, addrBreak);
){
u8 aVarint[9]; /* Buffer large enough for a varint */
i64 iOff = *piOffset; /* Offset in file to read from */
- int nRead = 9; /* Number of bytes to read from file */
int rc; /* Return code */
assert( iEof>iOff );
- if( (iEof-iOff)<nRead ){
- nRead = iEof-iOff;
- }
-
- rc = sqlite3OsRead(pFile, aVarint, nRead, iOff);
+ rc = sqlite3OsRead(pFile, aVarint, 9, iOff);
if( rc==SQLITE_OK ){
*piOffset += getVarint(aVarint, (u64 *)piVal);
}
/* This call cannot fail. As the memory is already allocated. */
r2 = sqlite3VdbeRecordUnpack(pKeyInfo, nKey2, pKey2, aSpace, nSpace);
assert( r2 && (r2->flags & UNPACKED_NEED_FREE)==0 );
- assert( r2==aSpace );
+ assert( r2==(UnpackedRecord*)aSpace );
}else{
r2 = (UnpackedRecord *)aSpace;
assert( !bOmitRowid );
iRes = i1;
}else{
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
);
- 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 ){
iRes = i1;
}else{
i64 iOff = pSorter->iWriteOff;
SorterRecord *p;
SorterRecord *pNext = 0;
+ static const char eightZeros[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
pSorter->nPMA++;
rc = vdbeSorterWriteVarint(pSorter->pTemp1, pSorter->nInMemory, &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;
}