1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Change the recursive common table expression algorithm to use a queue instead

of a pair of tables.  Runs about 25% faster on the sudoku solver query. 
The OP_SwapCursors opcode is no longer required.  The current implementation
uses just a fifo, but the plan is to change it into a queue that will support 
ORDER BY and LIMIT in a recursive query.

FossilOrigin-Name: b2671e1133d2f1fbd36e7cd4b86d6cc7b528aa97
This commit is contained in:
drh
2014-01-21 22:25:45 +00:00
parent 8561c81ed6
commit e73f059093
6 changed files with 76 additions and 86 deletions

View File

@@ -3369,33 +3369,6 @@ case OP_OpenEphemeral: {
break;
}
#ifndef SQLITE_OMIT_CTE
/* Opcode: SwapCursors P1 P2 * * *
**
** Parameters P1 and P2 are both cursors opened by the OpenEphemeral
** opcode. This opcode deletes the contents of epheremal table P1,
** then renames P2 to P1 and P1 to P2. In other words, following this
** opcode cursor P2 is open on an empty table and P1 is open on the
** table that was initially accessed by P2.
*/
case OP_SwapCursors: {
Mem tmp;
VdbeCursor *pTmp;
tmp = p->aMem[p->nMem - pOp->p1];
p->aMem[p->nMem - pOp->p1] = p->aMem[p->nMem - pOp->p2];
p->aMem[p->nMem - pOp->p2] = tmp;
pTmp = p->apCsr[pOp->p1];
p->apCsr[pOp->p1] = p->apCsr[pOp->p2];
p->apCsr[pOp->p2] = pTmp;
assert( pTmp->isTable );
rc = sqlite3BtreeClearTable(pTmp->pBt, MASTER_ROOT, 0);
break;
}
#endif /* ifndef SQLITE_OMIT_CTE */
/* Opcode: SorterOpen P1 * * P4 *
**
** This opcode works like OP_OpenEphemeral except that it opens
@@ -4393,7 +4366,6 @@ case OP_NullRow: {
pC->nullRow = 1;
pC->rowidIsValid = 0;
pC->cacheStatus = CACHE_STALE;
assert( pC->pCursor || pC->pVtabCursor );
if( pC->pCursor ){
sqlite3BtreeClearCursor(pC->pCursor);
}