summaryrefslogtreecommitdiffstats
path: root/test/tkt-f7b4edec.test
blob: d21da31917e81e4ed60a503d5367df7ce27bc99c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# 2011 March 18
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests to verify that ticket 
# [f7b4edece25c994857dc139207f55a53c8319fae] has been fixed.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable !shared_cache { finish_test ; return }

# Open two database connections to the same database file in
# shared cache mode.  Create update hooks that will fire on
# each connection.
#
db close
set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
sqlite3 db1 test.db
sqlite3 db2 test.db
unset -nocomplain HOOKS
set HOOKS {}
proc update_hook {args} { lappend ::HOOKS $args }
db1 update_hook update_hook
db2 update_hook update_hook

# Create a prepared statement
#
do_test tkt-f7b4edec-1 {
  execsql { CREATE TABLE t1(x, y); } db1
  execsql { INSERT INTO t1 VALUES(1, 2) } db1
  set ::HOOKS
} {{INSERT main t1 1}}

# In the second database connection cause the schema to be reparsed
# without changing the schema cookie.
#
set HOOKS {}
do_test tkt-f7b4edec-2 {
  execsql {
    BEGIN;
      DROP TABLE t1;
      CREATE TABLE t1(x, y);
    ROLLBACK;
  } db2
  set ::HOOKS
} {}

# Rerun the prepared statement that was created prior to the 
# schema reparse.  Verify that the update-hook gives the correct
# output.
#
set HOOKS {}
do_test tkt-f7b4edec-3 {
  execsql { INSERT INTO t1 VALUES(1, 2) } db1
  set ::HOOKS
} {{INSERT main t1 2}}

# Be sure to restore the original shared-cache mode setting before
# returning.
#
db1 close
db2 close
sqlite3_enable_shared_cache $::enable_shared_cache


finish_test