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