-C Merge\sthe\scompound\sSELECT\soperator\sfix\sfrom\strunk.
-D 2015-06-23T13:02:10.077
+C Improvements\sto\sthe\sway\sbalance_nonroot()\sconstructs\sthe\sb.apCell\sarray\sof\npointers\sto\scells.
+D 2015-06-23T14:49:42.852
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 1063c58075b7400d93326b0eb332b48a54f53025
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/backup.c ff743689c4d6c5cb55ad42ed9d174b2b3e71f1e3
F src/bitvec.c 5eb7958c3bf65210211cbcfc44eff86d0ded7c9d
F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79
-F src/btree.c e6ac65de1742116fb5abbb106a26eb5bf48cd79e
+F src/btree.c 8d772673dc249aee6b6e65e4285291f7f2565ffd
F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1
F src/btreeInt.h 6ece2dd9c8e2eac05f0a8ded8772a44e96486c65
F src/build.c b3f15255d5b16e42dafeaa638fd4f8a47c94ed70
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 43844537e8a372953386663f8177202901ba7566 4df852ce26c95d5d23c83dbe9c59d2c3435acddf
-R 5a31f6e2047c6b2a76413665b07fcf29
+P a7be554f4b8534fc237fa4c6defc38fcd4049707
+R 4ad5f5185dfc9700d38a61349b40bf79
U drh
-Z ef941435462213fb596e80b11c30b19f
+Z 77f5541f0ad6043b85ab2e262249ce69
((P)->aData + ((P)->maskPage & get2byte(&(P)->aCellIdx[2*(I)])))
#define findCellv2(D,M,O,I) (D+(M&get2byte(D+(O+2*(I)))))
-
/*
-** This a more complex version of findCell() that works for
-** pages that do contain overflow cells.
+** Sort the overflow cells of a page into index order.
+**
+** An O(N*N) algorithm is used. But that should not be a problem
+** since N is only very rarely more than 1.
*/
-static u8 *findOverflowCell(MemPage *pPage, int iCell){
- int i;
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
- for(i=pPage->nOverflow-1; i>=0; i--){
- int k;
- k = pPage->aiOvfl[i];
- if( k<=iCell ){
- if( k==iCell ){
- return pPage->apOvfl[i];
+static void btreeSortOverflow(MemPage *p){
+ int j, k;
+ for(j=0; j<p->nOverflow-1; j++){
+ for(k=j+1; k<p->nOverflow; k++){
+ if( p->aiOvfl[j]>p->aiOvfl[k] ){
+ SWAP(u16, p->aiOvfl[j], p->aiOvfl[k]);
+ SWAP(u8*, p->apOvfl[j], p->apOvfl[k]);
}
- iCell--;
}
}
- return findCell(pPage, iCell);
}
+
/*
** This is common tail processing for btreeParseCellPtr() and
** btreeParseCellPtrIndex() for the case when the cell does not fit entirely
leafCorrection = b.pRef->leaf*4;
leafData = b.pRef->intKeyLeaf;
for(i=0; i<nOld; i++){
- int limit;
MemPage *pOld = apOld[i];
+ int limit = pOld->nCell;
+ u8 *aData = pOld->aData;
+ u16 maskPage = pOld->maskPage;
+ u16 cellOffset = pOld->cellOffset;
/* Verify that all sibling pages are of the same "type" (table-leaf,
** table-interior, index-leaf, or index-interior).
goto balance_cleanup;
}
- limit = pOld->nCell+pOld->nOverflow;
+ /* Load b.apCell[] with pointers to all cells in pOld. Intersperse
+ ** overflow cells in the correct sequence.
+ **
+ ** This must be done in advance. Once the balance starts, the cell
+ ** offset section of the btree page will be overwritten and we will no
+ ** long be able to find the cells if a pointer to each cell is not saved
+ ** first.
+ */
memset(&b.szCell[b.nCell], 0, sizeof(b.szCell[0])*limit);
+ j = 0;
if( pOld->nOverflow>0 ){
- for(j=0; j<limit; j++){
- assert( b.nCell<nMaxCells );
- b.apCell[b.nCell] = findOverflowCell(pOld, j);
- b.nCell++;
- }
- }else{
- u8 *aData = pOld->aData;
- u16 maskPage = pOld->maskPage;
- u16 cellOffset = pOld->cellOffset;
- for(j=0; j<limit; j++){
- assert( b.nCell<nMaxCells );
- b.apCell[b.nCell] = findCellv2(aData, maskPage, cellOffset, j);
+ memset(&b.szCell[b.nCell+limit], 0, sizeof(b.szCell[0])*pOld->nOverflow);
+ btreeSortOverflow(pOld);
+ for(k=0; k<pOld->nOverflow; k++){
+ limit = pOld->aiOvfl[k] - k;
+ while( j<limit ){
+ b.apCell[b.nCell] = findCellv2(aData, maskPage, cellOffset, j);
+ b.nCell++;
+ j++;
+ }
+ b.apCell[b.nCell] = pOld->apOvfl[k];
b.nCell++;
}
+ limit = pOld->nCell;
}
+ while( j<limit ){
+ assert( b.nCell<nMaxCells );
+ b.apCell[b.nCell] = findCellv2(aData, maskPage, cellOffset, j);
+ b.nCell++;
+ j++;
+ }
+
cntOld[i] = b.nCell;
if( i<nOld-1 && !leafData){
u16 sz = (u16)szNew[i];