Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/altermalloc2.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / altermalloc2.test` 127 lines ยท 2583 bytes Raw Blame History 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 set ::TMPDBERROR [list 1 \ 30 {unable to open a temporary database file for storing temporary tables} 31 ] 32 33 34 do_faultsim_test 1 -prep { 35 faultsim_restore_and_reopen 36 } -body { 37 execsql { 38 ALTER TABLE t1 RENAME abcd TO dcba 39 } 40 } -test { 41 faultsim_test_result {0 {}} $::TMPDBERROR 42 } 43 44 catch {db close} 45 forcedelete test.db 46 sqlite3 db test.db 47 do_execsql_test 2.0 { 48 PRAGMA encoding = 'utf-16'; 49 CREATE TABLE t1(abcd, efgh); 50 } 51 faultsim_save_and_close 52 53 do_faultsim_test 2 -prep { 54 faultsim_restore_and_reopen 55 } -body { 56 execsql { 57 ALTER TABLE t1 RENAME abcd TO dcba 58 } 59 } -test { 60 faultsim_test_result {0 {}} $::TMPDBERROR 61 } 62 63 64 reset_db 65 do_execsql_test 3.0 { 66 CREATE TABLE t1(abcd, efgh); 67 CREATE VIEW v1 AS SELECT * FROM t1 WHERE abcd>efgh; 68 } 69 faultsim_save_and_close 70 71 do_faultsim_test 3 -prep { 72 faultsim_restore_and_reopen 73 } -body { 74 execsql { 75 ALTER TABLE t1 RENAME abcd TO dcba 76 } 77 } -test { 78 faultsim_test_result {0 {}} $::TMPDBERROR 79 } 80 81 reset_db 82 do_execsql_test 4.0 { 83 CREATE TABLE rr(a, b); 84 CREATE VIEW vv AS SELECT * FROM rr; 85 86 CREATE TRIGGER vv1 INSTEAD OF INSERT ON vv BEGIN 87 SELECT 1, 2, 3; 88 END; 89 CREATE TRIGGER tr1 AFTER INSERT ON rr BEGIN 90 INSERT INTO vv VALUES(new.a, new.b); 91 END; 92 } {} 93 94 faultsim_save_and_close 95 do_faultsim_test 4 -faults oom-* -prep { 96 faultsim_restore_and_reopen 97 execsql { SELECT * FROM sqlite_master } 98 } -body { 99 execsql { 100 ALTER TABLE rr RENAME a TO c; 101 } 102 } -test { 103 faultsim_test_result {0 {}} $::TMPDBERROR 104 } 105 106 reset_db 107 do_execsql_test 5.0 { 108 CREATE TABLE rr(a, b); 109 CREATE VIEW vv AS SELECT * FROM ( 110 WITH abc(d, e) AS (SELECT * FROM rr) 111 SELECT * FROM abc 112 ); 113 } {} 114 115 faultsim_save_and_close 116 do_faultsim_test 5 -faults oom-* -prep { 117 faultsim_restore_and_reopen 118 execsql { SELECT * FROM sqlite_master } 119 } -body { 120 execsql { 121 ALTER TABLE rr RENAME TO c; 122 } 123 } -test { 124 faultsim_test_result {0 {}} $::TMPDBERROR 125 } 126 127 finish_test