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 set ::TMPDBERROR [list 1 \
30 {unable to open a temporary database file for storing temporary tables}
34 do_faultsim_test 1 -prep {
35 faultsim_restore_and_reopen
38 ALTER TABLE t1 RENAME abcd TO dcba
41 faultsim_test_result {0 {}} $::TMPDBERROR
48 PRAGMA encoding = 'utf-16';
49 CREATE TABLE t1(abcd, efgh);
51 faultsim_save_and_close
53 do_faultsim_test 2 -prep {
54 faultsim_restore_and_reopen
57 ALTER TABLE t1 RENAME abcd TO dcba
60 faultsim_test_result {0 {}} $::TMPDBERROR
66 CREATE TABLE t1(abcd, efgh);
67 CREATE VIEW v1 AS SELECT * FROM t1 WHERE abcd>efgh;
69 faultsim_save_and_close
71 do_faultsim_test 3 -prep {
72 faultsim_restore_and_reopen
75 ALTER TABLE t1 RENAME abcd TO dcba
78 faultsim_test_result {0 {}} $::TMPDBERROR
83 CREATE TABLE rr(a, b);
84 CREATE VIEW vv AS SELECT * FROM rr;
86 CREATE TRIGGER vv1 INSTEAD OF INSERT ON vv BEGIN
89 CREATE TRIGGER tr1 AFTER INSERT ON rr BEGIN
90 INSERT INTO vv VALUES(new.a, new.b);
94 faultsim_save_and_close
95 do_faultsim_test 4 -faults oom-* -prep {
96 faultsim_restore_and_reopen
97 execsql { SELECT * FROM sqlite_master }
100 ALTER TABLE rr RENAME a TO c;
103 faultsim_test_result {0 {}} $::TMPDBERROR
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)
115 faultsim_save_and_close
116 do_faultsim_test 5 -faults oom-* -prep {
117 faultsim_restore_and_reopen
118 execsql { SELECT * FROM sqlite_master }
121 ALTER TABLE rr RENAME TO c;
124 faultsim_test_result {0 {}} $::TMPDBERROR