-C Merge\slatest\schanges\sfrom\sorderby-planning\sbranch.
-D 2014-03-28T19:18:16.969
+C Add\sthe\soptimization\sto\savoid\ssome\sunnecessary\scalls\sto\ssqlite3VdbeRecordUnpack()\sadded\sto\sthe\strunk\sby\s[707ea170b3].
+D 2014-03-29T06:27:35.162
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in ad0921c4b2780d01868cf69b419a4f102308d125
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/vdbeaux.c 1153175fb57a8454e1c8cf79b59b7bf92b26779d
F src/vdbeblob.c 15377abfb59251bccedd5a9c7d014a895f0c04aa
F src/vdbemem.c 6fc77594c60f6155404f3f8d71bf36d1fdeb4447
-F src/vdbesort.c 01068b89364fa2bffeba9b929367ed04661e97f7
+F src/vdbesort.c d7ef3c431d7996907815a13579952506bf2bdf8b
F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767
F src/vtab.c 21b932841e51ebd7d075e2d0ad1415dce8d2d5fd
F src/wal.c 76e7fc6de229bea8b30bb2539110f03a494dc3a8
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P 8cb2b02baa7ef9aa96319e977f0315328f944237 3047a25f1c41e83f0b4772f7c36fbfec0f12dc7e
-R 132477cf9a18d083088d044c20454723
+P 4c7fb5423430f3b936befaa7c309f8e1968ee7d8
+R c555f8c440b397229a1b1d80867cea18
U dan
-Z b189ca5a1e8d41a36f80415af9011f68
+Z 5b7820939497d4f0728d4d29380b4189
rc = vdbeSorterIterNext(&pMerger->aIter[iPrev]);
/* Update contents of aTree[] */
- for(i=(pMerger->nTree+iPrev)/2; rc==SQLITE_OK && i>0; i=i/2){
- rc = vdbeSorterDoCompare(pThread, pMerger, i);
+ if( rc==SQLITE_OK ){
+ int i; /* Index of aTree[] to recalculate */
+ VdbeSorterIter *pIter1; /* First iterator to compare */
+ VdbeSorterIter *pIter2; /* Second iterator to compare */
+ u8 *pKey2; /* To pIter2->aKey, or 0 if record cached */
+
+ /* Find the first two iterators to compare. The one that was just
+ ** advanced (iPrev) and the one next to it in the array. */
+ pIter1 = &pMerger->aIter[(iPrev & 0xFFFE)];
+ pIter2 = &pMerger->aIter[(iPrev | 0x0001)];
+ pKey2 = pIter2->aKey;
+
+ for(i=(pMerger->nTree+iPrev)/2; i>0; i=i/2){
+ /* Compare pIter1 and pIter2. Store the result in variable iRes. */
+ int iRes;
+ if( pIter1->pFile==0 ){
+ iRes = +1;
+ }else if( pIter2->pFile==0 ){
+ iRes = -1;
+ }else{
+ vdbeSorterCompare(pThread, 0,
+ pIter1->aKey, pIter1->nKey, pKey2, pIter2->nKey, &iRes
+ );
+ }
+
+ /* If pIter1 contained the smaller value, set aTree[i] to its index.
+ ** Then set pIter2 to the next iterator to compare to pIter1. In this
+ ** case there is no cache of pIter2 in pThread->pUnpacked, so set
+ ** pKey2 to point to the record belonging to pIter2.
+ **
+ ** Alternatively, if pIter2 contains the smaller of the two values,
+ ** set aTree[i] to its index and update pIter1. If vdbeSorterCompare()
+ ** was actually called above, then pThread->pUnpacked now contains
+ ** a value equivalent to pIter2. So set pKey2 to NULL to prevent
+ ** vdbeSorterCompare() from decoding pIter2 again.
+ **
+ ** If the two values were equal, then the value from the oldest
+ ** PMA should be considered smaller. The VdbeSorter.aIter[] array
+ ** is sorted from oldest to newest, so pIter1 contains older values
+ ** than pIter2 iff (pIter1<pIter2). */
+ if( iRes<0 || (iRes==0 && pIter1<pIter2) ){
+ pMerger->aTree[i] = (int)(pIter1 - pMerger->aIter);
+ pIter2 = &pMerger->aIter[ pMerger->aTree[i ^ 0x0001] ];
+ pKey2 = pIter2->aKey;
+ }else{
+ if( pIter1->pFile ) pKey2 = 0;
+ pMerger->aTree[i] = (int)(pIter2 - pMerger->aIter);
+ pIter1 = &pMerger->aIter[ pMerger->aTree[i ^ 0x0001] ];
+ }
+ }
+ *pbEof = (pMerger->aIter[pMerger->aTree[1]].pFile==0);
}
- *pbEof = (pMerger->aIter[pMerger->aTree[1]].pFile==0);
return rc;
}