summaryrefslogtreecommitdiff
path: root/src/pl
diff options
context:
space:
mode:
authorTom Lane2018-09-26 17:31:56 +0000
committerTom Lane2018-09-26 17:31:56 +0000
commitd6c55de1f99a9028540516316b95321a7b12a540 (patch)
tree7c95ff050f56bcf20648e3d7a8a7fbb2ddbc7293 /src/pl
parent96bf88d52711ad3a0a4cc2d1d9cb0e2acab85e63 (diff)
Implement %m in src/port/snprintf.c, and teach elog.c to rely on that.
I started out with the idea that we needed to detect use of %m format specs in contexts other than elog/ereport calls, because we couldn't rely on that working in *printf calls. But a better answer is to fix things so that it does work. Now that we're using snprintf.c all the time, we can implement %m in that and we've fixed the problem. This requires also adjusting our various printf-wrapping functions so that they ensure "errno" is preserved when they call snprintf.c. Remove elog.c's handmade implementation of %m, and let it rely on snprintf to support the feature. That should provide some performance gain, though I've not attempted to measure it. There are a lot of places where we could now simplify 'printf("%s", strerror(errno))' into 'printf("%m")', but I'm not in any big hurry to make that happen. Patch by me, reviewed by Michael Paquier Discussion: https://postgr.es/m/2975.1526862605@sss.pgh.pa.us
Diffstat (limited to 'src/pl')
-rw-r--r--src/pl/plpython/plpy_elog.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/pl/plpython/plpy_elog.c b/src/pl/plpython/plpy_elog.c
index e244104fed..3814a6c32d 100644
--- a/src/pl/plpython/plpy_elog.c
+++ b/src/pl/plpython/plpy_elog.c
@@ -46,6 +46,7 @@ static bool set_string_attr(PyObject *obj, char *attrname, char *str);
void
PLy_elog_impl(int elevel, const char *fmt,...)
{
+ int save_errno = errno;
char *xmsg;
char *tbmsg;
int tb_depth;
@@ -96,6 +97,7 @@ PLy_elog_impl(int elevel, const char *fmt,...)
va_list ap;
int needed;
+ errno = save_errno;
va_start(ap, fmt);
needed = appendStringInfoVA(&emsg, dgettext(TEXTDOMAIN, fmt), ap);
va_end(ap);