Em seg., 5 de jul. de 2021 às 09:02, David Rowley <dgrowleyml@gmail.com> escreveu:
On Mon, 5 Jul 2021 at 23:07, Ranier Vilela <ranier.vf@gmail.com> wrote: > > Em seg., 5 de jul. de 2021 às 06:44, Dean Rasheed <dean.a.rasheed@gmail.com> escreveu: >> Note, however, that it won't make any difference to performance in the >> way that you're suggesting -- elog() in Postgres is used for "should >> never happen, unless there's a software bug" errors, rather than, say, >> "might happen for certain invalid inputs" errors, so init_var() should >> always be called in these functions. > > I agree that in this case, most of the time, elog is not called.
You may have misunderstood what Dean meant. elog(ERROR) calls are now exclusively for "cannot happen" cases. If someone gets one of these then there's a bug to fix or something else serious has gone wrong with the hardware.
The case you seem to be talking about would fit better if the code in question had been ereport(ERROR).
I don't disagree that the initialisation is better to happen after the elog. I'm just mentioning this as I wanted to make sure you knew the difference between elog(ERROR) and ereport(ERROR).
I understand the difference now, thanks for clarifying.