/ Check-in [ecbc0d5d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Disable the column cache when coding values that will be passed to the xFilter() method of a virtual table, in case the xFilter() implementation modifies the type or encoding of the value. Ticket #3121. (CVS 5139)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ecbc0d5deddc0ca0d1d2649e0134ee392266027e
User & Date: danielk1977 2008-05-16 15:40:40
Context
2008-05-19
15:37
Added test cases for corrupt 2-10 byte SerialTypeLen values. (CVS 5140) check-in: 97ed2dd1 user: shane tags: trunk
2008-05-16
15:40
Disable the column cache when coding values that will be passed to the xFilter() method of a virtual table, in case the xFilter() implementation modifies the type or encoding of the value. Ticket #3121. (CVS 5139) check-in: ecbc0d5d user: danielk1977 tags: trunk
15:24
Check that the encoding of values passed to sqlite3_bind_value() matches that of the database. (CVS 5138) check-in: e94a2883 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

    12     12   ** This module contains C code that generates VDBE code used to process
    13     13   ** the WHERE clause of SQL statements.  This module is reponsible for
    14     14   ** generating the code that loops through a table looking for applicable
    15     15   ** rows.  Indices are selected and used to speed the search when doing
    16     16   ** so is applicable.  Because this module is responsible for selecting
    17     17   ** indices, you might also think of this module as the "query optimizer".
    18     18   **
    19         -** $Id: where.c,v 1.302 2008/04/19 14:40:44 drh Exp $
           19  +** $Id: where.c,v 1.303 2008/05/16 15:40:40 danielk1977 Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   
    23     23   /*
    24     24   ** The number of bits in a Bitmask.  "BMS" means "BitMask Size".
    25     25   */
    26     26   #define BMS  (sizeof(Bitmask)*8)
................................................................................
  2351   2351         int nConstraint = pBestIdx->nConstraint;
  2352   2352         struct sqlite3_index_constraint_usage *aUsage =
  2353   2353                                                     pBestIdx->aConstraintUsage;
  2354   2354         const struct sqlite3_index_constraint *aConstraint =
  2355   2355                                                     pBestIdx->aConstraint;
  2356   2356   
  2357   2357         iReg = sqlite3GetTempRange(pParse, nConstraint+2);
         2358  +      pParse->disableColCache++;
  2358   2359         for(j=1; j<=nConstraint; j++){
  2359   2360           int k;
  2360   2361           for(k=0; k<nConstraint; k++){
  2361   2362             if( aUsage[k].argvIndex==j ){
  2362   2363               int iTerm = aConstraint[k].iTermOffset;
  2363   2364               sqlite3ExprCode(pParse, wc.a[iTerm].pExpr->pRight, iReg+j+1);
  2364   2365               break;
  2365   2366             }
  2366   2367           }
  2367   2368           if( k==nConstraint ) break;
  2368   2369         }
         2370  +      pParse->disableColCache--;
  2369   2371         sqlite3VdbeAddOp2(v, OP_Integer, pBestIdx->idxNum, iReg);
  2370   2372         sqlite3VdbeAddOp2(v, OP_Integer, j-1, iReg+1);
  2371   2373         sqlite3VdbeAddOp4(v, OP_VFilter, iCur, brk, iReg, pBestIdx->idxStr,
  2372   2374                           pBestIdx->needToFreeIdxStr ? P4_MPRINTF : P4_STATIC);
  2373   2375         sqlite3ReleaseTempRange(pParse, iReg, nConstraint+2);
  2374   2376         pBestIdx->needToFreeIdxStr = 0;
  2375   2377         for(j=0; j<pBestIdx->nConstraint; j++){

Added test/tkt3121.test.

            1  +# 2008 May 16
            2  +#
            3  +# The author disclaims copyright to this source code.  In place of
            4  +# a legal notice, here is a blessing:
            5  +#
            6  +#    May you do good and not evil.
            7  +#    May you find forgiveness for yourself and forgive others.
            8  +#    May you share freely, never taking more than you give.
            9  +#
           10  +#***********************************************************************
           11  +#
           12  +# $Id: tkt3121.test,v 1.1 2008/05/16 15:40:40 danielk1977 Exp $
           13  +
           14  +set testdir [file dirname $argv0]
           15  +source $testdir/tester.tcl
           16  +
           17  +ifcapable !vtab {
           18  +  finish_test
           19  +  return
           20  +}
           21  +
           22  +# Register the module
           23  +register_echo_module [sqlite3_connection_pointer db]
           24  +
           25  +do_test vtabD-1.1 {
           26  +  execsql {
           27  +    PRAGMA encoding = 'utf16';
           28  +
           29  +    CREATE TABLE r1(field);
           30  +    CREATE TABLE r2(col PRIMARY KEY, descr);
           31  +
           32  +    INSERT INTO r1 VALUES('abcd');
           33  +    INSERT INTO r2 VALUES('abcd', 'A nice description');
           34  +    INSERT INTO r2 VALUES('efgh', 'Another description');
           35  +
           36  +    CREATE VIRTUAL TABLE t1 USING echo(r1);
           37  +    CREATE VIRTUAL TABLE t2 USING echo(r2);
           38  +  }
           39  +} {}
           40  +
           41  +do_test vtabD-1.2 {
           42  +  execsql {
           43  +    select
           44  +      t1.field as Field,
           45  +      t2.descr as Descr
           46  +    from t1 inner join t2 on t1.field = t2.col order by t1.field
           47  +  }
           48  +} {abcd {A nice description}}
           49  +
           50  +finish_test
           51  +