1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Enhance defensive mode so that it disallows CREATE TRIGGER statements if the

statements within the trigger attempt to write on a shadow table.

FossilOrigin-Name: 3283bbd12a60f472ed03cb7c6209a605a3bf9f3d9083371e17840b56e8b3f559
This commit is contained in:
drh
2022-09-27 00:56:45 +00:00
parent f333370e1f
commit 80cf891792
3 changed files with 24 additions and 7 deletions

View File

@@ -351,6 +351,23 @@ void sqlite3FinishTrigger(
Vdbe *v;
char *z;
/* If this is a new CREATE TABLE statement, and if shadow tables
** are read-only, and the trigger makes a change to a shadow table,
** then raise an error - do not allow the trigger to be created. */
if( sqlite3ReadOnlyShadowTables(db) ){
TriggerStep *pStep;
for(pStep=pTrig->step_list; pStep; pStep=pStep->pNext){
if( pStep->zTarget!=0
&& sqlite3ShadowTableName(db, pStep->zTarget)
){
sqlite3ErrorMsg(pParse,
"trigger \"%s\" may not write to shadow table \"%s\"",
pTrig->zName, pStep->zTarget);
goto triggerfinish_cleanup;
}
}
}
/* Make an entry in the sqlite_schema table */
v = sqlite3GetVdbe(pParse);
if( v==0 ) goto triggerfinish_cleanup;