diff --git a/manifest b/manifest index 6c9743bfa6..dd25184f0e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\sbuild\sworks\sagain\swith\s-DSQLITE_OMIT_MERGE_SORT.\s\sThe\smerge-sorter\snow\navoids\sspilling\sto\sdisk\s(letting\sthe\sin-memory\slinked\slist\sgrow\swithout\nbound)\sif\sPRAGMA\stemp_store=3. -D 2011-09-03T00:17:51.023 +C Reduce\sthe\snumber\sof\sVdbeRecordUnpack()\scalls\smade\sin\svdbesort.c. +D 2011-09-03T14:36:13.912 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d314143fa6be24828021d3f583ad37d9afdce505 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -245,7 +245,7 @@ F src/vdbeapi.c 11dc47987abacb76ad016dcf5abc0dc422482a98 F src/vdbeaux.c e58acbc5ea3823922a0cd8fa21f94f39af51ee88 F src/vdbeblob.c f024f0bf420f36b070143c32b15cc7287341ffd3 F src/vdbemem.c 5e6effb96dd53d233361cbfaa3f0a43b9af689e9 -F src/vdbesort.c aa7ad2ef91ad7d33eb614d3fb1c4cbd068b321ad +F src/vdbesort.c 5e38e7e1f5f6900b1b8bea49decd23c69221aed9 F src/vdbetrace.c 5d0dc3d5fd54878cc8d6d28eb41deb8d5885b114 F src/vtab.c 901791a47318c0562cd0c676a2c6ff1bc530e582 F src/wal.c 3154756177d6219e233d84291d5b05f4e06ff5e9 @@ -961,7 +961,7 @@ F tool/symbols.sh caaf6ccc7300fd43353318b44524853e222557d5 F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings.sh b7fdb2cc525f5ef4fa43c80e771636dd3690f9d2 -P a9a64592cf88580cb254fb0aac65a2f2085976ec -R 4edd7e2341e47b4ce23f768c53615b8c -U drh -Z cbdc1caefa14410ba02a8248a6138d65 +P 68e26c4487696d194ee85370380e4b0e56d206ee +R f6e37dce79fea0b74c498631cfb45ff1 +U dan +Z cc6b7d2a23c219696518afb4690c5277 diff --git a/manifest.uuid b/manifest.uuid index 2bc60c00a6..af74b9885a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -68e26c4487696d194ee85370380e4b0e56d206ee \ No newline at end of file +666c2c3cff51dac2ba5689b75705d99c3705673b \ No newline at end of file diff --git a/src/vdbesort.c b/src/vdbesort.c index e8135f0f14..9e169c3e36 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -303,6 +303,9 @@ static int vdbeSorterIterInit( ** field. For the purposes of the comparison, ignore it. Also, if bOmitRowid ** is true and key1 contains even a single NULL value, it is considered to ** be less than key2. Even if key2 also contains NULL values. +** +** If pKey2 is passed a NULL pointer, then it is assumed that the pCsr->aSpace +** has been allocated and contains an unpacked record that is used as key2. */ static int vdbeSorterCompare( VdbeCursor *pCsr, /* Cursor object (for pKeyInfo) */ @@ -326,15 +329,20 @@ static int vdbeSorterCompare( pSorter->nSpace = nSpace; } - /* 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 ); + if( pKey2 ){ + /* 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 ); + }else{ + r2 = (UnpackedRecord *)aSpace; + assert( !bOmitRowid ); + } if( bOmitRowid ){ for(i=0; inField-1; i++){ if( r2->aMem[i].flags & MEM_Null ){ *pRes = -1; - sqlite3VdbeDeleteUnpackedRecord(r2); return SQLITE_OK; } } @@ -344,7 +352,6 @@ static int vdbeSorterCompare( } *pRes = sqlite3VdbeRecordCompare(nKey1, pKey1, r2); - /* sqlite3VdbeDeleteUnpackedRecord(r2); */ return SQLITE_OK; } @@ -483,6 +490,7 @@ static int vdbeSorterMerge( int rc = SQLITE_OK; SorterRecord *pFinal = 0; SorterRecord **pp = &pFinal; + int bKey2InSpace = 0; /* True if pCsr->aSpace contains key2 */ while( p1 || p2 ){ if( p1==0 ){ @@ -493,8 +501,8 @@ static int vdbeSorterMerge( p1 = 0; }else{ int res; - rc = vdbeSorterCompare( - pCsr, 0, p1->pVal, p1->nVal, p2->pVal, p2->nVal, &res + rc = vdbeSorterCompare(pCsr, 0, + p1->pVal, p1->nVal, (bKey2InSpace ? 0 : p2->pVal), p2->nVal, &res ); if( rc!=SQLITE_OK ){ vdbeSorterRecordFree(db, p1); @@ -507,10 +515,12 @@ static int vdbeSorterMerge( *pp = p1; pp = &p1->pNext; p1 = p1->pNext; + bKey2InSpace = 1; }else{ *pp = p2; pp = &p2->pNext; p2 = p2->pNext; + bKey2InSpace = 0; } *pp = 0; }