CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
altermalloc3.test91 linesDownload Raw Back to test
1# 2021 February 182#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 altermalloc317 18# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.19ifcapable !altertable {20  finish_test21  return22}23 24 25set ::TMPDBERROR [list 1 \26  {unable to open a temporary database file for storing temporary tables}27]28 29sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 130do_execsql_test 1.0 {31  CREATE TABLE x1(32      one, two, three, PRIMARY KEY(one), 33      CHECK (three!="xyz"), CHECK (two!="one")34  ) WITHOUT ROWID;35  CREATE INDEX x1i ON x1(one+"two"+"four") WHERE "five";36  CREATE TEMP TRIGGER AFTER INSERT ON x1 BEGIN37    UPDATE x1 SET two=new.three || "new" WHERE one=new.one||"";38  END;39  CREATE TABLE t1(a, b, c, d, PRIMARY KEY(d, b)) WITHOUT ROWID;40  INSERT INTO t1 VALUES(1, 2, 3, 4);41}42faultsim_save_and_close43 44do_faultsim_test 1 -prep {45  faultsim_restore_and_reopen46} -body {47  execsql { ALTER TABLE t1 DROP COLUMN c }48} -test {49  faultsim_test_result {0 {}} $::TMPDBERROR50}51 52 53#-------------------------------------------------------------------------54# dbsqlfuzz e3dd84cda3848016a6a6024c7249d09bc2ef261555#56reset_db57do_execsql_test 2.0 {58  CREATE TABLE t2(k,v);59  CREATE TRIGGER r2 AFTER INSERT ON t2 BEGIN60    UPDATE t2 SET (k,v)= (61       (WITH cte1(a) AS ( SELECT 1 FROM ( SELECT * FROM t2 ) )62       SELECT a FROM cte163    ), 1);64  END;65 66  CREATE TRIGGER r1 AFTER INSERT ON t2 BEGIN67    UPDATE t2 SET k=1 FROM t2 AS one, t2 AS two NATURAL JOIN t2 AS three 68    WHERE one.k=two.v;69  END;70}71 72faultsim_save_and_close73faultsim_restore_and_reopen74 75do_execsql_test 2.1 {76  ALTER TABLE t2 RENAME TO t2x;77}78 79do_faultsim_test 2.2 -prep {80  faultsim_restore_and_reopen81  db eval { SELECT * FROM sqlite_master } 82} -body {83  execsql {84    ALTER TABLE t2 RENAME TO t2x;85  }86} -test {87  faultsim_test_result {0 {}} $::TMPDBERROR88}89 90finish_test91