SQLite

Check-in [0c8db5d88e]
Login

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

Overview
Comment:Additional intarray test cases and tweaks to comments.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0c8db5d88ee41dab58d6464283b51f82f7457838
User & Date: drh 2009-11-10 17:55:48.000
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: 30055b257c user: drh tags: trunk)
2009-11-10
17:55
Additional intarray test cases and tweaks to comments. (check-in: 0c8db5d88e user: drh tags: trunk)
17:24
Initial implementation and test cases for the "intarray" virtual table. (check-in: 0e7d29253f user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/test_intarray.c.
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

/*
** None of this works unless we have virtual tables.
*/
#ifndef SQLITE_OMIT_VIRTUALTABLE

/*
** Free an sqlite3_intarray object
*/
static void intarrayFree(sqlite3_intarray *p){
  if( p->xFree ){
    p->xFree(p->a);
  }
  sqlite3_free(p);
}







|







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

/*
** None of this works unless we have virtual tables.
*/
#ifndef SQLITE_OMIT_VIRTUALTABLE

/*
** Free an sqlite3_intarray object.
*/
static void intarrayFree(sqlite3_intarray *p){
  if( p->xFree ){
    p->xFree(p->a);
  }
  sqlite3_free(p);
}
Changes to test/intarray.test.
26
27
28
29
30
31
32


33
34
35
36
37
38
39
    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
  }
  for {set i 1} {$i<=999} {incr i} {
    set b [format {x%03d} $i]
    db eval {INSERT INTO t1(a,b) VALUES($i,$b)}
  }
  db eval {


    SELECT b FROM t1 WHERE a IN (12,34,56,78) ORDER BY a
  }
} {x012 x034 x056 x078}

do_test intarray-1.1 {
  set ia1 [sqlite3_intarray_create db ia1]
  set ia2 [sqlite3_intarray_create db ia2]







>
>







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
    CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
  }
  for {set i 1} {$i<=999} {incr i} {
    set b [format {x%03d} $i]
    db eval {INSERT INTO t1(a,b) VALUES($i,$b)}
  }
  db eval {
    CREATE TABLE t2(x INTEGER PRIMARY KEY, y);
    INSERT INTO t2 SELECT * FROM t1;
    SELECT b FROM t1 WHERE a IN (12,34,56,78) ORDER BY a
  }
} {x012 x034 x056 x078}

do_test intarray-1.1 {
  set ia1 [sqlite3_intarray_create db ia1]
  set ia2 [sqlite3_intarray_create db ia2]
54
55
56
57
58
59
60



61










































62
do_test intarray-1.3 {
  sqlite3_intarray_bind $ia3 45 123 678
  db eval {
    SELECT b FROM t1 WHERE a IN ia3 ORDER BY a
  }
} {x045 x123 x678}















































finish_test







>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
do_test intarray-1.3 {
  sqlite3_intarray_bind $ia3 45 123 678
  db eval {
    SELECT b FROM t1 WHERE a IN ia3 ORDER BY a
  }
} {x045 x123 x678}

do_test intarray-1.4 {
  db eval {
    SELECT count(b) FROM t1 WHERE a NOT IN ia3 ORDER BY a
  }
} {996}

#explain {SELECT b FROM t1 WHERE a NOT IN ia3}

do_test intarray-1.5 {
  set cmd sqlite3_intarray_bind
  lappend cmd $ia1
  for {set i 1} {$i<=999} {incr i} {
    lappend cmd $i
    lappend cmd [expr {$i+1000}]
    lappend cmd [expr {$i+2000}]
  }
  eval $cmd
  db eval {
    REPLACE INTO t1 SELECT * FROM t2;
    DELETE FROM t1 WHERE a NOT IN ia1;
    SELECT count(*) FROM t1;
  }
} {999}

do_test intarray-1.6 {
  db eval {
    DELETE FROM t1 WHERE a IN ia1;
    SELECT count(*) FROM t1;
  }
} {0}

do_test intarray-2.1 {
  db eval {
    CREATE TEMP TABLE t3(p,q);
    INSERT INTO t3 SELECT * FROM t2;
    SELECT count(*) FROM t3 WHERE p IN ia1;
  }
} {999}

do_test intarray-2.2 {
  set ia5 [sqlite3_intarray_create db ia5]
  db eval {
    SELECT count(*) FROM t3 WHERE p IN ia1;
  }
} {999}

finish_test