xref: /sqlite-3.40.0/test/select7.test (revision 8cdbf836)
1# The author disclaims copyright to this source code.  In place of
2# a legal notice, here is a blessing:
3#
4#    May you do good and not evil.
5#    May you find forgiveness for yourself and forgive others.
6#    May you share freely, never taking more than you give.
7#
8#***********************************************************************
9# This file implements regression tests for SQLite library.  The
10# focus of this file is testing compute SELECT statements and nested
11# views.
12#
13# $Id: select7.test,v 1.1 2004/08/29 16:25:04 drh Exp $
14
15
16set testdir [file dirname $argv0]
17source $testdir/tester.tcl
18
19# A 3-way INTERSECT.  Ticket #875
20do_test select7-1.1 {
21  execsql {
22    create temp table t1(x);
23    insert into t1 values('amx');
24    insert into t1 values('anx');
25    insert into t1 values('amy');
26    insert into t1 values('bmy');
27    select * from t1 where x like 'a__'
28      intersect select * from t1 where x like '_m_'
29      intersect select * from t1 where x like '__x';
30  }
31} {amx}
32
33
34# Nested views do not handle * properly.  Ticket #826.
35#
36do_test select7-2.1 {
37  execsql {
38    CREATE TABLE x(id integer primary key, a TEXT NULL);
39    INSERT INTO x (a) VALUES ('first');
40    CREATE TABLE tempx(id integer primary key, a TEXT NULL);
41    INSERT INTO tempx (a) VALUES ('t-first');
42    CREATE VIEW tv1 AS SELECT x.id, tx.id FROM x JOIN tempx tx ON tx.id=x.id;
43    CREATE VIEW tv1b AS SELECT x.id, tx.id FROM x JOIN tempx tx on tx.id=x.id;
44    CREATE VIEW tv2 AS SELECT * FROM tv1 UNION SELECT * FROM tv1b;
45    SELECT * FROM tv2;
46  }
47} {1 1}
48
49
50finish_test
51