mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
Make explicit the restrictions on UPDATE, DELETE, and INSERT statement syntax
within triggers. Ticket #3947. (CVS 6840) FossilOrigin-Name: c8bf40df7be728b11bb633516d1988c6064a9d70
This commit is contained in:
@ -639,4 +639,64 @@ do_test trigger1-15.2 {
|
||||
catchsql { INSERT INTO tA VALUES('abc', 2, 3) }
|
||||
} {1 {datatype mismatch}}
|
||||
|
||||
# Ticket #3947: Do not allow qualified table names on INSERT, UPDATE, and
|
||||
# DELETE statements within triggers. Actually, this has never been allowed
|
||||
# by the grammar. But the error message is confusing: one simply gets a
|
||||
# "syntax error". That has now been changed to give a full error message.
|
||||
#
|
||||
do_test trigger1-16.1 {
|
||||
db eval {
|
||||
CREATE TABLE t16(a,b,c);
|
||||
CREATE INDEX t16a ON t16(a);
|
||||
CREATE INDEX t16b ON t16(b);
|
||||
}
|
||||
catchsql {
|
||||
CREATE TRIGGER main.t16err1 AFTER INSERT ON tA BEGIN
|
||||
INSERT INTO main.t16 VALUES(1,2,3);
|
||||
END;
|
||||
}
|
||||
} {1 {qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers}}
|
||||
do_test trigger1-16.2 {
|
||||
catchsql {
|
||||
CREATE TRIGGER main.t16err2 AFTER INSERT ON tA BEGIN
|
||||
UPDATE main.t16 SET rowid=rowid+1;
|
||||
END;
|
||||
}
|
||||
} {1 {qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers}}
|
||||
do_test trigger1-16.3 {
|
||||
catchsql {
|
||||
CREATE TRIGGER main.t16err3 AFTER INSERT ON tA BEGIN
|
||||
DELETE FROM main.t16;
|
||||
END;
|
||||
}
|
||||
} {1 {qualified table names are not allowed on INSERT, UPDATE, and DELETE statements within triggers}}
|
||||
do_test trigger1-16.4 {
|
||||
catchsql {
|
||||
CREATE TRIGGER main.t16err4 AFTER INSERT ON tA BEGIN
|
||||
UPDATE t16 NOT INDEXED SET rowid=rowid+1;
|
||||
END;
|
||||
}
|
||||
} {1 {the NOT INDEXED clause is not allowed on UPDATE or DELETE statements within triggers}}
|
||||
do_test trigger1-16.5 {
|
||||
catchsql {
|
||||
CREATE TRIGGER main.t16err5 AFTER INSERT ON tA BEGIN
|
||||
UPDATE t16 INDEXED BY t16a SET rowid=rowid+1 WHERE a=1;
|
||||
END;
|
||||
}
|
||||
} {1 {the INDEXED BY clause is not allowed on UPDATE or DELETE statements within triggers}}
|
||||
do_test trigger1-16.6 {
|
||||
catchsql {
|
||||
CREATE TRIGGER main.t16err6 AFTER INSERT ON tA BEGIN
|
||||
DELETE FROM t16 NOT INDEXED WHERE a=123;
|
||||
END;
|
||||
}
|
||||
} {1 {the NOT INDEXED clause is not allowed on UPDATE or DELETE statements within triggers}}
|
||||
do_test trigger1-16.7 {
|
||||
catchsql {
|
||||
CREATE TRIGGER main.t16err7 AFTER INSERT ON tA BEGIN
|
||||
DELETE FROM t16 INDEXED BY t16a WHERE a=123;
|
||||
END;
|
||||
}
|
||||
} {1 {the INDEXED BY clause is not allowed on UPDATE or DELETE statements within triggers}}
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user