Detecting outdated stored procedure dependencies

26 views
Skip to first unread message

Tomasz Tyrakowski

unread,
Sep 24, 2024, 6:13:27 AMSep 24
to firebird-support
Hello

AFAIU, when a stored procedure B calls another procedure A, and A gets
later altered, but without altering B, B still uses/calls the old
version of A. That's how it's always been, ever since Interbase days.
However, is there a more technical documentation available about how
exactly calling SPs by other SPs works and is implemented in Firebird?
I've got a pretty good understanding of it from the user's perspective,
i.e. I know what has to be done for it to work correctly, but I'd like
to understand how the actuall calls are done (I know FB is open source
and I can look into the code, but human life is finite).
Going back to the example with procedures A and B: if I forget to alter
B (to itself) after altering A, calling B results in execution of the
old version of A's BLR (that's easy to verify empirically, which I did
before posting, just in case ;) ).
Where are those versions kept in the database? Looking at
RDB$PROCEDURES, I can't figure it out.
Is it possible to detect, which version of A's BLR is actually used by
B, then check the current (most recent) version of A's BLR and detect if
there's a difference? I can't find any information about BLR versions in
the system tables, but then I might be looking in wrong places.
On the other hand, if A's BLR was inlined in the caller (in B's BLR),
indirect recurrence would be impossible (A calling B, B calling A),
which is not the case (I've got several indirectly recurrent SPs and
they work just fine).
So, if anyone knows about any sources, which would be helpful to
understand this stuff better, and could point them out, I'd really
appreciate it.

regards
Tomasz

Dimitry Sibiryakov

unread,
Sep 24, 2024, 6:16:48 AMSep 24
to firebird...@googlegroups.com
Tomasz Tyrakowski wrote 24.09.2024 12:13:
> Going back to the example with procedures A and B: if I forget to alter B (to
> itself) after altering A, calling B results in execution of the old version of
> A's BLR (that's easy to verify empirically, which I did before posting, just in
> case ;) ).
> Where are those versions kept in the database?

They are kept in database as usual record versions but in your case the old
version of SP is used from metadata cache which is in memory and bound to the
attachment. As soon as your attachment gone - this old version die as well.

--
WBR, SD.

Tomasz Tyrakowski

unread,
Sep 24, 2024, 6:25:41 AMSep 24
to firebird...@googlegroups.com
Thanks for a prompt reply. You're right, after I reconnect, B uses the
new version of A.
Still, is there any (reasonably) detailed documentation about it, so
that I can read it at my leisure and won't spam firebird-support with
more follow-up questions?

cheers
Tomasz

AlexPeshkoff

unread,
Sep 25, 2024, 4:13:57 AMSep 25
to firebird-support
Will be fixed by https://github.com/FirebirdSQL/firebird/issues/7954, i.e. new metadata cache will forcefully switch B to use new version of A in the next request after altering A.

вторник, 24 сентября 2024 г. в 13:25:41 UTC+3, Tomasz Tyrakowski:
Reply all
Reply to author
Forward
0 new messages