errmsg() clobbers errno

From: John Gorman <johngorman2(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: errmsg() clobbers errno
Date: 2015-05-19 16:12:36
Message-ID: CALkS6B9AH00MJmmKd78deaFwtc=JfYbsDXvq0kjyR0J9pX2Xkw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi All

While debugging an extension I discovered that the errmsg()
function zeros out errno.

This is annoying because if the process of assembling a meaningful
error message happens to call errmsg() before calling strerror()
we lose the strerror information. This is exactly the time when we
want to preserve any available error state.

I am attaching a patch to preserve errno across errmsg() calls.

Does this seem like a good idea?

Best, John

Attachment Content-Type Size
errmsg-errno-v1.patch application/octet-stream 586 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-05-19 16:15:58 Re: Wrong Assert in PageIndexMultiDelete?
Previous Message Geoff Winkless 2015-05-19 15:49:40 Re: INSERT ... ON CONFLICT DO UPDATE with _any_ constraint