From c933fadf42ed646cf0d951e907a38cb9bbbe1975 Mon Sep 17 00:00:00 2001 From: dimitr Date: Wed, 17 Dec 2014 11:56:48 +0000 Subject: [PATCH] Fixed CORE-4622: Regression: Trigger with UPDATE OR INSERT statement and IIF() not working as expected. --- src/dsql/DdlNodes.epp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/dsql/DdlNodes.epp b/src/dsql/DdlNodes.epp index 45238764a7..4d46d47fa4 100644 --- a/src/dsql/DdlNodes.epp +++ b/src/dsql/DdlNodes.epp @@ -3480,6 +3480,12 @@ void CreateAlterTriggerNode::compile(thread_db* /*tdbb*/, DsqlCompilerScratch* d dsqlScratch->setPsql(true); dsqlScratch->putLocalVariables(localDeclList, 0); + dsqlScratch->loopLevel = 0; + dsqlScratch->cursorNumber = 0; + + StmtNode* stmtNode = body->dsqlPass(dsqlScratch); + GEN_hidden_variables(dsqlScratch); + dsqlScratch->scopeLevel++; // dimitr: I see no reason to deny EXIT command in triggers, // hence I've added zero label at the beginning. @@ -3490,9 +3496,9 @@ void CreateAlterTriggerNode::compile(thread_db* /*tdbb*/, DsqlCompilerScratch* d // Hopefully, system triggers are never recompiled. dsqlScratch->appendUChar(blr_label); dsqlScratch->appendUChar(0); - dsqlScratch->loopLevel = 0; - dsqlScratch->cursorNumber = 0; - body->dsqlPass(dsqlScratch)->genBlr(dsqlScratch); + + stmtNode->genBlr(dsqlScratch); + dsqlScratch->scopeLevel--; dsqlScratch->appendUChar(blr_end); dsqlScratch->appendUChar(blr_eoc);