Re: Fix error handling in getCopyDataMessage and pqFunctionCall3

From: Ewan Young <kdbase(dot)hack(at)gmail(dot)com>
To: Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix error handling in getCopyDataMessage and pqFunctionCall3
Date: 2026-07-23 07:01:51
Message-ID: CAON2xHOqskf0AbdAA7a3Ttju=kibkVHemun2ioQw7PY7533JNA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jul 22, 2026 at 10:00 PM Anthonin Bonnefoy
<anthonin(dot)bonnefoy(at)datadoghq(dot)com> wrote:
>
> Hi,
>
> Currently, any OOM triggered within getNotify and getParameterStatus
> will drop the connection and set error_result=true.
>
> However, this error is currently ignored in 2 spots:
> getCopyDataMessage and pqFunctionCall3. They will continue to process
> the dead connection without reporting the error.
>
> The attached patch fixes the issue by returning the error (-2 for
> getCopyDataMessage, the PGresult for pqFunctionCall3) whenever a fatal
> error was triggered.

Thanks for the patch.

I traced through this and it looks correct. I confirmed by code
inspection that the third
caller of these helpers, pqParseInput3(), does not need the same
change: it already
has the check, and handleFatalError() also flushes the input buffer and sets
asyncStatus = PGASYNC_READY, so it can't spin. The two functions you patched are
the only ones with private loops that ignored error_result, so the
scope looks complete.

+1 from me.

>
> Regards,
> Anthonin Bonnefoy

--
Regards,
Ewan Young

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rafia Sabih 2026-07-23 07:05:48 Re: CREATE OR REPLACE MATERIALIZED VIEW
Previous Message Ewan Young 2026-07-23 06:19:48 Re: [PATCH] Fix temporal foreign key validation of pre-existing rows