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