blob: 24e44a7b585b0f96ae385dfedb8f5be5730762f1 [file] [log] [blame]
danf7588d42021-01-15 17:51:56 +00001# 2021 January 15
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. The
12# focus of this file is testing cases where EXISTS expressions are
13# transformed to IN() expressions by where.c
14#
15
16set testdir [file dirname $argv0]
17source $testdir/tester.tcl
18set testprefix existsfault
19
20do_execsql_test 1 {
21 CREATE TABLE t1(a PRIMARY KEY, b);
22 INSERT INTO t1 VALUES(1, 'one');
23 INSERT INTO t1 VALUES(2, 'two');
24 INSERT INTO t1 VALUES(3, 'three');
25 INSERT INTO t1 VALUES(4, 'four');
26 INSERT INTO t1 VALUES(5, 'five');
27 INSERT INTO t1 VALUES(6, 'six');
28 INSERT INTO t1 VALUES(7, 'seven');
29
30 CREATE TABLE t2(c INTEGER, d INTEGER);
31 INSERT INTO t2 VALUES(1, 1);
32 INSERT INTO t2 VALUES(3, 2);
33 INSERT INTO t2 VALUES(5, 3);
34 INSERT INTO t2 VALUES(7, 4);
35}
36faultsim_save_and_close
37
38do_faultsim_test 1 -prep {
39 faultsim_restore_and_reopen
40} -body {
41 execsql {
42 SELECT t1.* FROM t1 WHERE EXISTS(
43 SELECT * FROM t2 WHERE t2.c=t1.a AND d IN (1, 2, 3)
44 )
45 }
46} -test {
47 faultsim_test_result {0 {1 one 3 three 5 five}}
48}
49
50
51finish_test
52