Skip to content

Commit

Permalink
Fixed CORE-3967: subselect with reference to outer select fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
dyemanov committed Nov 1, 2012
1 parent 3e07dd1 commit 92e6b2e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/jrd/RecordSourceNodes.cpp
Expand Up @@ -2224,19 +2224,23 @@ bool RseNode::dsqlMatch(const ExprNode* other, bool /*ignoreMapCast*/) const
RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
{
// Set up a new (empty) context to process the joins, but ensure
// that it includes system (e.g. trigger) contexts (if present).
// that it includes system (e.g. trigger) contexts (if present),
// as well as any outer (from other levels) contexts.

DsqlContextStack* const base_context = dsqlScratch->context;
DsqlContextStack temp;
dsqlScratch->context = &temp;

for (DsqlContextStack::iterator iter(*base_context); iter.hasData(); ++iter)
{
if (iter.object()->ctx_flags & CTX_system)
if ((iter.object()->ctx_flags & CTX_system) ||
(iter.object()->ctx_scope_level != dsqlScratch->scopeLevel))
{
temp.push(iter.object());
}
}

size_t systemContexts = temp.getCount();
const size_t visibleContexts = temp.getCount();

RecSourceListNode* fromList = dsqlFrom;
RecSourceListNode* streamList = FB_NEW(getPool()) RecSourceListNode(
Expand Down Expand Up @@ -2483,7 +2487,7 @@ RseNode* RseNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)

// Merge the newly created contexts with the original ones

while (temp.getCount() > systemContexts)
while (temp.getCount() > visibleContexts)
base_context->push(temp.pop());

dsqlScratch->context = base_context;
Expand Down

0 comments on commit 92e6b2e

Please sign in to comment.