Skip to content

Commit

Permalink
Merge pull request #7390 from FirebirdSQL/view-invariants
Browse files Browse the repository at this point in the history
Fix invariants optimization involving views (#7388)
  • Loading branch information
dyemanov committed Dec 16, 2022
2 parents 76593ec + 386b7e6 commit 0ec40cc
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/dsql/ExprNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6539,8 +6539,6 @@ ValueExprNode* FieldNode::pass1(thread_db* tdbb, CompilerScratch* csb)
{
StreamType stream = fieldStream;

markVariant(csb, stream);

CompilerScratch::csb_repeat* tail = &csb->csb_rpt[stream];
jrd_rel* relation = tail->csb_relation;
jrd_fld* field;
Expand All @@ -6551,6 +6549,7 @@ ValueExprNode* FieldNode::pass1(thread_db* tdbb, CompilerScratch* csb)
if (relation && (relation->rel_flags & REL_being_scanned))
csb->csb_g_flags |= csb_reload;

markVariant(csb, stream);
return ValueExprNode::pass1(tdbb, csb);
}

Expand Down Expand Up @@ -6628,9 +6627,11 @@ ValueExprNode* FieldNode::pass1(thread_db* tdbb, CompilerScratch* csb)

if (!(sub = field->fld_computation) && !(sub = field->fld_source))
{

if (!relation->rel_view_rse)
{
markVariant(csb, stream);
return ValueExprNode::pass1(tdbb, csb);
}

// Msg 364 "cannot access column %s in view %s"
ERR_post(Arg::Gds(isc_no_field_access) << Arg::Str(field->fld_name) <<
Expand All @@ -6651,7 +6652,10 @@ ValueExprNode* FieldNode::pass1(thread_db* tdbb, CompilerScratch* csb)
// dimitr: added an extra check for views, because we don't
// want their old/new contexts to be substituted
if (relation->rel_view_rse || !field->fld_computation)
{
markVariant(csb, stream);
return ValueExprNode::pass1(tdbb, csb);
}
}

StreamMap localMap;
Expand Down Expand Up @@ -6758,11 +6762,7 @@ ValueExprNode* FieldNode::pass1(thread_db* tdbb, CompilerScratch* csb)

if (computingField)
{
FB_SIZE_T pos;

if (csb->csb_computing_fields.find(field, pos))
csb->csb_computing_fields.remove(pos);
else
if (!csb->csb_computing_fields.findAndRemove(field))
fb_assert(false);
}

Expand Down

0 comments on commit 0ec40cc

Please sign in to comment.