SQLITE_NOTICE(283): recovered 1 frames from WAL file /fossil/sqlite.fossil-wal

SQLite: Check-in [aebe429e]
/ Check-in [aebe429e]
Login

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

Overview
Comment:When handling ORDER BY expressions, do not assume all values of an indexed expressions are distinct. Fix for [4766f444].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: aebe429e52ffef026cb0803fb164339d61bd2e88
User & Date: dan 2016-10-10 14:34:00
References
2016-10-10
14:38 Closed ticket [4766f444]: ORDER BY handling with indexes on expressions plus 6 other changes artifact: 498d1d7a user: dan
Context
2016-10-10
14:48
Remove a stray line from session4.test causing a memory leak. No changes to SQLite code. check-in: 6624c496 user: dan tags: trunk
14:34
When handling ORDER BY expressions, do not assume all values of an indexed expressions are distinct. Fix for [4766f444]. check-in: aebe429e user: dan tags: trunk
13:29
Make sure indexes on expressions skip over initial NULL values in the index. Fix for ticket [4baa464912129477f3c9] check-in: 71797ba4 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/where.c.

  3665   3665             }else{
  3666   3666               rev = revIdx ^ pOrderBy->a[i].sortOrder;
  3667   3667               if( rev ) *pRevMask |= MASKBIT(iLoop);
  3668   3668               revSet = 1;
  3669   3669             }
  3670   3670           }
  3671   3671           if( isMatch ){
  3672         -          if( iColumn<0 ){
         3672  +          if( iColumn==XN_ROWID ){
  3673   3673               testcase( distinctColumns==0 );
  3674   3674               distinctColumns = 1;
  3675   3675             }
  3676   3676             obSat |= MASKBIT(i);
  3677   3677           }else{
  3678   3678             /* No match found */
  3679   3679             if( j==0 || j<nKeyCol ){

Changes to test/indexexpr1.test.

   335    335     SELECT '1:', typeof(a), a FROM t1 WHERE a<10;
   336    336     SELECT '2:', typeof(a), a FROM t1 WHERE a+0<10;
   337    337     CREATE INDEX t1x1 ON t1(a);
   338    338     CREATE INDEX t1x2 ON t1(a+0);
   339    339     SELECT '3:', typeof(a), a FROM t1 WHERE a<10;
   340    340     SELECT '4:', typeof(a), a FROM t1 WHERE a+0<10;
   341    341   } {1: integer 1 2: integer 1 3: integer 1 4: integer 1}
          342  +
          343  +do_execsql_test indexexpr1-1200 {
          344  +  CREATE TABLE t10(a int, b int, c int, d int);
          345  +  INSERT INTO t10(a, b, c, d) VALUES(0, 0, 2, 2);
          346  +  INSERT INTO t10(a, b, c, d) VALUES(0, 0, 0, 0);
          347  +  INSERT INTO t10(a, b, c, d) VALUES(0, 0, 1, 1);
          348  +  INSERT INTO t10(a, b, c, d) VALUES(1, 1, 1, 1);
          349  +  INSERT INTO t10(a, b, c, d) VALUES(1, 1, 0, 0);
          350  +  INSERT INTO t10(a, b, c, d) VALUES(2, 2, 0, 0);
          351  +
          352  +  SELECT a+b, c+d FROM t10 ORDER BY a+b, c+d;
          353  +} {
          354  +  0 0 0 2 0 4 2 0 2 2 4 0
          355  +}
          356  +do_execsql_test indexexpr1-1200.1 {
          357  +  CREATE INDEX t10_ab ON t10(a+b);
          358  +}
          359  +do_execsql_test indexexpr1-1200.2 {
          360  +  SELECT a+b, c+d FROM t10 ORDER BY a+b, c+d;
          361  +} {
          362  +  0 0 0 2 0 4 2 0 2 2 4 0
          363  +}
          364  +do_execsql_test indexexpr1-1200.3 {
          365  +  CREATE INDEX t10_abcd ON t10(a+b,c+d);
          366  +}
          367  +do_execsql_test indexexpr1-1200.4 {
          368  +  SELECT a+b, c+d FROM t10 ORDER BY a+b, c+d;
          369  +} {
          370  +  0 0 0 2 0 4 2 0 2 2 4 0
          371  +}
   342    372   
   343    373   finish_test