xref: /sqlite-3.40.0/test/vtabB.test (revision 05a3e474)
1665850fbSdrh# 2008 April 10
2665850fbSdrh#
3665850fbSdrh# The author disclaims copyright to this source code.  In place of
4665850fbSdrh# a legal notice, here is a blessing:
5665850fbSdrh#
6665850fbSdrh#    May you do good and not evil.
7665850fbSdrh#    May you find forgiveness for yourself and forgive others.
8665850fbSdrh#    May you share freely, never taking more than you give.
9665850fbSdrh#
10665850fbSdrh#***********************************************************************
11665850fbSdrh# This file implements regression tests for SQLite library.  The
12665850fbSdrh# focus of this file is is verifying that a virtual table in the
13665850fbSdrh# TEMP database that is created and dropped within a transaction
14665850fbSdrh# is handled correctly.  Ticket #2994.
15*05a3e474Sdrh#
16*05a3e474Sdrh# Also make sure a virtual table on the right-hand side of an IN operator
17*05a3e474Sdrh# is materialized rather than being used directly.  Ticket #3082.
18*05a3e474Sdrh#
19665850fbSdrh
20665850fbSdrh#
21*05a3e474Sdrh# $Id: vtabB.test,v 1.2 2008/04/25 12:10:15 drh Exp $
22665850fbSdrh
23665850fbSdrhset testdir [file dirname $argv0]
24665850fbSdrhsource $testdir/tester.tcl
25665850fbSdrh
26665850fbSdrhifcapable !vtab {
27665850fbSdrh  finish_test
28665850fbSdrh  return
29665850fbSdrh}
30665850fbSdrh
31665850fbSdrhdo_test vtabB-1.1 {
32665850fbSdrh  register_echo_module [sqlite3_connection_pointer db]
33665850fbSdrh  execsql {
34665850fbSdrh    CREATE TABLE t1(x);
35665850fbSdrh    BEGIN;
36665850fbSdrh    CREATE VIRTUAL TABLE temp.echo_test1 USING echo(t1);
37665850fbSdrh    DROP TABLE echo_test1;
38665850fbSdrh    ROLLBACK;
39665850fbSdrh  }
40665850fbSdrh} {}
41665850fbSdrh
42*05a3e474Sdrhdo_test vtabB-2.1 {
43*05a3e474Sdrh  execsql {
44*05a3e474Sdrh    INSERT INTO t1 VALUES(2);
45*05a3e474Sdrh    INSERT INTO t1 VALUES(3);
46*05a3e474Sdrh    CREATE TABLE t2(y);
47*05a3e474Sdrh    INSERT INTO t2 VALUES(1);
48*05a3e474Sdrh    INSERT INTO t2 VALUES(2);
49*05a3e474Sdrh    CREATE VIRTUAL TABLE echo_t2 USING echo(t2);
50*05a3e474Sdrh    SELECT * FROM t1 WHERE x IN (SELECT rowid FROM t2);
51*05a3e474Sdrh  }
52*05a3e474Sdrh} {2}
53*05a3e474Sdrhdo_test vtab8-2.2 {
54*05a3e474Sdrh  execsql {
55*05a3e474Sdrh    SELECT rowid FROM echo_t2
56*05a3e474Sdrh  }
57*05a3e474Sdrh} {1 2}
58*05a3e474Sdrhdo_test vtabB-2.3 {
59*05a3e474Sdrh  execsql {
60*05a3e474Sdrh    SELECT * FROM t1 WHERE x IN (SELECT rowid FROM t2);
61*05a3e474Sdrh  }
62*05a3e474Sdrh} {2}
63*05a3e474Sdrhdo_test vtabB-2.4 {
64*05a3e474Sdrh  execsql {
65*05a3e474Sdrh    SELECT * FROM t1 WHERE x IN (SELECT rowid FROM echo_t2);
66*05a3e474Sdrh  }
67*05a3e474Sdrh} {2}
68*05a3e474Sdrhdo_test vtabB-2.5 {
69*05a3e474Sdrh  execsql {
70*05a3e474Sdrh    SELECT * FROM t1 WHERE x IN (SELECT y FROM t2);
71*05a3e474Sdrh  }
72*05a3e474Sdrh} {2}
73*05a3e474Sdrhdo_test vtabB-2.6 {
74*05a3e474Sdrh  execsql {
75*05a3e474Sdrh    SELECT * FROM t1 WHERE x IN (SELECT y FROM echo_t2);
76*05a3e474Sdrh  }
77*05a3e474Sdrh} {2}
78*05a3e474Sdrh
79665850fbSdrhfinish_test
80