From 6c4a899f0b4adfa244bf46dec49358b735a775ec Mon Sep 17 00:00:00 2001 From: hvlad Date: Fri, 18 Mar 2016 00:41:43 +0200 Subject: [PATCH] Revert "Revert "Merge branch 'B3_0_Release' of https://github.com/FirebirdSQL/firebird into B3_0_Release"" This reverts commit 1bb06d69f67bc713a04fcf3a3fd07f37b44ac384. Sorry for confusion --- src/dsql/DdlNodes.epp | 2 +- src/dsql/ExprNodes.cpp | 2 +- src/dsql/StmtNodes.cpp | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dsql/DdlNodes.epp b/src/dsql/DdlNodes.epp index 978b0b6a89..948aaa950e 100644 --- a/src/dsql/DdlNodes.epp +++ b/src/dsql/DdlNodes.epp @@ -3574,11 +3574,11 @@ void CreateAlterTriggerNode::compile(thread_db* /*tdbb*/, DsqlCompilerScratch* d dsqlScratch->loopLevel = 0; dsqlScratch->cursorNumber = 0; + dsqlScratch->scopeLevel++; 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. // My first suspicion regarding an obvious conflict diff --git a/src/dsql/ExprNodes.cpp b/src/dsql/ExprNodes.cpp index cd2d2f381c..97c112f30e 100644 --- a/src/dsql/ExprNodes.cpp +++ b/src/dsql/ExprNodes.cpp @@ -8036,7 +8036,7 @@ ValueExprNode* RecordKeyNode::dsqlPass(DsqlCompilerScratch* dsqlScratch) for (DsqlContextStack::iterator stack(*dsqlScratch->context); stack.hasData(); ++stack) { dsql_ctx* context = stack.object(); - if ((context->ctx_flags & CTX_system) || + if ((context->ctx_flags & (CTX_system | CTX_returning)) == CTX_system || context->ctx_scope_level != dsqlScratch->scopeLevel) { continue; diff --git a/src/dsql/StmtNodes.cpp b/src/dsql/StmtNodes.cpp index 2dd0f15a82..7aca08e742 100644 --- a/src/dsql/StmtNodes.cpp +++ b/src/dsql/StmtNodes.cpp @@ -135,7 +135,8 @@ namespace oldContext(aOldContext), oldAlias(oldContext->ctx_alias), oldInternalAlias(oldContext->ctx_internal_alias), - autoFlags(&oldContext->ctx_flags, oldContext->ctx_flags | CTX_system | CTX_returning) + autoFlags(&oldContext->ctx_flags, oldContext->ctx_flags | CTX_system | CTX_returning), + autoScopeLevel(&aScratch->scopeLevel, aScratch->scopeLevel + 1) { // Clone the modify/old context and push with name "NEW" in a greater scope level. @@ -165,6 +166,7 @@ namespace newContext->ctx_alias = newContext->ctx_internal_alias = NEW_CONTEXT_NAME; newContext->ctx_flags |= CTX_returning; + newContext->ctx_scope_level = scratch->scopeLevel; scratch->context->push(newContext); } @@ -219,6 +221,7 @@ namespace dsql_ctx* oldContext; string oldAlias, oldInternalAlias; AutoSetRestore autoFlags; + AutoSetRestore autoScopeLevel; }; } // namespace