mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-16 23:02:26 +03:00
Use the OP_Sequence opcode for generating unique rowid values for an
autoindex on a co-routine implementation of a subquery. FossilOrigin-Name: eab4297577e4d325fed4757867fc77860de7448998d86f098c8a50272e17d35e
This commit is contained in:
21
src/where.c
21
src/where.c
@@ -562,17 +562,17 @@ static LogEst estLog(LogEst N){
|
||||
** opcodes into OP_Copy when the table is being accessed via co-routine
|
||||
** instead of via table lookup.
|
||||
**
|
||||
** If the bIncrRowid parameter is 0, then any OP_Rowid instructions on
|
||||
** cursor iTabCur are transformed into OP_Null. Or, if bIncrRowid is non-zero,
|
||||
** then each OP_Rowid is transformed into an instruction to increment the
|
||||
** value stored in its output register.
|
||||
** If the iAutoidxCur is not zero, then any OP_Rowid instructions on
|
||||
** cursor iTabCur are transformed into OP_Sequence opcode for the
|
||||
** iAutoidxCur cursor, in order to generate unique rowids for the
|
||||
** automatic index being generated.
|
||||
*/
|
||||
static void translateColumnToCopy(
|
||||
Parse *pParse, /* Parsing context */
|
||||
int iStart, /* Translate from this opcode to the end */
|
||||
int iTabCur, /* OP_Column/OP_Rowid references to this table */
|
||||
int iRegister, /* The first column is in this register */
|
||||
int bIncrRowid /* If non-zero, transform OP_rowid to OP_AddImm(1) */
|
||||
int iAutoidxCur /* If non-zero, cursor of autoindex being generated */
|
||||
){
|
||||
Vdbe *v = pParse->pVdbe;
|
||||
VdbeOp *pOp = sqlite3VdbeGetOp(v, iStart);
|
||||
@@ -586,11 +586,9 @@ static void translateColumnToCopy(
|
||||
pOp->p2 = pOp->p3;
|
||||
pOp->p3 = 0;
|
||||
}else if( pOp->opcode==OP_Rowid ){
|
||||
if( bIncrRowid ){
|
||||
/* Increment the value stored in the P2 operand of the OP_Rowid. */
|
||||
pOp->opcode = OP_AddImm;
|
||||
pOp->p1 = pOp->p2;
|
||||
pOp->p2 = 1;
|
||||
if( iAutoidxCur ){
|
||||
pOp->opcode = OP_Sequence;
|
||||
pOp->p1 = iAutoidxCur;
|
||||
}else{
|
||||
pOp->opcode = OP_Null;
|
||||
pOp->p1 = 0;
|
||||
@@ -864,8 +862,9 @@ static void constructAutomaticIndex(
|
||||
if( pTabItem->fg.viaCoroutine ){
|
||||
sqlite3VdbeChangeP2(v, addrCounter, regBase+n);
|
||||
testcase( pParse->db->mallocFailed );
|
||||
assert( pLevel->iIdxCur>0 );
|
||||
translateColumnToCopy(pParse, addrTop, pLevel->iTabCur,
|
||||
pTabItem->regResult, 1);
|
||||
pTabItem->regResult, pLevel->iIdxCur);
|
||||
sqlite3VdbeGoto(v, addrTop);
|
||||
pTabItem->fg.viaCoroutine = 0;
|
||||
}else{
|
||||
|
||||
Reference in New Issue
Block a user