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

Performance improvement for affinity transformations on comparison operators.

FossilOrigin-Name: d7afdcbac24350b73a30c06c45cf0f2122820e4f
This commit is contained in:
drh
2014-09-18 16:28:59 +00:00
parent 7ea31ccb01
commit 24a096297e
3 changed files with 22 additions and 12 deletions

View File

@@ -1904,12 +1904,21 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
}else{
/* Neither operand is NULL. Do a comparison. */
affinity = pOp->p5 & SQLITE_AFF_MASK;
if( affinity>=SQLITE_AFF_TEXT ){
applyAffinity(pIn1, affinity, encoding);
applyAffinity(pIn3, affinity, encoding);
if( db->mallocFailed ) goto no_mem;
if( affinity>=SQLITE_AFF_NUMERIC ){
if( (pIn1->flags & (MEM_Int|MEM_Real))==0 && (pIn1->flags&MEM_Str)!=0 ){
applyNumericAffinity(pIn1,0);
}
if( (pIn3->flags & (MEM_Int|MEM_Real))==0 && (pIn3->flags&MEM_Str)!=0 ){
applyNumericAffinity(pIn3,0);
}
}else if( affinity==SQLITE_AFF_TEXT ){
if( (pIn1->flags & MEM_Str)==0 && (pIn1->flags & (MEM_Int|MEM_Real))!=0 ){
sqlite3VdbeMemStringify(pIn1, encoding, 1);
}
if( (pIn3->flags & MEM_Str)==0 && (pIn3->flags & (MEM_Int|MEM_Real))!=0 ){
sqlite3VdbeMemStringify(pIn3, encoding, 1);
}
}
assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
if( pIn1->flags & MEM_Zero ){
sqlite3VdbeMemExpandBlob(pIn1);
@@ -1919,6 +1928,7 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
sqlite3VdbeMemExpandBlob(pIn3);
flags3 &= ~MEM_Zero;
}
if( db->mallocFailed ) goto no_mem;
res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
}
switch( pOp->opcode ){