Index: src/expr.c ================================================================== --- src/expr.c +++ src/expr.c @@ -289,10 +289,14 @@ p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight); p5 = binaryCompareP5(pLeft, pRight, jumpIfNull); addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1, (void*)p4, P4_COLLSEQ); sqlite3VdbeChangeP5(pParse->pVdbe, (u8)p5); + if( p5!=SQLITE_AFF_NONE ){ + sqlite3ExprCacheAffinityChange(pParse, in1, 1); + sqlite3ExprCacheAffinityChange(pParse, in2, 1); + } return addr; } #if SQLITE_MAX_EXPR_DEPTH>0 /* ADDED test/affinity01.test Index: test/affinity01.test ================================================================== --- /dev/null +++ test/affinity01.test @@ -0,0 +1,25 @@ +# 2014-03-24 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# Various tests for register affinity conversions. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix affinity01 + +do_execsql_test 1.0 { + CREATE TABLE t(x); + INSERT INTO t VALUES('1'); + SELECT typeof(x) FROM t WHERE x=x+0; +} {text} + +finish_test