sl@0
|
1 |
# 2006 January 30
|
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.
|
sl@0
|
12 |
#
|
sl@0
|
13 |
# This file implements tests to verify that ticket #1644 is
|
sl@0
|
14 |
# fixed. Ticket #1644 complains that precompiled statements
|
sl@0
|
15 |
# are not expired correctly as a result of changes to TEMP
|
sl@0
|
16 |
# views and triggers.
|
sl@0
|
17 |
#
|
sl@0
|
18 |
|
sl@0
|
19 |
set testdir [file dirname $argv0]
|
sl@0
|
20 |
source $testdir/tester.tcl
|
sl@0
|
21 |
|
sl@0
|
22 |
ifcapable !tempdb||!view {
|
sl@0
|
23 |
finish_test
|
sl@0
|
24 |
return
|
sl@0
|
25 |
}
|
sl@0
|
26 |
|
sl@0
|
27 |
# Create two tables T1 and T2 and make V1 point to T1.
|
sl@0
|
28 |
do_test tkt1644-1.1 {
|
sl@0
|
29 |
execsql {
|
sl@0
|
30 |
CREATE TABLE t1(a);
|
sl@0
|
31 |
INSERT INTO t1 VALUES(1);
|
sl@0
|
32 |
CREATE TABLE t2(b);
|
sl@0
|
33 |
INSERT INTO t2 VALUES(99);
|
sl@0
|
34 |
CREATE TEMP VIEW v1 AS SELECT * FROM t1;
|
sl@0
|
35 |
SELECT * FROM v1;
|
sl@0
|
36 |
}
|
sl@0
|
37 |
} {1}
|
sl@0
|
38 |
|
sl@0
|
39 |
# The "SELECT * FROM v1" should be in the TCL interface cache below.
|
sl@0
|
40 |
# It will continue to point to T1 unless the cache is invalidated when
|
sl@0
|
41 |
# the view changes.
|
sl@0
|
42 |
#
|
sl@0
|
43 |
do_test tkt1644-1.2 {
|
sl@0
|
44 |
execsql {
|
sl@0
|
45 |
DROP VIEW v1;
|
sl@0
|
46 |
CREATE TEMP VIEW v1 AS SELECT * FROM t2;
|
sl@0
|
47 |
SELECT * FROM v1;
|
sl@0
|
48 |
}
|
sl@0
|
49 |
} {99}
|
sl@0
|
50 |
|
sl@0
|
51 |
# Cache an access to the T1 table.
|
sl@0
|
52 |
#
|
sl@0
|
53 |
do_test tkt1644-1.3 {
|
sl@0
|
54 |
execsql {
|
sl@0
|
55 |
SELECT * FROM t1;
|
sl@0
|
56 |
}
|
sl@0
|
57 |
} {1}
|
sl@0
|
58 |
|
sl@0
|
59 |
# Create a temp table T1. Make sure the cache is invalidated so that
|
sl@0
|
60 |
# the statement is recompiled and refers to the empty temp table.
|
sl@0
|
61 |
#
|
sl@0
|
62 |
do_test tkt1644-1.4 {
|
sl@0
|
63 |
execsql {
|
sl@0
|
64 |
CREATE TEMP TABLE t1(x);
|
sl@0
|
65 |
}
|
sl@0
|
66 |
execsql {
|
sl@0
|
67 |
SELECT * FROM t1;
|
sl@0
|
68 |
}
|
sl@0
|
69 |
} {}
|
sl@0
|
70 |
|
sl@0
|
71 |
ifcapable view {
|
sl@0
|
72 |
do_test tkt1644-2.1 {
|
sl@0
|
73 |
execsql {
|
sl@0
|
74 |
CREATE TEMP TABLE temp_t1(a, b);
|
sl@0
|
75 |
}
|
sl@0
|
76 |
set ::DB [sqlite3_connection_pointer db]
|
sl@0
|
77 |
set ::STMT [sqlite3_prepare $::DB "SELECT * FROM temp_t1" -1 DUMMY]
|
sl@0
|
78 |
execsql {
|
sl@0
|
79 |
DROP TABLE temp_t1;
|
sl@0
|
80 |
}
|
sl@0
|
81 |
list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]
|
sl@0
|
82 |
} {SQLITE_ERROR SQLITE_SCHEMA}
|
sl@0
|
83 |
|
sl@0
|
84 |
do_test tkt1644-2.2 {
|
sl@0
|
85 |
execsql {
|
sl@0
|
86 |
CREATE TABLE real_t1(a, b);
|
sl@0
|
87 |
CREATE TEMP VIEW temp_v1 AS SELECT * FROM real_t1;
|
sl@0
|
88 |
}
|
sl@0
|
89 |
set ::DB [sqlite3_connection_pointer db]
|
sl@0
|
90 |
set ::STMT [sqlite3_prepare $::DB "SELECT * FROM temp_v1" -1 DUMMY]
|
sl@0
|
91 |
execsql {
|
sl@0
|
92 |
DROP VIEW temp_v1;
|
sl@0
|
93 |
}
|
sl@0
|
94 |
list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]
|
sl@0
|
95 |
} {SQLITE_ERROR SQLITE_SCHEMA}
|
sl@0
|
96 |
|
sl@0
|
97 |
do_test tkt1644-2.3 {
|
sl@0
|
98 |
execsql {
|
sl@0
|
99 |
CREATE TEMP VIEW temp_v1 AS SELECT * FROM real_t1 LIMIT 10 OFFSET 10;
|
sl@0
|
100 |
}
|
sl@0
|
101 |
set ::DB [sqlite3_connection_pointer db]
|
sl@0
|
102 |
set ::STMT [sqlite3_prepare $::DB "SELECT * FROM temp_v1" -1 DUMMY]
|
sl@0
|
103 |
execsql {
|
sl@0
|
104 |
DROP VIEW temp_v1;
|
sl@0
|
105 |
}
|
sl@0
|
106 |
list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]
|
sl@0
|
107 |
} {SQLITE_ERROR SQLITE_SCHEMA}
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
|
sl@0
|
111 |
finish_test
|