github.com/jdgcs/sqlite3@v1.12.1-0.20210908114423-bc5f96e4dd51/testdata/tcl/altermalloc2.test (about) 1 # 2018 August 20 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 # 12 13 set testdir [file dirname $argv0] 14 source $testdir/tester.tcl 15 source $testdir/malloc_common.tcl 16 set testprefix altermalloc2 17 18 # If SQLITE_OMIT_ALTERTABLE is defined, omit this file. 19 ifcapable !altertable { 20 finish_test 21 return 22 } 23 24 do_execsql_test 1.0 { 25 CREATE TABLE t1(abcd, efgh); 26 } 27 faultsim_save_and_close 28 29 do_faultsim_test 1 -prep { 30 faultsim_restore_and_reopen 31 } -body { 32 execsql { 33 ALTER TABLE t1 RENAME abcd TO dcba 34 } 35 } -test { 36 faultsim_test_result {0 {}} 37 } 38 39 catch {db close} 40 forcedelete test.db 41 sqlite3 db test.db 42 do_execsql_test 2.0 { 43 PRAGMA encoding = 'utf-16'; 44 CREATE TABLE t1(abcd, efgh); 45 } 46 faultsim_save_and_close 47 48 do_faultsim_test 2 -prep { 49 faultsim_restore_and_reopen 50 } -body { 51 execsql { 52 ALTER TABLE t1 RENAME abcd TO dcba 53 } 54 } -test { 55 faultsim_test_result {0 {}} 56 } 57 58 59 reset_db 60 do_execsql_test 3.0 { 61 CREATE TABLE t1(abcd, efgh); 62 CREATE VIEW v1 AS SELECT * FROM t1 WHERE abcd>efgh; 63 } 64 faultsim_save_and_close 65 66 do_faultsim_test 3 -prep { 67 faultsim_restore_and_reopen 68 } -body { 69 execsql { 70 ALTER TABLE t1 RENAME abcd TO dcba 71 } 72 } -test { 73 faultsim_test_result {0 {}} 74 } 75 76 reset_db 77 do_execsql_test 4.0 { 78 CREATE TABLE rr(a, b); 79 CREATE VIEW vv AS SELECT * FROM rr; 80 81 CREATE TRIGGER vv1 INSTEAD OF INSERT ON vv BEGIN 82 SELECT 1, 2, 3; 83 END; 84 CREATE TRIGGER tr1 AFTER INSERT ON rr BEGIN 85 INSERT INTO vv VALUES(new.a, new.b); 86 END; 87 } {} 88 89 faultsim_save_and_close 90 do_faultsim_test 4 -faults oom-* -prep { 91 faultsim_restore_and_reopen 92 execsql { SELECT * FROM sqlite_master } 93 } -body { 94 execsql { 95 ALTER TABLE rr RENAME a TO c; 96 } 97 } -test { 98 faultsim_test_result {0 {}} 99 } 100 101 reset_db 102 do_execsql_test 5.0 { 103 CREATE TABLE rr(a, b); 104 CREATE VIEW vv AS SELECT * FROM ( 105 WITH abc(d, e) AS (SELECT * FROM rr) 106 SELECT * FROM abc 107 ); 108 } {} 109 110 faultsim_save_and_close 111 do_faultsim_test 5 -faults oom-* -prep { 112 faultsim_restore_and_reopen 113 execsql { SELECT * FROM sqlite_master } 114 } -body { 115 execsql { 116 ALTER TABLE rr RENAME TO c; 117 } 118 } -test { 119 faultsim_test_result {0 {}} 120 } 121 122 finish_test