blob: 201e97895043c05a411d733067e31cb937db2390 [file] [log] [blame]
drh665850f2008-04-10 18:35:21 +00001# 2008 April 10
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11# This file implements regression tests for SQLite library. The
12# focus of this file is is verifying that a virtual table in the
13# TEMP database that is created and dropped within a transaction
14# is handled correctly. Ticket #2994.
drh05a3e472008-04-25 12:10:15 +000015#
16# Also make sure a virtual table on the right-hand side of an IN operator
17# is materialized rather than being used directly. Ticket #3082.
18#
drh665850f2008-04-10 18:35:21 +000019
20#
drh05a3e472008-04-25 12:10:15 +000021# $Id: vtabB.test,v 1.2 2008/04/25 12:10:15 drh Exp $
drh665850f2008-04-10 18:35:21 +000022
23set testdir [file dirname $argv0]
24source $testdir/tester.tcl
25
26ifcapable !vtab {
27 finish_test
28 return
29}
30
31do_test vtabB-1.1 {
32 register_echo_module [sqlite3_connection_pointer db]
33 execsql {
34 CREATE TABLE t1(x);
35 BEGIN;
36 CREATE VIRTUAL TABLE temp.echo_test1 USING echo(t1);
37 DROP TABLE echo_test1;
38 ROLLBACK;
39 }
40} {}
41
drh05a3e472008-04-25 12:10:15 +000042do_test vtabB-2.1 {
43 execsql {
44 INSERT INTO t1 VALUES(2);
45 INSERT INTO t1 VALUES(3);
46 CREATE TABLE t2(y);
47 INSERT INTO t2 VALUES(1);
48 INSERT INTO t2 VALUES(2);
49 CREATE VIRTUAL TABLE echo_t2 USING echo(t2);
50 SELECT * FROM t1 WHERE x IN (SELECT rowid FROM t2);
51 }
52} {2}
53do_test vtab8-2.2 {
54 execsql {
55 SELECT rowid FROM echo_t2
56 }
57} {1 2}
58do_test vtabB-2.3 {
59 execsql {
60 SELECT * FROM t1 WHERE x IN (SELECT rowid FROM t2);
61 }
62} {2}
63do_test vtabB-2.4 {
64 execsql {
65 SELECT * FROM t1 WHERE x IN (SELECT rowid FROM echo_t2);
66 }
67} {2}
68do_test vtabB-2.5 {
69 execsql {
70 SELECT * FROM t1 WHERE x IN (SELECT y FROM t2);
71 }
72} {2}
73do_test vtabB-2.6 {
74 execsql {
75 SELECT * FROM t1 WHERE x IN (SELECT y FROM echo_t2);
76 }
77} {2}
78
drh665850f2008-04-10 18:35:21 +000079finish_test