/ Check-in [7ae06895]
Login

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

Overview
Comment:Fix a bug in the EXPLAIN QUERY PLAN code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | experimental
Files: files | file ages | folders
SHA1: 7ae068952fba4395b4aa437613a5ed2bd9ddf941
User & Date: dan 2010-11-11 11:43:01
Context
2010-11-11
16:46
Add a row of EXPLAIN QUERY PLAN output for each composite select operation (UNION, EXCEPT etc.) in the query. check-in: 00fb8468 user: dan tags: experimental
11:43
Fix a bug in the EXPLAIN QUERY PLAN code. check-in: 7ae06895 user: dan tags: experimental
10:36
Modifications to test cases to account for new EXPLAIN QUERY PLAN output. check-in: 30904ef8 user: dan tags: experimental
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  3154   3154     WherePlan *pPlan = &pLevel->plan;
  3155   3155     Index *pIndex = pPlan->u.pIdx;
  3156   3156     int nEq = pPlan->nEq;
  3157   3157     char *zRet = 0;
  3158   3158     int i;
  3159   3159   
  3160   3160     for(i=0; i<nEq; i++){
  3161         -    char *zCol = pTab->aCol[pIndex->aiColumn[i]].zName;
  3162   3161       zRet = sqlite3MAppendf(db, zRet, 
  3163         -        "%s%s%s=?", (zRet?zRet:""), (zRet?" AND ":""), zCol);
         3162  +        "%s%s%s=?", (zRet?zRet:""), (zRet?" AND ":""), 
         3163  +        pTab->aCol[pIndex->aiColumn[i]].zName
         3164  +    );
  3164   3165     }
  3165   3166   
  3166   3167     if( pPlan->wsFlags&WHERE_BTM_LIMIT ){
  3167   3168       zRet = sqlite3MAppendf(db, zRet,
  3168         -        "%s%s%s>?", (zRet?zRet:""), (zRet?" AND ":""), pTab->aCol[nEq].zName);
         3169  +        "%s%s%s>?", (zRet?zRet:""), (zRet?" AND ":""),
         3170  +        pTab->aCol[pIndex->aiColumn[i]].zName
         3171  +    );
  3169   3172     }
  3170   3173     if( pPlan->wsFlags&WHERE_TOP_LIMIT ){
  3171   3174       zRet = sqlite3MAppendf(db, zRet,
  3172         -        "%s%s%s<?", (zRet?zRet:""), (zRet?" AND ":""), pTab->aCol[nEq].zName);
         3175  +        "%s%s%s<?", (zRet?zRet:""), (zRet?" AND ":""), 
         3176  +        pTab->aCol[pIndex->aiColumn[i]].zName
         3177  +    );
  3173   3178     }
  3174   3179   
  3175   3180     if( zRet ){
  3176   3181       zRet = sqlite3MAppendf(db, zRet, " (%s)", zRet);
  3177   3182     }
  3178   3183   
  3179   3184     return zRet;

Changes to test/autoindex1.test.

   237    237              AND later.owner_change_date > prev.owner_change_date
   238    238              AND later.owner_change_date <= s.date_of_registration||' 00:00:00')
   239    239          ) y ON x.sheep_no = y.sheep_no
   240    240      WHERE y.sheep_no IS NULL
   241    241      ORDER BY x.registering_flock;
   242    242   } {
   243    243     1 0 0 {SCAN TABLE sheep AS s (~1000000 rows)} 
   244         -  1 1 1 {SCAN TABLE flock_owner AS prev BY INDEX sqlite_autoindex_flock_owner_1 (flock_no=? AND flock_no<?) (~2 rows)} 
          244  +  1 1 1 {SCAN TABLE flock_owner AS prev BY INDEX sqlite_autoindex_flock_owner_1 (flock_no=? AND owner_change_date<?) (~2 rows)} 
   245    245     1 0 0 {EXECUTE CORRELATED SCALAR SUBQUERY 2} 
   246         -  2 0 0 {SCAN TABLE flock_owner AS later BY COVERING INDEX sqlite_autoindex_flock_owner_1 (flock_no=? AND flock_no>? AND flock_no<?) (~1 rows)} 
          246  +  2 0 0 {SCAN TABLE flock_owner AS later BY COVERING INDEX sqlite_autoindex_flock_owner_1 (flock_no=? AND owner_change_date>? AND owner_change_date<?) (~1 rows)} 
   247    247     0 0 0 {SCAN TABLE sheep AS x BY INDEX sheep_reg_flock_index (~1000000 rows)} 
   248    248     0 1 1 {SCAN SUBQUERY 1 AS y BY AUTOMATIC COVERING INDEX (sheep_no=?) (~7 rows)}
   249    249   }
   250    250   
   251    251   finish_test

Changes to test/e_createtable.test.

  1375   1375     1    "EXPLAIN QUERY PLAN SELECT * FROM t1 WHERE b = 5" 
  1376   1376          {0 0 0 {SCAN TABLE t1 BY INDEX sqlite_autoindex_t1_1 (b=?) (~1 rows)}}
  1377   1377   
  1378   1378     2    "EXPLAIN QUERY PLAN SELECT * FROM t2 ORDER BY b, c"
  1379   1379          {0 0 0 {SCAN TABLE t2 BY INDEX sqlite_autoindex_t2_1 (~1000000 rows)}}
  1380   1380   
  1381   1381     3    "EXPLAIN QUERY PLAN SELECT * FROM t2 WHERE b=10 AND c>10"
  1382         -       {0 0 0 {SCAN TABLE t2 BY INDEX sqlite_autoindex_t2_1 (b=? AND b>?) (~3 rows)}}
         1382  +       {0 0 0 {SCAN TABLE t2 BY INDEX sqlite_autoindex_t2_1 (b=? AND c>?) (~3 rows)}}
  1383   1383   }
  1384   1384   
  1385   1385   # EVIDENCE-OF: R-45493-35653 A CHECK constraint may be attached to a
  1386   1386   # column definition or specified as a table constraint. In practice it
  1387   1387   # makes no difference.
  1388   1388   #
  1389   1389   #   All the tests that deal with CHECK constraints below (4.11.* and 

Changes to test/fts3fault.test.

    10     10   #***********************************************************************
    11     11   #
    12     12   
    13     13   set testdir [file dirname $argv0]
    14     14   source $testdir/tester.tcl
    15     15   
    16     16   set ::testprefix fts3fault
           17  +
           18  +# If SQLITE_ENABLE_FTS3 is not defined, omit this file.
           19  +ifcapable !fts3 { finish_test ; return }
    17     20   
    18     21   # Test error handling in the sqlite3Fts3Init() function. This is the 
    19     22   # function that registers the FTS3 module and various support functions
    20     23   # with SQLite.
    21     24   #
    22     25   do_faultsim_test 1 -body { 
    23     26     sqlite3 db test.db 

Changes to test/where7.test.

 23339  23339         AND t302.c3 > 1287603136
 23340  23340         AND (t301.c4 = 1407449685622784
 23341  23341              OR t301.c8 = 1407424651264000)
 23342  23342      ORDER BY t302.c5 LIMIT 200;
 23343  23343   } {
 23344  23344     0 0 1 {SCAN TABLE t301 BY COVERING INDEX t301_c4 (c4=?) (~10 rows)} 
 23345  23345     0 0 1 {SCAN TABLE t301 BY INTEGER PRIMARY KEY (rowid=?) (~1 rows)} 
 23346         -  0 1 0 {SCAN TABLE t302 BY INDEX t302_c8_c3 (c8=? AND c8>?) (~2 rows)} 
        23346  +  0 1 0 {SCAN TABLE t302 BY INDEX t302_c8_c3 (c8=? AND c3>?) (~2 rows)} 
 23347  23347     0 0 0 {USE TEMP B-TREE FOR ORDER BY}
 23348  23348   }
 23349  23349   
 23350  23350   finish_test

Changes to test/where9.test.

   468    468   
   469    469     # Likewise, inequalities in an AND are preferred over inequalities in
   470    470     # an OR.
   471    471     #
   472    472     do_execsql_test where9-5.3 {
   473    473       EXPLAIN QUERY PLAN SELECT a FROM t1 WHERE b>1000 AND (c>=31031 OR d IS NULL)
   474    474     } {
   475         -    0 0 0 {SCAN TABLE t1 BY INDEX t1b (a>?) (~165000 rows)}
          475  +    0 0 0 {SCAN TABLE t1 BY INDEX t1b (b>?) (~165000 rows)}
   476    476     }
   477    477   }
   478    478   
   479    479   ############################################################################
   480    480   # Make sure OR-clauses work correctly on UPDATE and DELETE statements.
   481    481   
   482    482   do_test where9-6.2.1 {