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

     1  # 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  
    16  set testdir [file dirname $argv0]
    17  source $testdir/tester.tcl
    18  set testprefix existsfault
    19  
    20  do_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  }
    36  faultsim_save_and_close
    37  
    38  do_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  
    51  finish_test
    52