Re: Question on ThrowErrorData - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Question on ThrowErrorData
Date
Msg-id 200981.1760961928@sss.pgh.pa.us
Whole thread Raw
In response to Question on ThrowErrorData  (正华吕 <kainwen@gmail.com>)
Responses Re: Question on ThrowErrorData
List pgsql-hackers
=?UTF-8?B?5q2j5Y2O5ZCV?= <kainwen@gmail.com> writes:
>      Inside errfinish, it just does a simple pointer assignment to set
>      filename and funcname field (via function set_stack_entry_location()).

Please note the comment on struct ErrorData:

 * ErrorData holds the data accumulated during any one ereport() cycle.
 * Any non-NULL pointers must point to palloc'd data.
 * (The const pointers are an exception; we assume they point at non-freeable
 * constant strings.)
...
    const char *filename;       /* __FILE__ of ereport() call */
...
    const char *funcname;       /* __func__ of ereport() call */

In practice these are always pointing at compiler-generated
constant strings.

            regards, tom lane



pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt
Next
From: torikoshia
Date:
Subject: Re: RFC: Logging plan of the running query