Index: src/where.c ================================================================== --- src/where.c +++ src/where.c @@ -14,11 +14,11 @@ ** generating the code that loops through a table looking for applicable ** rows. Indices are selected and used to speed the search when doing ** so is applicable. Because this module is responsible for selecting ** indices, you might also think of this module as the "query optimizer". ** -** $Id: where.c,v 1.302 2008/04/19 14:40:44 drh Exp $ +** $Id: where.c,v 1.303 2008/05/16 15:40:40 danielk1977 Exp $ */ #include "sqliteInt.h" /* ** The number of bits in a Bitmask. "BMS" means "BitMask Size". @@ -2353,10 +2353,11 @@ pBestIdx->aConstraintUsage; const struct sqlite3_index_constraint *aConstraint = pBestIdx->aConstraint; iReg = sqlite3GetTempRange(pParse, nConstraint+2); + pParse->disableColCache++; for(j=1; j<=nConstraint; j++){ int k; for(k=0; kdisableColCache--; sqlite3VdbeAddOp2(v, OP_Integer, pBestIdx->idxNum, iReg); sqlite3VdbeAddOp2(v, OP_Integer, j-1, iReg+1); sqlite3VdbeAddOp4(v, OP_VFilter, iCur, brk, iReg, pBestIdx->idxStr, pBestIdx->needToFreeIdxStr ? P4_MPRINTF : P4_STATIC); sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2); ADDED test/tkt3121.test Index: test/tkt3121.test ================================================================== --- /dev/null +++ test/tkt3121.test @@ -0,0 +1,51 @@ +# 2008 May 16 +# +# 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. +# +#*********************************************************************** +# +# $Id: tkt3121.test,v 1.1 2008/05/16 15:40:40 danielk1977 Exp $ + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +ifcapable !vtab { + finish_test + return +} + +# Register the module +register_echo_module [sqlite3_connection_pointer db] + +do_test vtabD-1.1 { + execsql { + PRAGMA encoding = 'utf16'; + + CREATE TABLE r1(field); + CREATE TABLE r2(col PRIMARY KEY, descr); + + INSERT INTO r1 VALUES('abcd'); + INSERT INTO r2 VALUES('abcd', 'A nice description'); + INSERT INTO r2 VALUES('efgh', 'Another description'); + + CREATE VIRTUAL TABLE t1 USING echo(r1); + CREATE VIRTUAL TABLE t2 USING echo(r2); + } +} {} + +do_test vtabD-1.2 { + execsql { + select + t1.field as Field, + t2.descr as Descr + from t1 inner join t2 on t1.field = t2.col order by t1.field + } +} {abcd {A nice description}} + +finish_test +