xref: /sqlite-3.40.0/test/tkt-c694113d5.test (revision ba968dbf)
1# 2018-07-24
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. Specifically,
12# it tests that ticket [c694113e50321afdf952e2d1235b08ba663f8399]:
13#
14
15set testdir [file dirname $argv0]
16source $testdir/tester.tcl
17
18do_test tkt-c694113d5.100 {
19  sqlite3 db :memory:
20  db eval {
21    CREATE TABLE t1(a INTEGER PRIMARY KEY);
22    CREATE TABLE t2(d INTEGER PRIMARY KEY,e,f);
23    INSERT INTO t1(a) VALUES(1),(2),(3),(4);
24  }
25  set answer {}
26  db eval {SELECT a FROM t1 WHERE NOT EXISTS(SELECT 1 FROM t2 WHERE d=a)} {
27    if {$a==3} {
28      lappend answer "CREATE INDEX"
29      db eval {CREATE INDEX t2e ON t2(e);}
30    }
31    lappend answer "a=$a"
32  }
33  set answer
34} {a=1 a=2 {CREATE INDEX} a=3 a=4}
35
36finish_test
37