2021-02-17 23:46:44 +03:00
|
|
|
# 2021 February 18
|
|
|
|
#
|
|
|
|
# The author disclaims copyright to this source code. In place of
|
|
|
|
# a legal notice, here is a blessing:
|
|
|
|
#
|
|
|
|
# May you do good and not evil.
|
|
|
|
# May you find forgiveness for yourself and forgive others.
|
|
|
|
# May you share freely, never taking more than you give.
|
|
|
|
#
|
|
|
|
#*************************************************************************
|
|
|
|
#
|
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
source $testdir/malloc_common.tcl
|
|
|
|
set testprefix altermalloc3
|
|
|
|
|
|
|
|
# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.
|
|
|
|
ifcapable !altertable {
|
|
|
|
finish_test
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-05-27 18:33:51 +03:00
|
|
|
|
2022-02-11 22:41:03 +03:00
|
|
|
set ::TMPDBERROR [list 1 \
|
|
|
|
{unable to open a temporary database file for storing temporary tables}
|
|
|
|
]
|
|
|
|
|
2023-10-25 20:26:11 +03:00
|
|
|
sqlite3_db_config db SQLITE_DBCONFIG_DQS_DDL 1
|
2021-02-17 23:46:44 +03:00
|
|
|
do_execsql_test 1.0 {
|
2021-03-16 21:24:49 +03:00
|
|
|
CREATE TABLE x1(
|
|
|
|
one, two, three, PRIMARY KEY(one),
|
|
|
|
CHECK (three!="xyz"), CHECK (two!="one")
|
|
|
|
) WITHOUT ROWID;
|
|
|
|
CREATE INDEX x1i ON x1(one+"two"+"four") WHERE "five";
|
|
|
|
CREATE TEMP TRIGGER AFTER INSERT ON x1 BEGIN
|
|
|
|
UPDATE x1 SET two=new.three || "new" WHERE one=new.one||"";
|
|
|
|
END;
|
2021-02-17 23:46:44 +03:00
|
|
|
CREATE TABLE t1(a, b, c, d, PRIMARY KEY(d, b)) WITHOUT ROWID;
|
|
|
|
INSERT INTO t1 VALUES(1, 2, 3, 4);
|
|
|
|
}
|
|
|
|
faultsim_save_and_close
|
|
|
|
|
|
|
|
do_faultsim_test 1 -prep {
|
|
|
|
faultsim_restore_and_reopen
|
|
|
|
} -body {
|
|
|
|
execsql { ALTER TABLE t1 DROP COLUMN c }
|
|
|
|
} -test {
|
2022-02-11 22:41:03 +03:00
|
|
|
faultsim_test_result {0 {}} $::TMPDBERROR
|
2021-02-17 23:46:44 +03:00
|
|
|
}
|
|
|
|
|
2022-05-27 18:33:51 +03:00
|
|
|
|
2021-09-27 18:44:03 +03:00
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
# dbsqlfuzz e3dd84cda3848016a6a6024c7249d09bc2ef2615
|
|
|
|
#
|
|
|
|
reset_db
|
|
|
|
do_execsql_test 2.0 {
|
|
|
|
CREATE TABLE t2(k,v);
|
|
|
|
CREATE TRIGGER r2 AFTER INSERT ON t2 BEGIN
|
|
|
|
UPDATE t2 SET (k,v)= (
|
|
|
|
(WITH cte1(a) AS ( SELECT 1 FROM ( SELECT * FROM t2 ) )
|
|
|
|
SELECT a FROM cte1
|
|
|
|
), 1);
|
|
|
|
END;
|
2022-05-27 18:33:51 +03:00
|
|
|
|
|
|
|
CREATE TRIGGER r1 AFTER INSERT ON t2 BEGIN
|
|
|
|
UPDATE t2 SET k=1 FROM t2 AS one, t2 AS two NATURAL JOIN t2 AS three
|
|
|
|
WHERE one.k=two.v;
|
|
|
|
END;
|
2021-09-27 18:44:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
faultsim_save_and_close
|
|
|
|
faultsim_restore_and_reopen
|
|
|
|
|
|
|
|
do_execsql_test 2.1 {
|
|
|
|
ALTER TABLE t2 RENAME TO t2x;
|
|
|
|
}
|
|
|
|
|
|
|
|
do_faultsim_test 2.2 -prep {
|
|
|
|
faultsim_restore_and_reopen
|
|
|
|
db eval { SELECT * FROM sqlite_master }
|
|
|
|
} -body {
|
|
|
|
execsql {
|
|
|
|
ALTER TABLE t2 RENAME TO t2x;
|
|
|
|
}
|
|
|
|
} -test {
|
2022-02-11 22:41:03 +03:00
|
|
|
faultsim_test_result {0 {}} $::TMPDBERROR
|
2021-09-27 18:44:03 +03:00
|
|
|
}
|
2021-02-17 23:46:44 +03:00
|
|
|
|
|
|
|
finish_test
|