github.com/jdgcs/sqlite3@v1.12.1-0.20210908114423-bc5f96e4dd51/testdata/tcl/notnullfault.test (about) 1 # 2021 February 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 optimizations associated with "IS NULL" 13 # and "IS NOT NULL" operators on columns with NOT NULL constraints. 14 # 15 16 set testdir [file dirname $argv0] 17 source $testdir/tester.tcl 18 set testprefix notnullfault 19 20 do_execsql_test 1.0 { 21 CREATE TABLE t1(a, b); 22 CREATE TABLE t2(c, d NOT NULL); 23 } 24 faultsim_save_and_close 25 26 do_faultsim_test 1 -prep { 27 faultsim_restore_and_reopen 28 } -body { 29 execsql { 30 SELECT * FROM t2 WHERE d NOT NULL 31 } 32 } -test { 33 faultsim_test_result {0 {}} 34 } 35 36 #------------------------------------------------------------------------- 37 reset_db 38 do_execsql_test 2.0 { 39 CREATE TABLE t1(a, b, c); 40 CREATE TABLE t2(a, b, c, PRIMARY KEY(a, b, c)) WITHOUT ROWID; 41 } 42 faultsim_save_and_close 43 44 do_faultsim_test 2.1 -faults oom-t* -prep { 45 faultsim_restore_and_reopen 46 } -body { 47 execsql { 48 SELECT dense_rank() OVER win FROM t2 49 WINDOW win AS (ORDER BY c IS NULL) 50 } 51 } -test { 52 faultsim_test_result {0 {}} 53 } 54 55 finish_test