sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
| 1 | # 2026 June 4 |
| 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. |
| 12 | # |
| 13 | |
| 14 | set testdir [file dirname $argv0] |
| 15 | source $testdir/tester.tcl |
| 16 | set testprefix nulls2 |
| 17 | |
| 18 | foreach {tn idx} { |
| 19 | 1 {} |
| 20 | 2 { CREATE INDEX i1 ON t1(a, b, c) } |
| 21 | 3 { CREATE INDEX i1 ON t1(b, c, a) } |
| 22 | 4 { CREATE INDEX i1 ON t1(c, a, b) } |
| 23 | 5 { CREATE INDEX i1 ON t1(c, b, a) } |
| 24 | } { |
| 25 | reset_db |
| 26 | |
| 27 | do_execsql_test 1.$tn.0 { |
| 28 | CREATE TABLE t1(a, b, c); |
| 29 | |
| 30 | INSERT INTO t1 VALUES(1, 1, NULL); |
| 31 | INSERT INTO t1 VALUES(2, 2, NULL); |
| 32 | |
| 33 | CREATE TABLE t2(d NOT NULL, e NOT NULL, f); |
| 34 | INSERT INTO t2 VALUES(1, 1, NULL); |
| 35 | INSERT INTO t2 VALUES(2, 2, NULL); |
| 36 | } |
| 37 | |
| 38 | execsql $idx |
| 39 | |
| 40 | # This should return zero rows, as "f" is always NULL. |
| 41 | # |
| 42 | do_execsql_test 1.$tn.1 { |
| 43 | SELECT rowid FROM t2 WHERE (d, e, f) IN ( |
| 44 | SELECT a, b, c FROM t1 |
| 45 | ) |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | foreach {tn idx} { |
| 50 | 1 {} |
| 51 | 2 { CREATE INDEX i1 ON t1(a, b, c) } |
| 52 | 3 { CREATE INDEX i1 ON t1(b, c, a) } |
| 53 | 4 { CREATE INDEX i1 ON t1(c, a, b) } |
| 54 | 5 { CREATE INDEX i1 ON t1(c, b, a) } |
| 55 | } { |
| 56 | reset_db |
| 57 | |
| 58 | do_execsql_test 2.$tn.0 { |
| 59 | CREATE TABLE t1(a, b, c COLLATE nocase); |
| 60 | INSERT INTO t1 VALUES('one', 'two', 'THREE'); |
| 61 | INSERT INTO t1 VALUES('four', 'five', 'SIX'); |
| 62 | } |
| 63 | |
| 64 | execsql $idx |
| 65 | |
| 66 | do_execsql_test 1.$tn.1 { |
| 67 | SELECT (NULL, 'two', 'three') IN ( |
| 68 | SELECT a, b, c FROM t1 |
| 69 | ) IS NULL |
| 70 | } 1 |
| 71 | } |
| 72 | |
| 73 | |
| 74 | finish_test |