Re: BUG #18767: Inconsistency in result of a Plpgsql GET DIAGNOSTICS PG_CONTEXT instruction. - Mailing list pgsql-bugs

From Philippe BEAUDOIN
Subject Re: BUG #18767: Inconsistency in result of a Plpgsql GET DIAGNOSTICS PG_CONTEXT instruction.
Date
Msg-id e4def4d7-6ac7-48af-b0aa-ddb79df61f54@free.fr
Whole thread Raw
In response to Re: BUG #18767: Inconsistency in result of a Plpgsql GET DIAGNOSTICS PG_CONTEXT instruction.  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-bugs
Le 07/01/2025 à 12:27, Pavel Stehule a écrit :
If you want to understand to these details, you should to look to source code


fn_signature is calculated in compile time - this is when the function is first time executed in session. Until the end of session or function change, the interpreter uses already compiled AST from cache and doesn't try to call the compiler (or more correctly named - parser). So the behavior depends on the state when the function was executed the first time. It can be more complex when a function uses polymorphic parameters, because then there can be cached more instances of one function.

The reason why signature is calculated only at compile time is just performance. Any access to the system catalog has its own cost, and you don't want to execute it again and again when the function is started. It cannot be executed at exception time (when it is usually used), because at this time it is impossible to access the system catalog.


Regards

Pavel

Ah, this clearly explains the strange to me things I noted. Thanks a lot for the explanation.

This closes the issue.

Regards. Philippe.

pgsql-bugs by date:

Previous
From: Aleksander Alekseev
Date:
Subject: Re: TimestampTz->Text->TimestampTz casting fails with DateStyle 'Postgres'
Next
From: Torbjörn Gannholm
Date:
Subject: Incorrect result in certain expressions of anti-join