Re: Fix error handling in getCopyDataMessage and pqFunctionCall3 - Mailing list pgsql-hackers

From Anthonin Bonnefoy
Subject Re: Fix error handling in getCopyDataMessage and pqFunctionCall3
Date
Msg-id CAO6_Xqr2BPsDUWRxz0LdPaXhJG2HhbaF7vAh0WZp43BvN0D9eA@mail.gmail.com
Whole thread
List pgsql-hackers
Thanks for the reviews!

On Thu, Jul 23, 2026 at 9:43 AM Fujii Masao <masao.fujii@gmail.com> wrote:
> + /*
> + * An error may have been triggered while processing the message, bail
> + * out
> + */
> + if (conn->error_result && conn->status == CONNECTION_BAD)
> + return pqPrepareAsyncResult(conn);
>
> getCopyDataMessage() checks for the fatal error before pqParseDone(),
> but pqFunctionCall3() does it after pqParseDone().  Shouldn't
> pqFunctionCall3() use the same ordering?
>
> If getNotify() or getParameterStatus() calls handleFatalError(), the input
> buffer has already been flushed, so calling pqParseDone() afterwards seems
> unnecessary and a bit confusing.

Right, I guess one possible reason would be to trace the message. But
on the other hand, pqParseDone is called for successfully parsed
messages, and other codepaths don't call pqParseDone on errors, so it
is definitely confusing.

I've updated the patch to move the error checks before pqParseDone in
both cases.

Regards,
Anthonin Bonnefoy

Attachment

pgsql-hackers by date:

Previous
From: Ewan Young
Date:
Subject: Re: [PATCH] Fix temporal foreign key validation of pre-existing rows
Next
From: Chao Li
Date:
Subject: Re: Fix missing FORMAT when deparsing JSON_ARRAY(query)