1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/tkt1644.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,111 @@
1.4 +# 2006 January 30
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +# This file implements regression tests for SQLite library.
1.15 +#
1.16 +# This file implements tests to verify that ticket #1644 is
1.17 +# fixed. Ticket #1644 complains that precompiled statements
1.18 +# are not expired correctly as a result of changes to TEMP
1.19 +# views and triggers.
1.20 +#
1.21 +
1.22 +set testdir [file dirname $argv0]
1.23 +source $testdir/tester.tcl
1.24 +
1.25 +ifcapable !tempdb||!view {
1.26 + finish_test
1.27 + return
1.28 +}
1.29 +
1.30 +# Create two tables T1 and T2 and make V1 point to T1.
1.31 +do_test tkt1644-1.1 {
1.32 + execsql {
1.33 + CREATE TABLE t1(a);
1.34 + INSERT INTO t1 VALUES(1);
1.35 + CREATE TABLE t2(b);
1.36 + INSERT INTO t2 VALUES(99);
1.37 + CREATE TEMP VIEW v1 AS SELECT * FROM t1;
1.38 + SELECT * FROM v1;
1.39 + }
1.40 +} {1}
1.41 +
1.42 +# The "SELECT * FROM v1" should be in the TCL interface cache below.
1.43 +# It will continue to point to T1 unless the cache is invalidated when
1.44 +# the view changes.
1.45 +#
1.46 +do_test tkt1644-1.2 {
1.47 + execsql {
1.48 + DROP VIEW v1;
1.49 + CREATE TEMP VIEW v1 AS SELECT * FROM t2;
1.50 + SELECT * FROM v1;
1.51 + }
1.52 +} {99}
1.53 +
1.54 +# Cache an access to the T1 table.
1.55 +#
1.56 +do_test tkt1644-1.3 {
1.57 + execsql {
1.58 + SELECT * FROM t1;
1.59 + }
1.60 +} {1}
1.61 +
1.62 +# Create a temp table T1. Make sure the cache is invalidated so that
1.63 +# the statement is recompiled and refers to the empty temp table.
1.64 +#
1.65 +do_test tkt1644-1.4 {
1.66 + execsql {
1.67 + CREATE TEMP TABLE t1(x);
1.68 + }
1.69 + execsql {
1.70 + SELECT * FROM t1;
1.71 + }
1.72 +} {}
1.73 +
1.74 +ifcapable view {
1.75 + do_test tkt1644-2.1 {
1.76 + execsql {
1.77 + CREATE TEMP TABLE temp_t1(a, b);
1.78 + }
1.79 + set ::DB [sqlite3_connection_pointer db]
1.80 + set ::STMT [sqlite3_prepare $::DB "SELECT * FROM temp_t1" -1 DUMMY]
1.81 + execsql {
1.82 + DROP TABLE temp_t1;
1.83 + }
1.84 + list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]
1.85 + } {SQLITE_ERROR SQLITE_SCHEMA}
1.86 +
1.87 + do_test tkt1644-2.2 {
1.88 + execsql {
1.89 + CREATE TABLE real_t1(a, b);
1.90 + CREATE TEMP VIEW temp_v1 AS SELECT * FROM real_t1;
1.91 + }
1.92 + set ::DB [sqlite3_connection_pointer db]
1.93 + set ::STMT [sqlite3_prepare $::DB "SELECT * FROM temp_v1" -1 DUMMY]
1.94 + execsql {
1.95 + DROP VIEW temp_v1;
1.96 + }
1.97 + list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]
1.98 + } {SQLITE_ERROR SQLITE_SCHEMA}
1.99 +
1.100 + do_test tkt1644-2.3 {
1.101 + execsql {
1.102 + CREATE TEMP VIEW temp_v1 AS SELECT * FROM real_t1 LIMIT 10 OFFSET 10;
1.103 + }
1.104 + set ::DB [sqlite3_connection_pointer db]
1.105 + set ::STMT [sqlite3_prepare $::DB "SELECT * FROM temp_v1" -1 DUMMY]
1.106 + execsql {
1.107 + DROP VIEW temp_v1;
1.108 + }
1.109 + list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]
1.110 + } {SQLITE_ERROR SQLITE_SCHEMA}
1.111 +}
1.112 +
1.113 +
1.114 +finish_test