xref: /sqlite-3.40.0/test/view2.test (revision 90bc36fb)
1*90bc36fbSdan# 2021 May 20
2*90bc36fbSdan#
3*90bc36fbSdan# The author disclaims copyright to this source code.  In place of
4*90bc36fbSdan# a legal notice, here is a blessing:
5*90bc36fbSdan#
6*90bc36fbSdan#    May you do good and not evil.
7*90bc36fbSdan#    May you find forgiveness for yourself and forgive others.
8*90bc36fbSdan#    May you share freely, never taking more than you give.
9*90bc36fbSdan#
10*90bc36fbSdan#***********************************************************************
11*90bc36fbSdan# This file implements regression tests for SQLite library.  The
12*90bc36fbSdan# focus of this file is testing VIEW statements.
13*90bc36fbSdan#
14*90bc36fbSdan# $Id: view.test,v 1.39 2008/12/14 14:45:21 danielk1977 Exp $
15*90bc36fbSdanset testdir [file dirname $argv0]
16*90bc36fbSdansource $testdir/tester.tcl
17*90bc36fbSdan
18*90bc36fbSdan# Omit this entire file if the library is not configured with views enabled.
19*90bc36fbSdanifcapable !view {
20*90bc36fbSdan  finish_test
21*90bc36fbSdan  return
22*90bc36fbSdan}
23*90bc36fbSdanset testprefix view2
24*90bc36fbSdan
25*90bc36fbSdando_execsql_test 1.0 {
26*90bc36fbSdan  CREATE TABLE t1(x, y);
27*90bc36fbSdan  INSERT INTO t1 VALUES(1, 2);
28*90bc36fbSdan  CREATE VIEW v1 AS SELECT * FROM (
29*90bc36fbSdan    WITH x1 AS (SELECT y, x FROM t1)
30*90bc36fbSdan    SELECT * FROM x1
31*90bc36fbSdan  );
32*90bc36fbSdan}
33*90bc36fbSdan
34*90bc36fbSdando_execsql_test 1.1 {
35*90bc36fbSdan  SELECT * FROM v1
36*90bc36fbSdan} {2 1}
37*90bc36fbSdan
38*90bc36fbSdando_execsql_test 1.2 {
39*90bc36fbSdan  CREATE VIEW v3 AS SELECT * FROM main.t1;
40*90bc36fbSdan  WITH t1(a, b) AS ( SELECT 3, 4 ) SELECT * FROM v3;
41*90bc36fbSdan} {1 2}
42*90bc36fbSdan
43*90bc36fbSdanbreakpoint
44*90bc36fbSdando_execsql_test 1.3 {
45*90bc36fbSdan  CREATE VIEW v2 AS SELECT * FROM t1;
46*90bc36fbSdan  WITH t1(a, b) AS ( SELECT 3, 4 ) SELECT * FROM v2;
47*90bc36fbSdan} {1 2}
48*90bc36fbSdan
49*90bc36fbSdanfinish_test
50