CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
altermalloc2.test128 linesDownload Raw Back to test
1# 2018 August 202#3# The author disclaims copyright to this source code.  In place of4# 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.tcl15source $testdir/malloc_common.tcl16set testprefix altermalloc217 18# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.19ifcapable !altertable {20  finish_test21  return22}23 24do_execsql_test 1.0 {25  CREATE TABLE t1(abcd, efgh);26}27faultsim_save_and_close28 29set ::TMPDBERROR [list 1 \30  {unable to open a temporary database file for storing temporary tables}31]32 33 34do_faultsim_test 1 -prep {35  faultsim_restore_and_reopen36} -body {37  execsql {38    ALTER TABLE t1 RENAME abcd TO dcba39  }40} -test {41  faultsim_test_result {0 {}} $::TMPDBERROR42}43 44catch {db close}45forcedelete test.db46sqlite3 db test.db47do_execsql_test 2.0 {48  PRAGMA encoding = 'utf-16';49  CREATE TABLE t1(abcd, efgh);50}51faultsim_save_and_close52 53do_faultsim_test 2 -prep {54  faultsim_restore_and_reopen55} -body {56  execsql {57    ALTER TABLE t1 RENAME abcd TO dcba58  }59} -test {60  faultsim_test_result {0 {}} $::TMPDBERROR61}62 63 64reset_db65do_execsql_test 3.0 {66  CREATE TABLE t1(abcd, efgh);67  CREATE VIEW v1 AS SELECT * FROM t1 WHERE abcd>efgh;68}69faultsim_save_and_close70 71do_faultsim_test 3 -prep {72  faultsim_restore_and_reopen73} -body {74  execsql {75    ALTER TABLE t1 RENAME abcd TO dcba76  }77} -test {78  faultsim_test_result {0 {}} $::TMPDBERROR79}80 81reset_db82do_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 BEGIN87    SELECT 1, 2, 3;88  END;89  CREATE TRIGGER tr1 AFTER INSERT ON rr BEGIN90    INSERT INTO vv VALUES(new.a, new.b);91  END;92} {}93 94faultsim_save_and_close95do_faultsim_test 4 -faults oom-* -prep {96  faultsim_restore_and_reopen97  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 {}} $::TMPDBERROR104}105 106reset_db107do_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 abc112  );113} {}114 115faultsim_save_and_close116do_faultsim_test 5 -faults oom-* -prep {117  faultsim_restore_and_reopen118  execsql { SELECT * FROM sqlite_master }119} -body {120  execsql {121    ALTER TABLE rr RENAME TO c;122  }123} -test {124  faultsim_test_result {0 {}} $::TMPDBERROR125}126 127finish_test128