Modify RETURNING so that it does not return changes implemented by

cascading foreign keys or by triggers.

FossilOrigin-Name: 6e62470a737cbde7f3fdcd027b98eb0b3dd11d063c63501d3c18448e93f5959f
This commit is contained in:
drh 2021-02-01 01:57:55 +00:00
parent 9407b6ef29
commit 7baf3d411b
3 changed files with 11 additions and 8 deletions

View File

@ -1,5 +1,5 @@
C Mark\san\sunreachable\sbranch\sas\sALWAYS().
D 2021-01-31T16:45:10.780
C Modify\sRETURNING\sso\sthat\sit\sdoes\snot\sreturn\schanges\simplemented\sby\ncascading\sforeign\skeys\sor\sby\striggers.
D 2021-02-01T01:57:55.870
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -607,7 +607,7 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
F src/tokenize.c c64c49d7c2ec4490c2fef1f24350167ba16b03b0c6cee58ad1a1d70a4325d4e9
F src/treeview.c 4b92992176fb2caefbe06ba5bd06e0e0ebcde3d5564758da672631f17aa51cda
F src/trigger.c b380259579a6d9dc3fa50d49b1b18ebfe42c10f12d3c5b3d0e2f7c3b35c45574
F src/trigger.c 30cb8be5ef144f5c9036cf45faa007aeb8cfebe3bc766fc58072730416d6bc57
F src/update.c 0f5a61f0787199983530a33f6fffe4f52742f35fcdf6ccfad1078b1a8bc17723
F src/upsert.c df8f1727d62b5987c4fd302cd4d7c0c84ae57cd65683c5a34a740dfe24039235
F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0
@ -1899,7 +1899,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 154fc2b15465c7c92a1af0a93851421aec42a81bab54840a9701f2c78068e14e
R cea5f0df7552de24bb2dee28a7a1e3f6
P cb8b797a64f65fca01c5faaeb30cbe4a53b56b81e696d1b62a90362d7ef8f924
R 199f69fc6dd65199d262c6cd91e2535c
U drh
Z fb166b95a911fcb55830f05a31923ad0
Z 013370d4bb9ad0b56cd61fbf8918d3d1

View File

@ -1 +1 @@
cb8b797a64f65fca01c5faaeb30cbe4a53b56b81e696d1b62a90362d7ef8f924
6e62470a737cbde7f3fdcd027b98eb0b3dd11d063c63501d3c18448e93f5959f

View File

@ -742,9 +742,11 @@ Trigger *sqlite3TriggersExist(
}else if( p->op==TK_RETURNING ){
/* The first time a RETURNING trigger is seen, the "op" value tells
** us what time of trigger it should be. */
assert( sqlite3IsToplevel(pParse) );
p->op = op;
mask |= TRIGGER_AFTER;
}else if( p->bReturning && p->op==TK_INSERT && op==TK_UPDATE ){
}else if( p->bReturning && p->op==TK_INSERT && op==TK_UPDATE
&& sqlite3IsToplevel(pParse) ){
/* Also fire a RETURNING trigger for INSERT on the UPDATE of an UPSERT */
mask |= TRIGGER_AFTER;
}
@ -1228,6 +1230,7 @@ void sqlite3CodeRowTrigger(
if( (p->op==op || (p->bReturning && p->op==TK_INSERT && op==TK_UPDATE))
&& p->tr_tm==tr_tm
&& checkColumnOverlap(p->pColumns, pChanges)
&& (sqlite3IsToplevel(pParse) || !p->bReturning)
){
u8 origOp = p->op;
p->op = op;