Bruce Momjian <bruce@momjian.us> writes:
> I have developed the attached patch to fix this and another instance I
> saw.
I think you need to re-read the part of the man page you quoted,
and set errno to zero beforehand, if you're going to rely on it
being zero after a non-error return.
regards, tom lane