SQLite

Check-in [0e9f534fef]
Login

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

Overview
Comment:Make sure affinity is applied correctly on lower-bound range constraints in the min() optimization. Fix for ticket [a0bac8b3c3d1bb].
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | apple-osx
Files: files | file ages | folders
SHA1: 0e9f534fef72ca142a4296ab5285c82aada38ba7
User & Date: drh 2016-07-26 04:23:55.718
Context
2016-07-26
04:54
Merge the cache_spill VACUUM fix from trunk. (check-in: cc6bfdf814 user: drh tags: apple-osx)
04:31
Make sure affinity is applied correctly on lower-bound range constraints in the min() optimization. Fix for ticket [a0bac8b3c3d1bb]. (check-in: b819bace9c user: drh tags: trunk)
04:23
Make sure affinity is applied correctly on lower-bound range constraints in the min() optimization. Fix for ticket [a0bac8b3c3d1bb]. (check-in: 0e9f534fef user: drh tags: apple-osx)
2016-07-25
22:46
Merge the VACCUM cache_size adjustment from trunk. (check-in: cdb7efd01e user: drh tags: apple-osx)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/wherecode.c.
1315
1316
1317
1318
1319
1320
1321

1322
1323
1324
1325
1326
1327
1328
        }
        if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
          zStartAff[nEq] = SQLITE_AFF_BLOB;
        }
      }  
      nConstraint++;
      testcase( pRangeStart->wtFlags & TERM_VIRTUAL );

    }else if( bSeekPastNull ){
      sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
      nConstraint++;
      startEq = 0;
      start_constraints = 1;
    }
    codeApplyAffinity(pParse, regBase, nConstraint - bSeekPastNull, zStartAff);







>







1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
        }
        if( sqlite3ExprNeedsNoAffinityChange(pRight, zStartAff[nEq]) ){
          zStartAff[nEq] = SQLITE_AFF_BLOB;
        }
      }  
      nConstraint++;
      testcase( pRangeStart->wtFlags & TERM_VIRTUAL );
      bSeekPastNull = 0;
    }else if( bSeekPastNull ){
      sqlite3VdbeAddOp2(v, OP_Null, 0, regBase+nEq);
      nConstraint++;
      startEq = 0;
      start_constraints = 1;
    }
    codeApplyAffinity(pParse, regBase, nConstraint - bSeekPastNull, zStartAff);
Changes to test/minmax.test.
623
624
625
626
627
628
629














630
631
632
} {5}

do_test_13_noopt 13.7 {
  SELECT min(b), count(b) FROM t1 WHERE a='a';
} {
  SELECT min(c), count(c) FROM t1 WHERE a='a';
} {1 5}
















finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>



623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
} {5}

do_test_13_noopt 13.7 {
  SELECT min(b), count(b) FROM t1 WHERE a='a';
} {
  SELECT min(c), count(c) FROM t1 WHERE a='a';
} {1 5}

# 2016-07-26.  https://www.sqlite.org/src/info/a0bac8b3c3d1bb75
# Incorrect result on a min() query after a CREATE INDEX.
#
do_execsql_test 14.1 {
  CREATE TABLE t14(a INTEGER, b INTEGER);
  INSERT INTO t14(a,b) VALUES(100,2),(200,2),(300,2),(400,1),(500,2);
  SELECT min(a) FROM t14 WHERE b='2' AND a>'50';
} {100}
do_execsql_test 14.2 {
  CREATE INDEX t14ba ON t14(b,a);
  SELECT min(a) FROM t14 WHERE b='2' AND a>'50';
} {100}



finish_test