mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 22:43:04 +01:00
Fixed CORE-1894 - Circular dependencies between computed fields crashs the engine.
This commit is contained in:
parent
0aa921866a
commit
21978036d5
@ -5639,10 +5639,22 @@ ValueExprNode* FieldNode::pass1(thread_db* tdbb, CompilerScratch* csb)
|
||||
|
||||
sub = NodeCopier::copy(tdbb, csb, sub, map);
|
||||
|
||||
bool computingField = false;
|
||||
|
||||
// If this is a computed field, cast the computed expression to the field type if required.
|
||||
// See CORE-5097.
|
||||
if (field->fld_computation && !relation->rel_view_rse)
|
||||
{
|
||||
FB_SIZE_T pos;
|
||||
|
||||
if (csb->csb_computing_fields.find(field, pos))
|
||||
ERR_post(Arg::Gds(isc_circular_computed));
|
||||
else
|
||||
{
|
||||
csb->csb_computing_fields.insert(pos, field);
|
||||
computingField = true;
|
||||
}
|
||||
|
||||
CastNode* cast = FB_NEW_POOL(*tdbb->getDefaultPool()) CastNode(
|
||||
*tdbb->getDefaultPool());
|
||||
cast->source = sub;
|
||||
@ -5710,6 +5722,16 @@ ValueExprNode* FieldNode::pass1(thread_db* tdbb, CompilerScratch* csb)
|
||||
doPass1(tdbb, csb, &sub);
|
||||
}
|
||||
|
||||
if (computingField)
|
||||
{
|
||||
FB_SIZE_T pos;
|
||||
|
||||
if (csb->csb_computing_fields.find(field, pos))
|
||||
csb->csb_computing_fields.remove(pos);
|
||||
else
|
||||
fb_assert(false);
|
||||
}
|
||||
|
||||
return sub;
|
||||
}
|
||||
|
||||
|
@ -423,6 +423,7 @@ class CompilerScratch : public pool_alloc<type_csb>
|
||||
csb_cursors(p),
|
||||
csb_invariants(p),
|
||||
csb_current_nodes(p),
|
||||
csb_computing_fields(p),
|
||||
csb_pool(p),
|
||||
csb_map_field_info(p),
|
||||
csb_map_item_info(p),
|
||||
@ -505,6 +506,7 @@ public:
|
||||
Firebird::Array<ULONG*> csb_invariants; // stack of pointer to nodes invariant offsets
|
||||
Firebird::Array<ExprNode*> csb_current_nodes; // RseNode's and other invariant
|
||||
// candidates within whose scope we are
|
||||
Firebird::SortedArray<jrd_fld*> csb_computing_fields; // Computed fields being compiled
|
||||
StreamType csb_n_stream; // Next available stream
|
||||
USHORT csb_msg_number; // Highest used message number
|
||||
ULONG csb_impure; // Next offset into impure area
|
||||
|
Loading…
Reference in New Issue
Block a user