Skip to content

Commit 3b2bc84

Browse files
committed
Frontported pull request #8826: Fixed potential endless loop inside MET_scan_relation
1 parent 16a7f49 commit 3b2bc84

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/jrd/met.epp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3973,12 +3973,16 @@ static void scan_relation(thread_db* tdbb, jrd_rel* relation)
39733973
AutoCacheRequest request(tdbb, irq_r_fields, IRQ_REQUESTS);
39743974
CompilerScratch* csb = NULL;
39753975

3976+
bool found = false;
3977+
39763978
FOR(REQUEST_HANDLE request)
39773979
REL IN RDB$RELATIONS
39783980
CROSS SCH IN RDB$SCHEMAS
39793981
WITH REL.RDB$RELATION_ID EQ relation->rel_id AND
39803982
SCH.RDB$SCHEMA_NAME EQ REL.RDB$SCHEMA_NAME
39813983
{
3984+
found = true;
3985+
39823986
// Pick up relation level stuff
39833987
relation->rel_current_fmt = REL.RDB$FORMAT;
39843988
vec<jrd_fld*>* vector = relation->rel_fields =
@@ -4251,6 +4255,27 @@ static void scan_relation(thread_db* tdbb, jrd_rel* relation)
42514255

42524256
delete csb;
42534257

4258+
if (!found && !(relation->rel_flags & REL_scanned))
4259+
{
4260+
// Relation was not found in RDB$RELATIONS. It could be system virtual relation
4261+
// defined in INI.
4262+
4263+
if (relation->isSystem() && relation->isVirtual())
4264+
{
4265+
relation->rel_flags |= REL_scanned;
4266+
}
4267+
else
4268+
{
4269+
fb_assert(false);
4270+
4271+
string name(relation->rel_name.toQuotedString());
4272+
if (name.isEmpty())
4273+
name.printf("<ID = %u>", relation->rel_id);
4274+
4275+
ERR_post(Arg::Gds(isc_relnotdef) << Arg::Str(name));
4276+
}
4277+
}
4278+
42544279
// We have just loaded the triggers onto the local vector triggers.
42554280
// It's now time to place them at their rightful place inside the relation block.
42564281
relation->replaceTriggers(tdbb, triggers);

0 commit comments

Comments
 (0)