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 #*************************************************************************
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 source $testdir/malloc_common.tcl
16 set testprefix altermalloc2
18 # If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
19 ifcapable !altertable {
25 CREATE TABLE t1(abcd, efgh);
27 faultsim_save_and_close
29 do_faultsim_test 1 -prep {
30 faultsim_restore_and_reopen
33 ALTER TABLE t1 RENAME abcd TO dcba
36 faultsim_test_result {0 {}}
43 PRAGMA encoding = 'utf-16';
44 CREATE TABLE t1(abcd, efgh);
46 faultsim_save_and_close
48 do_faultsim_test 2 -prep {
49 faultsim_restore_and_reopen
52 ALTER TABLE t1 RENAME abcd TO dcba
55 faultsim_test_result {0 {}}
61 CREATE TABLE t1(abcd, efgh);
62 CREATE VIEW v1 AS SELECT * FROM t1 WHERE abcd>efgh;
64 faultsim_save_and_close
66 do_faultsim_test 3 -prep {
67 faultsim_restore_and_reopen
70 ALTER TABLE t1 RENAME abcd TO dcba
73 faultsim_test_result {0 {}}
78 CREATE TABLE rr(a, b);
79 CREATE VIEW vv AS SELECT * FROM rr;
81 CREATE TRIGGER vv1 INSTEAD OF INSERT ON vv BEGIN
84 CREATE TRIGGER tr1 AFTER INSERT ON rr BEGIN
85 INSERT INTO vv VALUES(new.a, new.b);
89 faultsim_save_and_close
90 do_faultsim_test 4 -faults oom-* -prep {
91 faultsim_restore_and_reopen
92 execsql { SELECT * FROM sqlite_master }
95 ALTER TABLE rr RENAME a TO c;
98 faultsim_test_result {0 {}}