Fix assorted small bugs in ThrowErrorData().
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 26 Aug 2016 18:15:47 +0000 (14:15 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 26 Aug 2016 18:15:47 +0000 (14:15 -0400)
commit8529036b53298c0555670b4a81ed7349c44aeeb4
tree6bceafdca1af0e5f8b1050ad8232fe45abb8aca3
parentfbf28b6b52c269188262a87247adb2c359acd6c5
Fix assorted small bugs in ThrowErrorData().

Copy the palloc'd strings into the correct context, ie ErrorContext
not wherever the source ErrorData is.  This would be a large bug,
except that it appears that all catchers of thrown errors do either
EmitErrorReport or CopyErrorData before doing anything that would
cause transient memory contexts to be cleaned up.  Still, it's wrong
and it will bite somebody someday.

Fix failure to copy cursorpos and internalpos.

Utter the appropriate incantations involving recursion_depth, so that
we'll behave sanely if we get an error inside pstrdup.  (In general,
the body of this function ought to act like, eg, errdetail().)

Per code reading induced by Jakob Egger's report.
src/backend/utils/error/elog.c