Add a test for the fixes on this branch.
[sqlite.git] / test / rowvaluefault.test
bloba06ef886e96e297f8d7f9979f9ccef41a082299c
1 # 2016 June 17
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.  
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 source $testdir/malloc_common.tcl
18 set ::testprefix rowvaluefault
20 do_execsql_test 1.0 {
21   CREATE TABLE xyz(one, two, thr, fou);
22   INSERT INTO xyz VALUES('A', 'A', 'A',  1);
23   INSERT INTO xyz VALUES('B', 'B', 'B',  2);
24   INSERT INTO xyz VALUES('C', 'C', 'C',  3);
25   INSERT INTO xyz VALUES('D', 'D', 'D',  4);
27   CREATE UNIQUE INDEX xyz_one_two ON xyz(one, two);
30 do_faultsim_test 1 -faults oom* -body {
31   execsql { SELECT fou FROM xyz WHERE (one, two, thr) = ('B', 'B', 'B') }
32 } -test {
33   faultsim_test_result {0 2} 
36 do_faultsim_test 2 -faults oom* -body {
37   execsql { SELECT fou FROM xyz WHERE (two, thr) IS ('C', 'C') }
38 } -test {
39   faultsim_test_result {0 3} 
42 do_faultsim_test 3 -faults oom* -body {
43   execsql { SELECT fou FROM xyz WHERE (one, two, thr) > ('B', 'B', 'B') }
44 } -test {
45   faultsim_test_result {0 {3 4}} 
48 do_faultsim_test 4 -faults oom* -body {
49   execsql { SELECT fou FROM xyz WHERE (one, two) IN (SELECT one, two FROM xyz) }
50 } -test {
51   faultsim_test_result {0 {1 2 3 4}} 
54 do_faultsim_test 5 -faults oom* -body {
55   execsql { 
56     SELECT fou FROM xyz 
57     WHERE (one, two, thr) IN (SELECT one, two, thr FROM xyz) 
58   }
59 } -test {
60   faultsim_test_result {0 {1 2 3 4}} 
63 do_faultsim_test 6 -faults oom* -body {
64   execsql { 
65     SELECT fou FROM xyz 
66     WHERE (one, two, thr) BETWEEN ('B', 'B', 'B') AND ('C', 'C', 'C') }
67 } -test {
68   faultsim_test_result {0 {2 3}} 
71 do_faultsim_test 7 -faults oom* -body {
72   execsql { 
73     SELECT fou FROM xyz 
74     WHERE (one, two, thr) IN ( ('a','b','c'), ('A','A','A'), (1,2,3) );
75   }
76 } -test {
77   faultsim_test_result {0 1}
80 do_faultsim_test 8 -faults oom* -body {
81   execsql { 
82     SELECT fou FROM xyz 
83     WHERE (two, one) IN ( ('a','b','c'), ('A','A','A'), (1,2,3) );
84   }
85 } -test {
86   faultsim_test_result {1 {IN(...) element has 3 terms - expected 2}}
89 finish_test