mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-15 11:41:13 +03:00
Proposed optimization to the IS NULL and NOT NULL operators that avoids
loading the entire content of larges strings and BLOBs. Response to [forum:/info/3c08d4715dc05b00|forum post 3c08d4715dc05b00]. FossilOrigin-Name: 45f171565442f9fd6574fb93ae7abe83c168b20be68af42531bc55571450d3ab
This commit is contained in:
@@ -5241,6 +5241,7 @@ void sqlite3ExprIfTrue(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
|
||||
assert( TK_ISNULL==OP_IsNull ); testcase( op==TK_ISNULL );
|
||||
assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL );
|
||||
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
|
||||
sqlite3VdbeTypeofColumn(v, r1);
|
||||
sqlite3VdbeAddOp2(v, op, r1, dest);
|
||||
VdbeCoverageIf(v, op==TK_ISNULL);
|
||||
VdbeCoverageIf(v, op==TK_NOTNULL);
|
||||
@@ -5415,6 +5416,7 @@ void sqlite3ExprIfFalse(Parse *pParse, Expr *pExpr, int dest, int jumpIfNull){
|
||||
case TK_ISNULL:
|
||||
case TK_NOTNULL: {
|
||||
r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1);
|
||||
sqlite3VdbeTypeofColumn(v, r1);
|
||||
sqlite3VdbeAddOp2(v, op, r1, dest);
|
||||
testcase( op==TK_ISNULL ); VdbeCoverageIf(v, op==TK_ISNULL);
|
||||
testcase( op==TK_NOTNULL ); VdbeCoverageIf(v, op==TK_NOTNULL);
|
||||
|
||||
@@ -1791,9 +1791,7 @@ void sqlite3Pragma(
|
||||
|| pTab->iPKey==mxCol) ) mxCol--;
|
||||
if( mxCol>=0 ){
|
||||
sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, mxCol, 3);
|
||||
if( sqlite3VdbeGetLastOp(v)->opcode==OP_Column ){
|
||||
sqlite3VdbeChangeP5(v, OPFLAG_TYPEOFARG);
|
||||
}
|
||||
sqlite3VdbeTypeofColumn(v, 3);
|
||||
}
|
||||
|
||||
if( !isQuick ){
|
||||
|
||||
@@ -228,6 +228,7 @@ void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1);
|
||||
void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2);
|
||||
void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3);
|
||||
void sqlite3VdbeChangeP5(Vdbe*, u16 P5);
|
||||
void sqlite3VdbeTypeofColumn(Vdbe*, int);
|
||||
void sqlite3VdbeJumpHere(Vdbe*, int addr);
|
||||
void sqlite3VdbeJumpHereOrPopInst(Vdbe*, int addr);
|
||||
int sqlite3VdbeChangeToNoop(Vdbe*, int addr);
|
||||
|
||||
@@ -1155,6 +1155,22 @@ void sqlite3VdbeChangeP5(Vdbe *p, u16 p5){
|
||||
if( p->nOp>0 ) p->aOp[p->nOp-1].p5 = p5;
|
||||
}
|
||||
|
||||
/*
|
||||
** If the previous opcode is an OP_Column that delivers results
|
||||
** into register iDest, then add the OPFLAG_TYPEOF flag to that
|
||||
** opcode.
|
||||
*/
|
||||
void sqlite3VdbeTypeofColumn(Vdbe *p, int iDest){
|
||||
if( p->nOp>0 ){
|
||||
VdbeOp *pOp = &p->aOp[p->nOp-1];
|
||||
if( pOp->opcode==OP_Column && pOp->p3==iDest ){
|
||||
pOp->p5 |= OPFLAG_TYPEOFARG;
|
||||
}
|
||||
}else{
|
||||
assert( p->db->mallocFailed );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Change the P2 operand of instruction addr so that it points to
|
||||
** the address of the next instruction to be coded.
|
||||
|
||||
Reference in New Issue
Block a user