1*713f34acSdrh# 2018-02-15 2*713f34acSdrh# 3*713f34acSdrh# The author disclaims copyright to this source code. In place of 4*713f34acSdrh# a legal notice, here is a blessing: 5*713f34acSdrh# 6*713f34acSdrh# May you do good and not evil. 7*713f34acSdrh# May you find forgiveness for yourself and forgive others. 8*713f34acSdrh# May you share freely, never taking more than you give. 9*713f34acSdrh# 10*713f34acSdrh#*********************************************************************** 11*713f34acSdrh# This file implements regression tests for SQLite library. The 12*713f34acSdrh# focus of this file is testing the WITH clause in TRIGGERs and VIEWs. 13*713f34acSdrh# 14*713f34acSdrh 15*713f34acSdrhset testdir [file dirname $argv0] 16*713f34acSdrhsource $testdir/tester.tcl 17*713f34acSdrhset ::testprefix with4 18*713f34acSdrh 19*713f34acSdrhifcapable {!cte} { 20*713f34acSdrh finish_test 21*713f34acSdrh return 22*713f34acSdrh} 23*713f34acSdrh 24*713f34acSdrhdo_execsql_test 100 { 25*713f34acSdrh ATTACH ':memory:' AS aux; 26*713f34acSdrh CREATE TABLE main.t1(a,b); 27*713f34acSdrh CREATE TABLE aux.t2(x,y); 28*713f34acSdrh INSERT INTO t1 VALUES(1,2); 29*713f34acSdrh INSERT INTO t2 VALUES(3,4); 30*713f34acSdrh} {} 31*713f34acSdrhdo_catchsql_test 110 { 32*713f34acSdrh CREATE VIEW v1 AS SELECT * FROM t1, aux.t2; 33*713f34acSdrh} {1 {view v1 cannot reference objects in database aux}} 34*713f34acSdrhdo_catchsql_test 120 { 35*713f34acSdrh CREATE VIEW v2 AS WITH v(m,n) AS (SELECT x,y FROM aux.t2) SELECT * FROM t1, v; 36*713f34acSdrh} {1 {view v2 cannot reference objects in database aux}} 37*713f34acSdrhdo_catchsql_test 130 { 38*713f34acSdrh CREATE VIEW v2 AS WITH v(m,n) AS (SELECT 5,?2) SELECT * FROM t1, v; 39*713f34acSdrh} {1 {parameters are not allowed in views}} 40*713f34acSdrh 41*713f34acSdrhdo_catchsql_test 200 { 42*713f34acSdrh CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN 43*713f34acSdrh WITH v(m,n) AS (SELECT x,y FROM aux.t2) SELECT * FROM t1, v; 44*713f34acSdrh END; 45*713f34acSdrh} {1 {trigger r1 cannot reference objects in database aux}} 46*713f34acSdrhdo_catchsql_test 210 { 47*713f34acSdrh CREATE TRIGGER r1 AFTER INSERT ON t1 BEGIN 48*713f34acSdrh WITH v(m,n) AS (SELECT 5,?2) SELECT * FROM t1, v; 49*713f34acSdrh END; 50*713f34acSdrh} {1 {trigger cannot use variables}} 51*713f34acSdrh 52*713f34acSdrhfinish_test 53