blob: 0ee511ff341a7b4b2fc9f0a9bda9acd236b00392 [file] [log] [blame]
dana4b5fb52018-08-03 20:19:52 +00001# 2018-08-04
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11#
12#
13
14set testdir [file dirname $argv0]
15source $testdir/tester.tcl
16source $testdir/malloc_common.tcl
17set testprefix countofview
18
19do_execsql_test 1.0 {
20 CREATE TABLE t2(c);
21 CREATE TABLE t3(f);
22
23 INSERT INTO t2 VALUES(1), (2);
24 INSERT INTO t3 VALUES(3);
25}
26
27do_execsql_test 1.1 {
28 select c from t2 union all select f from t3 limit 1 offset 1
29} {2}
30
31do_execsql_test 1.2 {
32 select count(*) from (
33 select c from t2 union all select f from t3 limit 1 offset 1
34 )
35} {1}
36
37do_execsql_test 1.3 {
38 select count(*) from (
39 select c from t2 union all select f from t3
40 )
41} {3}
42
drh73c53b32019-05-15 18:42:15 +000043# 2019-05-15
44do_execsql_test 2.0 {
45 CREATE TABLE t1(x);
46 INSERT INTO t1 VALUES(1),(99),('abc');
47 CREATE VIEW v1(x,y) AS SELECT x,1 FROM t1 UNION ALL SELECT x,2 FROM t1;
48 SELECT count(*) FROM v1 WHERE x<>1;
49} {4}
50do_execsql_test 2.1 {
51 SELECT count(*) FROM v1 GROUP BY y;
52} {3 3}
53
54
55
dana4b5fb52018-08-03 20:19:52 +000056finish_test