/ Check-in [62f3a220]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a problem in the block-sort logic that can arise if the VDBE opcode array is resized while the block-sort logic is being coded. "make test" now runs to completion, though there are still 17 failures.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | orderby-planning
Files: files | file ages | folders
SHA1: 62f3a22050e0f11c789374f8a3785df0a84c24cb
User & Date: drh 2014-03-19 16:56:58
Context
2014-03-19
17:41
Make it possible for block-sort to use the OP_SorterOpen sorter in addition to a generic OP_OpenEphemeral. check-in: 7ce2daaf user: drh tags: orderby-planning
16:56
Fix a problem in the block-sort logic that can arise if the VDBE opcode array is resized while the block-sort logic is being coded. "make test" now runs to completion, though there are still 17 failures. check-in: 62f3a220 user: drh tags: orderby-planning
15:17
Avoid reusing temporary registers in co-routines when doing block-sorting. check-in: 463d921b user: drh tags: orderby-planning
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/select.c.

   478    478     if( nOBSat>0 ){
   479    479       int regPrevKey;   /* The first nOBSat columns of the previous row */
   480    480       int addrFirst;    /* Address of the OP_IfNot opcode */
   481    481       int addrJmp;      /* Address of the OP_Jump opcode */
   482    482       VdbeOp *pOp;      /* Opcode that opens the sorter */
   483    483       int nKey;         /* Number of sorting key columns, including OP_Sequence */
   484    484   
          485  +    regPrevKey = pParse->nMem+1;
          486  +    pParse->nMem += pSort->nOBSat;
          487  +    nKey = nExpr - pSort->nOBSat + 1;
   485    488       addrFirst = sqlite3VdbeAddOp1(v, OP_IfNot, regBase+nExpr); VdbeCoverage(v);
          489  +    sqlite3VdbeAddOp3(v, OP_Compare, regPrevKey, regBase, pSort->nOBSat);
   486    490       pOp = sqlite3VdbeGetOp(v, pSort->addrSortIndex);
   487    491       pOp->opcode = OP_OpenEphemeral;
   488    492       pSort->sortFlags &= ~SORTFLAG_UseSorter;
   489         -    nKey = nExpr - pSort->nOBSat + 1;
   490    493       pOp->p2 = nKey + 1;
   491         -    regPrevKey = pParse->nMem+1;
   492         -    pParse->nMem += pSort->nOBSat;
   493         -    sqlite3VdbeAddOp4(v, OP_Compare, regPrevKey, regBase, pSort->nOBSat,
   494         -                      (char*)pOp->p4.pKeyInfo, P4_KEYINFO);
          494  +    sqlite3VdbeChangeP4(v, -1, (char*)pOp->p4.pKeyInfo, P4_KEYINFO);
   495    495       pOp->p4.pKeyInfo = keyInfoFromExprList(pParse, pSort->pOrderBy, nOBSat, 1);
   496    496       addrJmp = sqlite3VdbeCurrentAddr(v);
   497    497       sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);
   498    498       pSort->labelBkOut = sqlite3VdbeMakeLabel(v);
   499    499       pSort->regReturn = ++pParse->nMem;
   500    500       sqlite3VdbeAddOp2(v, OP_Gosub, pSort->regReturn, pSort->labelBkOut);
   501    501       sqlite3VdbeAddOp1(v, OP_ClearEphem, pSort->iECursor);