From 16d861ffc27142a17e4e888d8ff57280e3ac754c Mon Sep 17 00:00:00 2001 From: drh <> Date: Sat, 30 Jan 2021 02:22:38 +0000 Subject: [PATCH] When running the RETURNING trigger, if it is tagged as a DELETE trigger, do not use it as INSERT or UPDATE. FossilOrigin-Name: 3c7a6e04ddde34961d8e9d0443913e572a80853cf14a8263cec19523c39ca744 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/trigger.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 97aab3c71b..332c29a24d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Test\scases\sadded.\s\sRETURNING\sworks\swith\sUPSERT\sas\sdoes\sPG. -D 2021-01-30T01:30:26.496 +C When\srunning\sthe\sRETURNING\strigger,\sif\sit\sis\stagged\sas\sa\sDELETE\strigger,\ndo\snot\suse\sit\sas\sINSERT\sor\sUPDATE. +D 2021-01-30T02:22:38.436 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 88f616cbd1aa538f3d6bebc4e9b9fb95b566771b45c0690f21223de0317ace54 +F src/trigger.c 0b683379a7855f50bfd114cc7590bc1a10d4c8008dcc23e335e307459a36daba F src/update.c 3dbc7189ffcf361c2149f1b1d0841a8a9689d27f15c5e72e6f14ebc447e6b0c0 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 6aa2a058d136d0b24d94c5cbe1ce447eb435c1a1c7cdce5e435f1548bb3f05e7 -R c5d28b15f2cd5974ae8ec5b186394cb6 +P f5698f96e27c9b8669ec6016bb9920ef7580c4146eb61d628a0f62be5135ce94 +R c9a80a1d4c54684acda1e51b55904277 U drh -Z 4324b62b15638b065ad3c0261246302c +Z 993208c24ec6d120a7fb4e41ada97fae diff --git a/manifest.uuid b/manifest.uuid index b8ff6b9b92..0fa6e547a7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f5698f96e27c9b8669ec6016bb9920ef7580c4146eb61d628a0f62be5135ce94 \ No newline at end of file +3c7a6e04ddde34961d8e9d0443913e572a80853cf14a8263cec19523c39ca744 \ No newline at end of file diff --git a/src/trigger.c b/src/trigger.c index baf78eb8c2..6a3498c457 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -740,7 +740,7 @@ Trigger *sqlite3TriggersExist( for(p=pList; p; p=p->pNext){ if( p->op==op && checkColumnOverlap(p->pColumns, pChanges) ){ mask |= p->tr_tm; - }else if( p->bReturning ){ + }else if( p->bReturning && (p->op==TK_RETURNING || p->op!=TK_DELETE) ){ p->op = op; mask |= TRIGGER_AFTER; } @@ -1217,7 +1217,7 @@ void sqlite3CodeRowTrigger( || p->pSchema==pParse->db->aDb[1].pSchema ); /* Determine whether we should code this trigger */ - if( (p->op==op || p->bReturning) + if( (p->op==op || (p->bReturning && p->op!=TK_DELETE)) && p->tr_tm==tr_tm && checkColumnOverlap(p->pColumns, pChanges) ){