From 1790e51409469dfcba8cc37bf98139f645529f29 Mon Sep 17 00:00:00 2001 From: Vlad Khorsun Date: Wed, 7 Jan 2026 21:35:59 +0200 Subject: [PATCH] Fixed bug #8851 : 'Internal error' when calling outer procedure after deleting unused result variable from inner procedure --- src/jrd/recsrc/ProcedureScan.cpp | 8 ++++++++ src/jrd/recsrc/RecordSource.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/jrd/recsrc/ProcedureScan.cpp b/src/jrd/recsrc/ProcedureScan.cpp index 1166d1e0890..167b83f41e8 100644 --- a/src/jrd/recsrc/ProcedureScan.cpp +++ b/src/jrd/recsrc/ProcedureScan.cpp @@ -72,6 +72,12 @@ void ProcedureScan::internalOpen(thread_db* tdbb) const const_cast(m_procedure)->checkReload(tdbb); + // Procedure could be altered and its record format changed since current instance of + // ProcedureScan was created. Here it is not the right place to check if new format is + // compatible with caller's expectations, so we just use correct (possible new) format. + + m_format = m_procedure->prc_record_format; + Request* const request = tdbb->getRequest(); Impure* const impure = request->getImpure(m_impure); @@ -229,6 +235,8 @@ bool ProcedureScan::internalGetRecord(thread_db* tdbb) const trace.fetch(false, ITracePlugin::RESULT_SUCCESS); + fb_assert(m_format == m_procedure->prc_record_format); + for (USHORT i = 0; i < m_format->fmt_count; i++) { assignParams(tdbb, &msg_format->fmt_desc[2 * i], &msg_format->fmt_desc[2 * i + 1], diff --git a/src/jrd/recsrc/RecordSource.h b/src/jrd/recsrc/RecordSource.h index 8c8422965ea..a9a8f66ca2d 100644 --- a/src/jrd/recsrc/RecordSource.h +++ b/src/jrd/recsrc/RecordSource.h @@ -170,7 +170,7 @@ namespace Jrd protected: const StreamType m_stream; - const Format* const m_format; + mutable const Format* m_format; };