Skip to content

Commit 73db7cd

Browse files
committed
Backported fix for potential endless loop inside MET_scan_relation
1 parent f06ae97 commit 73db7cd

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/jrd/met.epp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3860,9 +3860,13 @@ static void scan_relation(thread_db* tdbb, jrd_rel* relation)
38603860
AutoCacheRequest request(tdbb, irq_r_fields, IRQ_REQUESTS);
38613861
CompilerScratch* csb = NULL;
38623862

3863+
bool found = false;
3864+
38633865
FOR(REQUEST_HANDLE request)
38643866
REL IN RDB$RELATIONS WITH REL.RDB$RELATION_ID EQ relation->rel_id
38653867
{
3868+
found = true;
3869+
38663870
// Pick up relation level stuff
38673871
relation->rel_current_fmt = REL.RDB$FORMAT;
38683872
vec<jrd_fld*>* vector = relation->rel_fields =
@@ -4112,6 +4116,27 @@ static void scan_relation(thread_db* tdbb, jrd_rel* relation)
41124116

41134117
delete csb;
41144118

4119+
if (!found && !(relation->rel_flags & REL_scanned))
4120+
{
4121+
// Relation was not found in RDB$RELATIONS. It could be system virtual relation
4122+
// defined in INI.
4123+
4124+
if (relation->isSystem() && relation->isVirtual())
4125+
{
4126+
relation->rel_flags |= REL_scanned;
4127+
}
4128+
else
4129+
{
4130+
fb_assert(false);
4131+
4132+
string name(relation->rel_name.c_str());
4133+
if (name.isEmpty())
4134+
name.printf("<ID = %u>", relation->rel_id);
4135+
4136+
ERR_post(Arg::Gds(isc_relnotdef) << Arg::Str(name));
4137+
}
4138+
}
4139+
41154140
// release any triggers in case of a rescan, but not if the rescan
41164141
// hapenned while system triggers were being loaded.
41174142

0 commit comments

Comments
 (0)