... btw, speaking of signal-safe functions: I am dismayed to notice that strerror (and strerror_r) are *not* in POSIX's list of async-signal-safe functions. This is really quite unsurprising, considering that they are chartered to return locale-dependent strings. Unless the data has already been collected in the current process, that'd imply reading something from the locale definition files, allocating memory to hold it, etc.
So I'm now thinking this bit in PQcancel is completely unsafe: strncat(errbuf, SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)), maxlen); Seems we have to give up on providing any details beyond the name of the function that failed. regards, tom lane