xref: /sqlite-3.40.0/ext/rtree/rtreeconnect.test (revision 865c3c58)
1*865c3c58Sdan# 2017 August 17
2*865c3c58Sdan#
3*865c3c58Sdan# The author disclaims copyright to this source code.  In place of
4*865c3c58Sdan# a legal notice, here is a blessing:
5*865c3c58Sdan#
6*865c3c58Sdan#    May you do good and not evil.
7*865c3c58Sdan#    May you find forgiveness for yourself and forgive others.
8*865c3c58Sdan#    May you share freely, never taking more than you give.
9*865c3c58Sdan#
10*865c3c58Sdan#***********************************************************************
11*865c3c58Sdan#
12*865c3c58Sdan# The focus of this file is testing the r-tree extension. Specifically,
13*865c3c58Sdan# the impact of an SQLITE_SCHEMA error within the rtree module xConnect
14*865c3c58Sdan# callback.
15*865c3c58Sdan#
16*865c3c58Sdan
17*865c3c58Sdan
18*865c3c58Sdanif {![info exists testdir]} {
19*865c3c58Sdan  set testdir [file join [file dirname [info script]] .. .. test]
20*865c3c58Sdan}
21*865c3c58Sdansource $testdir/tester.tcl
22*865c3c58Sdanset testprefix rtreeconnect
23*865c3c58Sdan
24*865c3c58Sdanifcapable !rtree {
25*865c3c58Sdan  finish_test
26*865c3c58Sdan  return
27*865c3c58Sdan}
28*865c3c58Sdan
29*865c3c58Sdando_execsql_test 1.0 {
30*865c3c58Sdan  CREATE VIRTUAL TABLE r1 USING rtree(id, x1, x2, y1, y2);
31*865c3c58Sdan  CREATE TABLE t1(id, x1, x2, y1, y2);
32*865c3c58Sdan  CREATE TABLE log(l);
33*865c3c58Sdan
34*865c3c58Sdan  CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
35*865c3c58Sdan    INSERT INTO r1 VALUES(new.id, new.x1, new.x2, new.y1, new.y2);
36*865c3c58Sdan    INSERT INTO log VALUES('r1: ' || new.id);
37*865c3c58Sdan  END;
38*865c3c58Sdan}
39*865c3c58Sdan
40*865c3c58Sdandb close
41*865c3c58Sdansqlite3 db  test.db
42*865c3c58Sdansqlite3 db2 test.db
43*865c3c58Sdan
44*865c3c58Sdando_test 1.1 {
45*865c3c58Sdan  db eval { INSERT INTO log VALUES('startup'); }
46*865c3c58Sdan  db2 eval { CREATE TABLE newtable(x,y); }
47*865c3c58Sdan} {}
48*865c3c58Sdan
49*865c3c58Sdando_execsql_test 1.2 {
50*865c3c58Sdan  INSERT INTO t1 VALUES(1, 2, 3, 4, 5);
51*865c3c58Sdan}
52*865c3c58Sdan
53*865c3c58Sdandb2 close
54*865c3c58Sdandb close
55*865c3c58Sdan
56*865c3c58Sdanfinish_test
57