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 13set testdir [file dirname $argv0] 14source $testdir/tester.tcl 15source $testdir/malloc_common.tcl 16set testprefix altermalloc2 17 18# If SQLITE_OMIT_ALTERTABLE is defined, omit this file. 19ifcapable !altertable { 20 finish_test 21 return 22} 23 24do_execsql_test 1.0 { 25 CREATE TABLE t1(abcd, efgh); 26} 27faultsim_save_and_close 28 29do_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 39catch {db close} 40forcedelete test.db 41sqlite3 db test.db 42do_execsql_test 2.0 { 43 PRAGMA encoding = 'utf-16'; 44 CREATE TABLE t1(abcd, efgh); 45} 46faultsim_save_and_close 47 48do_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 59reset_db 60do_execsql_test 3.0 { 61 CREATE TABLE t1(abcd, efgh); 62 CREATE VIEW v1 AS SELECT * FROM t1 WHERE abcd>efgh; 63} 64faultsim_save_and_close 65 66do_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} 75finish_test 76