/ Check-in [d362ba15]
Login

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

Overview
Comment:Fix the "onecolumn" and "exists" methods of the TCL interface so that they work in combination with the "profile" callback.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d362ba157f993fc74a590cf15a9a2fa589278dd7
User & Date: drh 2016-06-13 12:34:38
Context
2016-06-13
12:51
Fix an incorrect assert() in the btree logic. check-in: fcf6114b user: drh tags: trunk
12:34
Fix the "onecolumn" and "exists" methods of the TCL interface so that they work in combination with the "profile" callback. check-in: d362ba15 user: drh tags: trunk
2016-06-10
22:49
Enhance "PRAGMA table_info" to that it provides information about eponymous virtual tables. check-in: 53a1e5d5 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/tclsqlite.c.

  2321   2321     **    $db onecolumn $sql
  2322   2322     **
  2323   2323     ** The onecolumn method is the equivalent of:
  2324   2324     **     lindex [$db eval $sql] 0
  2325   2325     */
  2326   2326     case DB_EXISTS: 
  2327   2327     case DB_ONECOLUMN: {
         2328  +    Tcl_Obj *pResult = 0;
  2328   2329       DbEvalContext sEval;
  2329   2330       if( objc!=3 ){
  2330   2331         Tcl_WrongNumArgs(interp, 2, objv, "SQL");
  2331   2332         return TCL_ERROR;
  2332   2333       }
  2333   2334   
  2334   2335       dbEvalInit(&sEval, pDb, objv[2], 0);
  2335   2336       rc = dbEvalStep(&sEval);
  2336   2337       if( choice==DB_ONECOLUMN ){
  2337   2338         if( rc==TCL_OK ){
  2338         -        Tcl_SetObjResult(interp, dbEvalColumnValue(&sEval, 0));
         2339  +        pResult = dbEvalColumnValue(&sEval, 0);
  2339   2340         }else if( rc==TCL_BREAK ){
  2340   2341           Tcl_ResetResult(interp);
  2341   2342         }
  2342   2343       }else if( rc==TCL_BREAK || rc==TCL_OK ){
  2343         -      Tcl_SetObjResult(interp, Tcl_NewBooleanObj(rc==TCL_OK));
         2344  +      pResult = Tcl_NewBooleanObj(rc==TCL_OK);
  2344   2345       }
  2345   2346       dbEvalFinalize(&sEval);
         2347  +    if( pResult ) Tcl_SetObjResult(interp, pResult);
  2346   2348   
  2347   2349       if( rc==TCL_BREAK ){
  2348   2350         rc = TCL_OK;
  2349   2351       }
  2350   2352       break;
  2351   2353     }
  2352   2354      

Changes to test/tclsqlite.test.

   630    630   do_execsql_test tcl-14.1 {
   631    631     CREATE TABLE t6(x);
   632    632     INSERT INTO t6 VALUES(1);
   633    633   }
   634    634   do_test tcl-14.2 {
   635    635     db one {SELECT x FROM t6 WHERE xCall()!='value'}
   636    636   } {}
          637  +
          638  +# Verify that the "exists" and "onecolumn" methods work when
          639  +# a "profile" is registered.
          640  +#
          641  +catch {db close}
          642  +sqlite3 db :memory:
          643  +proc noop-profile {args} {
          644  +  return
          645  +}
          646  +do_test tcl-15.0 {
          647  +  db eval {CREATE TABLE t1(a); INSERT INTO t1 VALUES(1),(2),(3);}
          648  +  db onecolumn {SELECT a FROM t1 WHERE a>2}
          649  +} {3}
          650  +do_test tcl-15.1 {
          651  +  db exists {SELECT a FROM t1 WHERE a>2}
          652  +} {1}
          653  +do_test tcl-15.2 {
          654  +  db exists {SELECT a FROM t1 WHERE a>3}
          655  +} {0}
          656  +db profile noop-profile
          657  +do_test tcl-15.3 {
          658  +  db onecolumn {SELECT a FROM t1 WHERE a>2}
          659  +} {3}
          660  +do_test tcl-15.4 {
          661  +  db exists {SELECT a FROM t1 WHERE a>2}
          662  +} {1}
          663  +do_test tcl-15.5 {
          664  +  db exists {SELECT a FROM t1 WHERE a>3}
          665  +} {0}
          666  +
          667  +
          668  +
          669  +
   637    670   
   638    671   
   639    672   
   640    673   finish_test