mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Improvement to the OP_Permutation opcode to prevent it from using CPU cycles
for initialization in prepared statements that do not use that opcode. FossilOrigin-Name: b4a98f65564a0d9fba2fef95ebd00a39b3e1e572
This commit is contained in:
20
src/vdbe.c
20
src/vdbe.c
@@ -583,7 +583,6 @@ int sqlite3VdbeExec(
|
||||
Mem *pIn2 = 0; /* 2nd input operand */
|
||||
Mem *pIn3 = 0; /* 3rd input operand */
|
||||
Mem *pOut = 0; /* Output operand */
|
||||
int *aPermute = 0; /* Permutation of columns for OP_Compare */
|
||||
#ifdef VDBE_PROFILE
|
||||
u64 start; /* CPU clock count at start of opcode */
|
||||
#endif
|
||||
@@ -2136,8 +2135,8 @@ case OP_ElseNotEq: { /* same as TK_ESCAPE, jump */
|
||||
|
||||
/* Opcode: Permutation * * * P4 *
|
||||
**
|
||||
** Set the permutation used by the OP_Compare operator to be the array
|
||||
** of integers in P4.
|
||||
** Set the permutation used by the OP_Compare operator in the next
|
||||
** instruction. The permutation is stored in the P4 operand.
|
||||
**
|
||||
** The permutation is only valid until the next OP_Compare that has
|
||||
** the OPFLAG_PERMUTE bit set in P5. Typically the OP_Permutation should
|
||||
@@ -2149,7 +2148,8 @@ case OP_ElseNotEq: { /* same as TK_ESCAPE, jump */
|
||||
case OP_Permutation: {
|
||||
assert( pOp->p4type==P4_INTARRAY );
|
||||
assert( pOp->p4.ai );
|
||||
aPermute = pOp->p4.ai + 1;
|
||||
assert( pOp[1].opcode==OP_Compare );
|
||||
assert( pOp[1].p5 & OPFLAG_PERMUTE );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2182,8 +2182,17 @@ case OP_Compare: {
|
||||
int idx;
|
||||
CollSeq *pColl; /* Collating sequence to use on this term */
|
||||
int bRev; /* True for DESCENDING sort order */
|
||||
int *aPermute; /* The permutation */
|
||||
|
||||
if( (pOp->p5 & OPFLAG_PERMUTE)==0 ) aPermute = 0;
|
||||
if( (pOp->p5 & OPFLAG_PERMUTE)==0 ){
|
||||
aPermute = 0;
|
||||
}else{
|
||||
assert( pOp>aOp );
|
||||
assert( pOp[-1].opcode==OP_Permutation );
|
||||
assert( pOp[-1].p4type==P4_INTARRAY );
|
||||
aPermute = pOp[-1].p4.ai + 1;
|
||||
assert( aPermute!=0 );
|
||||
}
|
||||
n = pOp->p3;
|
||||
pKeyInfo = pOp->p4.pKeyInfo;
|
||||
assert( n>0 );
|
||||
@@ -2216,7 +2225,6 @@ case OP_Compare: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
aPermute = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user