/ Check-in [6bc71dfc]
Login

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

Overview
Comment:Pull in recent trunk changes. Fix the ORDER BY optimizer so that it is better able to deal with COLLATE clauses. Clean up ambiguities in the descidx1.test script.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | nextgen-query-plan-exp
Files: files | file ages | folders
SHA1:6bc71dfcf0ef757c5c2b426dd8fddc1e5ae0f598
User & Date: drh 2013-06-03 20:46:35
Context
2013-06-03
21:25
Adjust the xBestIndex methods on both the fuzzer and transitive_closure virtual tables so that an unused MATCH operator gets a really large cost. Remove ambiguities from the fuzzer test cases. check-in: e2c1af78 user: drh tags: nextgen-query-plan-exp
20:46
Pull in recent trunk changes. Fix the ORDER BY optimizer so that it is better able to deal with COLLATE clauses. Clean up ambiguities in the descidx1.test script. check-in: 6bc71dfc user: drh tags: nextgen-query-plan-exp
20:39
Fix a typo in a collating function inside the e_reindex.test script. check-in: 4d74fccf user: drh tags: trunk
19:17
Do not use an index fullscan for an UPDATE or DELETE or if disabled by sqlite3_test_control() or sqlite3_config(). check-in: fabb2185 user: drh tags: nextgen-query-plan-exp
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/tclsqlite.c.

  3046   3046   
  3047   3047   /*
  3048   3048   ** Provide a dummy Tcl_InitStubs if we are using this as a static
  3049   3049   ** library.
  3050   3050   */
  3051   3051   #ifndef USE_TCL_STUBS
  3052   3052   # undef  Tcl_InitStubs
  3053         -# define Tcl_InitStubs(a,b,c)
         3053  +# define Tcl_InitStubs(a,b,c) TCL_VERSION
  3054   3054   #endif
  3055   3055   
  3056   3056   /*
  3057   3057   ** Make sure we have a PACKAGE_VERSION macro defined.  This will be
  3058   3058   ** defined automatically by the TEA makefile.  But other makefiles
  3059   3059   ** do not define it.
  3060   3060   */
................................................................................
  3070   3070   ** if the extension only supplies one new name!)  The "sqlite" command is
  3071   3071   ** used to open a new SQLite database.  See the DbMain() routine above
  3072   3072   ** for additional information.
  3073   3073   **
  3074   3074   ** The EXTERN macros are required by TCL in order to work on windows.
  3075   3075   */
  3076   3076   EXTERN int Sqlite3_Init(Tcl_Interp *interp){
  3077         -  Tcl_InitStubs(interp, "8.4", 0);
  3078         -  Tcl_CreateObjCommand(interp, "sqlite3", (Tcl_ObjCmdProc*)DbMain, 0, 0);
  3079         -  Tcl_PkgProvide(interp, "sqlite3", PACKAGE_VERSION);
  3080         -
         3077  +  int rc = Tcl_InitStubs(interp, "8.4", 0)==0 ? TCL_ERROR : TCL_OK;
         3078  +  if( rc==TCL_OK ){
         3079  +    Tcl_CreateObjCommand(interp, "sqlite3", (Tcl_ObjCmdProc*)DbMain, 0, 0);
  3081   3080   #ifndef SQLITE_3_SUFFIX_ONLY
  3082         -  /* The "sqlite" alias is undocumented.  It is here only to support
  3083         -  ** legacy scripts.  All new scripts should use only the "sqlite3"
  3084         -  ** command.
  3085         -  */
  3086         -  Tcl_CreateObjCommand(interp, "sqlite", (Tcl_ObjCmdProc*)DbMain, 0, 0);
         3081  +    /* The "sqlite" alias is undocumented.  It is here only to support
         3082  +    ** legacy scripts.  All new scripts should use only the "sqlite3"
         3083  +    ** command. */
         3084  +    Tcl_CreateObjCommand(interp, "sqlite", (Tcl_ObjCmdProc*)DbMain, 0, 0);
  3087   3085   #endif
  3088         -
  3089         -  return TCL_OK;
         3086  +    rc = Tcl_PkgProvide(interp, "sqlite3", PACKAGE_VERSION);
         3087  +  }
         3088  +  return rc;
  3090   3089   }
  3091   3090   EXTERN int Tclsqlite3_Init(Tcl_Interp *interp){ return Sqlite3_Init(interp); }
  3092   3091   EXTERN int Sqlite3_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; }
  3093   3092   EXTERN int Tclsqlite3_Unload(Tcl_Interp *interp, int flags){ return TCL_OK; }
  3094   3093   
  3095   3094   /* Because it accesses the file-system and uses persistent state, SQLite
  3096   3095   ** is not considered appropriate for safe interpreters.  Hence, we deliberately

Changes to src/where.c.

  4097   4097     ExprList *pOB;
  4098   4098     int iCol;
  4099   4099     int ii;
  4100   4100   
  4101   4101     if( (pOB = pBuilder->pOrderBy)==0 ) return 0;
  4102   4102     iCol = pIndex->aiColumn[0];
  4103   4103     for(ii=0; ii<pOB->nExpr; ii++){
  4104         -    Expr *pExpr = pOB->a[ii].pExpr;
         4104  +    Expr *pExpr = sqlite3ExprSkipCollate(pOB->a[ii].pExpr);
  4105   4105       if( pExpr->op!=TK_COLUMN ) return 0;
  4106   4106       if( pExpr->iTable==iCursor ){
  4107   4107         if( pExpr->iColumn==iCol ) return 1;
  4108   4108         return 0;
  4109   4109       }
  4110   4110     }
  4111   4111     return 0;

Changes to test/descidx1.test.

   193    193     do_test descidx1-4.2 {
   194    194       execsql {
   195    195         SELECT d FROM t2 ORDER BY a;
   196    196       }
   197    197     } {1.0 2.2 2.0 2.1 2.3 3.0 4.0 5.0 6.0}
   198    198     do_test descidx1-4.3 {
   199    199       execsql {
   200         -      SELECT d FROM t2 WHERE a>=2;
          200  +      SELECT d FROM t2 WHERE a>=2 ORDER BY a;
   201    201       }
   202    202     } {2.2 2.0 2.1 2.3 3.0 4.0 5.0 6.0}
   203    203     do_test descidx1-4.4 {
   204    204       execsql {
   205         -      SELECT d FROM t2 WHERE a>2;
          205  +      SELECT d FROM t2 WHERE a>2 ORDER BY a;
   206    206       }
   207    207     } {3.0 4.0 5.0 6.0}
   208    208     do_test descidx1-4.5 {
   209    209       execsql {
   210    210         SELECT d FROM t2 WHERE a=2 AND b>'two';
   211    211       }
   212    212     } {2.2}

Changes to test/e_reindex.test.

    94     94     set res [expr {[string length $lhs] - [string length $rhs]}]
    95     95     if {$res!=0} {return $res}
    96     96     return [string compare $lhs $rhs]
    97     97   }
    98     98   array set V {one 1 two 2 three 3 four 4 five 5 six 6 seven 7 eight 8}
    99     99   proc sort_by_value {lhs rhs} {
   100    100     global V
   101         -  set res [expr {$V($lhs) - $V(rhs)}]
          101  +  set res [expr {$V($lhs) - $V($rhs)}]
   102    102     if {$res!=0} {return $res}
   103    103     return [string compare $lhs $rhs]
   104    104   }
   105    105   
   106    106   db collate collA sort_by_length
   107    107   db collate collB sort_by_value
   108    108