8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 04:43:03 +01:00

Fixed stack overflow reason as shown by failed fbt test for core-4653.

This commit is contained in:
Vlad Khorsun 2022-09-07 13:26:08 +03:00
parent 92ae3c8f13
commit ef975036dd
2 changed files with 45 additions and 36 deletions

View File

@ -417,6 +417,8 @@ namespace Jrd
bool internalGetRecord(thread_db* tdbb) const override;
private:
void process(thread_db* tdbb) const;
NestConst<RecordSource> m_next;
StreamList m_streams;
};

View File

@ -87,48 +87,55 @@ bool SingularStream::internalGetRecord(thread_db* tdbb) const
if (m_next->getRecord(tdbb))
{
const FB_SIZE_T streamCount = m_streams.getCount();
MemoryPool& pool = *tdbb->getDefaultPool();
HalfStaticArray<record_param, 16> rpbs(pool, streamCount);
for (FB_SIZE_T i = 0; i < streamCount; i++)
{
rpbs.add(request->req_rpb[m_streams[i]]);
record_param& rpb = rpbs.back();
Record* const orgRecord = rpb.rpb_record;
if (orgRecord)
rpb.rpb_record = FB_NEW_POOL(pool) Record(pool, orgRecord);
}
if (m_next->getRecord(tdbb))
status_exception::raise(Arg::Gds(isc_sing_select_err));
for (FB_SIZE_T i = 0; i < streamCount; i++)
{
record_param& rpb = request->req_rpb[m_streams[i]];
Record* orgRecord = rpb.rpb_record;
rpb = rpbs[i];
const AutoPtr<Record> newRecord(rpb.rpb_record);
if (newRecord)
{
if (!orgRecord)
BUGCHECK(284); // msg 284 cannot restore singleton select data
rpb.rpb_record = orgRecord;
orgRecord->copyFrom(newRecord);
}
}
impure->irsb_flags |= irsb_singular_processed;
process(tdbb);
return true;
}
return false;
}
void SingularStream::process(thread_db* tdbb) const
{
Request* const request = tdbb->getRequest();
Impure* const impure = request->getImpure<Impure>(m_impure);
const FB_SIZE_T streamCount = m_streams.getCount();
MemoryPool& pool = *tdbb->getDefaultPool();
HalfStaticArray<record_param, 16> rpbs(pool, streamCount);
for (FB_SIZE_T i = 0; i < streamCount; i++)
{
rpbs.add(request->req_rpb[m_streams[i]]);
record_param& rpb = rpbs.back();
Record* const orgRecord = rpb.rpb_record;
if (orgRecord)
rpb.rpb_record = FB_NEW_POOL(pool) Record(pool, orgRecord);
}
if (m_next->getRecord(tdbb))
status_exception::raise(Arg::Gds(isc_sing_select_err));
for (FB_SIZE_T i = 0; i < streamCount; i++)
{
record_param& rpb = request->req_rpb[m_streams[i]];
Record* orgRecord = rpb.rpb_record;
rpb = rpbs[i];
const AutoPtr<Record> newRecord(rpb.rpb_record);
if (newRecord)
{
if (!orgRecord)
BUGCHECK(284); // msg 284 cannot restore singleton select data
rpb.rpb_record = orgRecord;
orgRecord->copyFrom(newRecord);
}
}
impure->irsb_flags |= irsb_singular_processed;
}
bool SingularStream::refetchRecord(thread_db* tdbb) const
{
return m_next->refetchRecord(tdbb);