mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 08:03:04 +01:00
A more generic solution for CORE-1245: Incorrect column values with outer joins and views. It also fixes CORE-3981: Sub-optimal predicate checking while selecting from a view.
This commit is contained in:
parent
41925536c7
commit
606ae96e9f
@ -5536,13 +5536,23 @@ ValueExprNode* FieldNode::pass1(thread_db* tdbb, CompilerScratch* csb)
|
|||||||
AutoSetRestore<jrd_rel*> autoView(&csb->csb_view, relation);
|
AutoSetRestore<jrd_rel*> autoView(&csb->csb_view, relation);
|
||||||
AutoSetRestore<StreamType> autoViewStream(&csb->csb_view_stream, stream);
|
AutoSetRestore<StreamType> autoViewStream(&csb->csb_view_stream, stream);
|
||||||
|
|
||||||
// ASF: If the view field doesn't reference an item of a stream, evaluate it
|
// ASF: If the view field doesn't reference any of the view streams,
|
||||||
// based on the view dbkey - CORE-1245.
|
// evaluate it based on the view dbkey - CORE-1245.
|
||||||
RecordKeyNode* recNode;
|
SortedStreamList streams;
|
||||||
|
sub->jrdStreamsCollector(streams);
|
||||||
|
bool view_refs = false;
|
||||||
|
for (size_t i = 0; i < streams.getCount(); i++)
|
||||||
|
{
|
||||||
|
const CompilerScratch::csb_repeat* const sub_tail = &csb->csb_rpt[streams[i]];
|
||||||
|
|
||||||
if (!sub->is<FieldNode>() &&
|
if (sub_tail->csb_view && sub_tail->csb_view_stream == csb->csb_view_stream)
|
||||||
(!(recNode = sub->as<RecordKeyNode>()) ||
|
{
|
||||||
(recNode->blrOp != blr_dbkey && recNode->blrOp != blr_record_version2)))
|
view_refs = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!view_refs)
|
||||||
{
|
{
|
||||||
ValueExprNodeStack stack;
|
ValueExprNodeStack stack;
|
||||||
CMP_expand_view_nodes(tdbb, csb, stream, stack, blr_dbkey, true);
|
CMP_expand_view_nodes(tdbb, csb, stream, stack, blr_dbkey, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user