Hi, On 28/01/14 22:35, Tom Lane wrote: > >> Absolutely. Probably best to save errno into a local just before the > >> ereport. > > > I think just resetting to edata->saved_errno is better and sufficient? > > -1 --- that field is nobody's business except elog.c's.
Ok, so I propose the attached patch as a fix. Best regards, -- Christian Kruse http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 8705586..f40215a 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -715,6 +715,7 @@ errcode_for_socket_access(void) { \ char *fmtbuf; \ StringInfoData buf; \ + int saved_errno = errno; \ /* Internationalize the error format string */ \ if (translateit && !in_error_recursion_trouble()) \ fmt = dgettext((domain), fmt); \ @@ -744,6 +745,7 @@ errcode_for_socket_access(void) pfree(edata->targetfield); \ edata->targetfield = pstrdup(buf.data); \ pfree(buf.data); \ + errno = saved_errno; \ } /* @@ -756,6 +758,7 @@ errcode_for_socket_access(void) const char *fmt; \ char *fmtbuf; \ StringInfoData buf; \ + int saved_errno = errno; \ /* Internationalize the error format string */ \ if (!in_error_recursion_trouble()) \ fmt = dngettext((domain), fmt_singular, fmt_plural, n); \ @@ -787,6 +790,7 @@ errcode_for_socket_access(void) pfree(edata->targetfield); \ edata->targetfield = pstrdup(buf.data); \ pfree(buf.data); \ + errno = saved_errno; \ }
pgpnd3GqyaztU.pgp
Description: PGP signature