github.com/jdgcs/sqlite3@v1.12.1-0.20210908114423-bc5f96e4dd51/testdata/tcl/countofview.test (about)

     1  # 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  
    14  set testdir [file dirname $argv0]
    15  source $testdir/tester.tcl
    16  source $testdir/malloc_common.tcl
    17  set testprefix countofview
    18  
    19  do_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  
    27  do_execsql_test 1.1 {
    28    select c from t2 union all select f from t3 limit 1 offset 1
    29  } {2}
    30  
    31  do_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  
    37  do_execsql_test 1.3 {
    38    select count(*) from (
    39      select c from t2 union all select f from t3
    40    )
    41  } {3}
    42  
    43  # 2019-05-15
    44  do_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}
    50  do_execsql_test 2.1 {
    51    SELECT count(*) FROM v1 GROUP BY y;
    52  } {3 3}
    53  
    54  
    55  
    56  finish_test