Re: [HACKERS] elog vs errmsg_internal - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] elog vs errmsg_internal
Date
Msg-id 16689.1501793786@sss.pgh.pa.us
Whole thread Raw
In response to [HACKERS] elog vs errmsg_internal  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-hackers
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
> Is there a preferred method to select between using elog() and
> errmsg_internal()?

ereport(... errmsg_internal() ...) can be a win for debug messages that
are in hot code paths, because the test for whether the message will
get printed is able to short-circuit more work.  In particular,
if you have moderately expensive functions like syscache lookups in
the argument list of elog(), I believe those functions get evaluated
even if we end up not printing anything.  ereport() skips the
arg-list evaluation in such cases.

But if that doesn't seem very relevant, I'd tend to go for elog()
just because it's less typing.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: [HACKERS] xmltable SQL conformance
Next
From: Pavel Stehule
Date:
Subject: Re: [HACKERS] xmltable SQL conformance