Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/jrd/recsrc/ProcedureScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ void ProcedureScan::internalOpen(thread_db* tdbb) const

const_cast<jrd_prc*>(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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. ALTER should create a new procedure version inside the metadata cache, but the already compiled procedure SP2 keeps a reference to the older version of SP1 (with the old format). AFAIU, this means that m_procedure->prc_record_format should never change, but your patch implies that the old version of the procedure somehow gets the new record format. How does it happen?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RoutineManager::modifyRoutine() marks procedure with FLAG_OBSOLETE | FLAG_BEING_ALTERED and calls Routine::remove() which doesn't delete such routines, but clears its internals and marks it with FLAG_CLEARED.
Then RoutineManager::getDependencies() calls MET_procedure() which doesn't create new version of procedure marked with FLAG_OBSOLETE but re-uses existing instance instead.


Request* const request = tdbb->getRequest();
Impure* const impure = request->getImpure<Impure>(m_impure);

Expand Down Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion src/jrd/recsrc/RecordSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ namespace Jrd

protected:
const StreamType m_stream;
const Format* const m_format;
mutable const Format* m_format;
};


Expand Down
Loading