/ Check-in [0c8db5d8]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Additional intarray test cases and tweaks to comments.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0c8db5d88ee41dab58d6464283b51f82f7457838
User & Date: drh 2009-11-10 17:55:48
Context
2009-11-11
00:24
Generate VDBE code for the built-in COALESCE() and IFNULL() functions. This allows unused arguments to never be evaluated, which is a performance win when the unused argument is a subquery. check-in: 30055b25 user: drh tags: trunk
2009-11-10
17:55
Additional intarray test cases and tweaks to comments. check-in: 0c8db5d8 user: drh tags: trunk
17:24
Initial implementation and test cases for the "intarray" virtual table. check-in: 0e7d2925 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_intarray.c.

    51     51   
    52     52   /*
    53     53   ** None of this works unless we have virtual tables.
    54     54   */
    55     55   #ifndef SQLITE_OMIT_VIRTUALTABLE
    56     56   
    57     57   /*
    58         -** Free an sqlite3_intarray object
           58  +** Free an sqlite3_intarray object.
    59     59   */
    60     60   static void intarrayFree(sqlite3_intarray *p){
    61     61     if( p->xFree ){
    62     62       p->xFree(p->a);
    63     63     }
    64     64     sqlite3_free(p);
    65     65   }

Changes to test/intarray.test.

    26     26       CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
    27     27     }
    28     28     for {set i 1} {$i<=999} {incr i} {
    29     29       set b [format {x%03d} $i]
    30     30       db eval {INSERT INTO t1(a,b) VALUES($i,$b)}
    31     31     }
    32     32     db eval {
           33  +    CREATE TABLE t2(x INTEGER PRIMARY KEY, y);
           34  +    INSERT INTO t2 SELECT * FROM t1;
    33     35       SELECT b FROM t1 WHERE a IN (12,34,56,78) ORDER BY a
    34     36     }
    35     37   } {x012 x034 x056 x078}
    36     38   
    37     39   do_test intarray-1.1 {
    38     40     set ia1 [sqlite3_intarray_create db ia1]
    39     41     set ia2 [sqlite3_intarray_create db ia2]
................................................................................
    54     56   do_test intarray-1.3 {
    55     57     sqlite3_intarray_bind $ia3 45 123 678
    56     58     db eval {
    57     59       SELECT b FROM t1 WHERE a IN ia3 ORDER BY a
    58     60     }
    59     61   } {x045 x123 x678}
    60     62   
           63  +do_test intarray-1.4 {
           64  +  db eval {
           65  +    SELECT count(b) FROM t1 WHERE a NOT IN ia3 ORDER BY a
           66  +  }
           67  +} {996}
           68  +
           69  +#explain {SELECT b FROM t1 WHERE a NOT IN ia3}
           70  +
           71  +do_test intarray-1.5 {
           72  +  set cmd sqlite3_intarray_bind
           73  +  lappend cmd $ia1
           74  +  for {set i 1} {$i<=999} {incr i} {
           75  +    lappend cmd $i
           76  +    lappend cmd [expr {$i+1000}]
           77  +    lappend cmd [expr {$i+2000}]
           78  +  }
           79  +  eval $cmd
           80  +  db eval {
           81  +    REPLACE INTO t1 SELECT * FROM t2;
           82  +    DELETE FROM t1 WHERE a NOT IN ia1;
           83  +    SELECT count(*) FROM t1;
           84  +  }
           85  +} {999}
           86  +
           87  +do_test intarray-1.6 {
           88  +  db eval {
           89  +    DELETE FROM t1 WHERE a IN ia1;
           90  +    SELECT count(*) FROM t1;
           91  +  }
           92  +} {0}
           93  +
           94  +do_test intarray-2.1 {
           95  +  db eval {
           96  +    CREATE TEMP TABLE t3(p,q);
           97  +    INSERT INTO t3 SELECT * FROM t2;
           98  +    SELECT count(*) FROM t3 WHERE p IN ia1;
           99  +  }
          100  +} {999}
          101  +
          102  +do_test intarray-2.2 {
          103  +  set ia5 [sqlite3_intarray_create db ia5]
          104  +  db eval {
          105  +    SELECT count(*) FROM t3 WHERE p IN ia1;
          106  +  }
          107  +} {999}
    61    108   
    62    109   finish_test