/ Check-in [6055dad2]
Login

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

Overview
Comment:Disable the OR optimization for WITHOUT ROWID tables, since it relies on the use of rowids.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | omit-rowid
Files: files | file ages | folders
SHA1: 6055dad2ba2f9256b1f2d0a9e32ca00f1b81b0cf
User & Date: drh 2013-11-06 12:05:57
Context
2013-11-06
12:56
Improved ORDER BY optimization for WITHOUT ROWID tables. check-in: 8f1709ff user: drh tags: omit-rowid
12:05
Disable the OR optimization for WITHOUT ROWID tables, since it relies on the use of rowids. check-in: 6055dad2 user: drh tags: omit-rowid
11:46
Remove an incorrect test case from conflict2.test. check-in: 427612ef user: drh tags: omit-rowid
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  4870   4870     
  4871   4871     pWC = pBuilder->pWC;
  4872   4872     if( pWInfo->wctrlFlags & WHERE_AND_ONLY ) return SQLITE_OK;
  4873   4873     pWCEnd = pWC->a + pWC->nTerm;
  4874   4874     pNew = pBuilder->pNew;
  4875   4875     memset(&sSum, 0, sizeof(sSum));
  4876   4876     pItem = pWInfo->pTabList->a + pNew->iTab;
         4877  +  if( !HasRowid(pItem->pTab) ) return SQLITE_OK;
  4877   4878     iCur = pItem->iCursor;
  4878   4879   
  4879   4880     for(pTerm=pWC->a; pTerm<pWCEnd && rc==SQLITE_OK; pTerm++){
  4880   4881       if( (pTerm->eOperator & WO_OR)!=0
  4881   4882        && (pTerm->u.pOrInfo->indexable & pNew->maskSelf)!=0 
  4882   4883       ){
  4883   4884         WhereClause * const pOrWC = &pTerm->u.pOrInfo->wc;

Changes to test/where8.test.

     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library. The focus
    12     12   # is testing of where.c. More specifically, the focus is the optimization
    13     13   # of WHERE clauses that feature the OR operator.
    14     14   #
    15         -# $Id: where8.test,v 1.9 2009/07/31 06:14:52 danielk1977 Exp $
    16     15   
    17     16   set testdir [file dirname $argv0]
    18     17   source $testdir/tester.tcl
    19     18   
    20     19   # Test organization:
    21     20   #
    22     21   #   where8-1.*: Tests to demonstrate simple cases work with a single table
................................................................................
   744    743       SELECT a, x FROM tA LEFT JOIN tB ON (
   745    744         a=1 AND b=2 AND c=3 AND d=4 AND e=5 AND f=6 AND g=7 AND h=8 AND
   746    745         i=1 AND j=2 AND k=3 AND l=4 AND m=5 AND n=6 AND o=7 AND
   747    746         (p = 1 OR p = 2 OR p = 3)
   748    747       )
   749    748     }
   750    749   } {1 {}}
          750  +
          751  +# The OR optimization and WITHOUT ROWID
          752  +#
          753  +do_execsql_test where8-6.1 {
          754  +  CREATE TABLE t600(a PRIMARY KEY, b) WITHOUT rowid;
          755  +  CREATE INDEX t600b ON t600(b);
          756  +  INSERT INTO t600 VALUES('state','screen'),('exact','dolphin'),('green','mercury');
          757  +  SELECT a, b, '|' FROM t600 WHERE a=='state' OR b='mercury' ORDER BY +a;
          758  +} {green mercury | state screen |}
   751    759   
   752    760   finish_test