xref: /sqlite-3.40.0/test/tkt-18458b1a.test (revision 66c48907)
1# 2019 September 10
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# This file implements regression tests for SQLite library. In particular,
12# that problems related to ticket [18458b1a] have been fixed.
13#
14
15set testdir [file dirname $argv0]
16source $testdir/tester.tcl
17set testprefix tkt-18458b1a
18
19foreach tn {1 2} {
20  reset_db
21  if {$tn==1} {
22    # Disable the flattener and push-down optimizations
23    optimization_control db query-flattener 0
24    optimization_control db push-down 0
25  } else {
26    # Enable them
27    optimization_control db query-flattener 1
28    optimization_control db push-down 1
29  }
30
31  db cache size 0
32
33  do_execsql_test $tn.1.1 {
34    CREATE TABLE t0(c0 COLLATE NOCASE);
35    INSERT INTO t0(c0) VALUES ('B');
36    CREATE VIEW v0(c0, c1) AS SELECT DISTINCT t0.c0, 'a' FROM t0;
37  }
38
39  do_execsql_test $tn.1.2 {
40    SELECT count(*) FROM v0 WHERE c1 >= c0;
41  } 1
42
43  do_execsql_test $tn.1.3 {
44    SELECT count(*) FROM v0 WHERE NOT NOT (c1 >= c0);
45  } 1
46
47  do_execsql_test $tn.1.4 {
48    SELECT count(*) FROM v0 WHERE ((c1 >= c0) OR 0+0);
49  } 1
50}
51
52finish_test
53