Re: Fixing pool_read2

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: emond(dot)papegaaij(at)gmail(dot)com
Cc: pgpool-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Fixing pool_read2
Date: 2026-09-29 11:00:01
Message-ID: 20260929.200001.1013985966582594675.ishii@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgpool-hackers

> Recently Emond Papegaaij reported me off list that pool_read2() has a
> bug and sent a patch (see below).
>
> I agree that pool_read2() should check whether "len" argument has a
> positive value. However, if pool_read2() reurns NULL when len == 0 (as
> the patch instructs), quite a few regression test fail. This is
> because in many places callers of pool_read2() expect it returns non
> NULL if len == 0. Otherwise, they complain:
>
> ERROR: unable to forward message to frontend
> DETAIL: read from backend failed
>
> pool_read2() is typically used to read the packet body (which is after
> the packet lenth field). Even if len == 0 case (no body packet like
> BindComplete), callers feel free to call palloc with 0 byte, and
> memcpy with 0 byte. Fortunately palloc and memcpy are flexible enough
> to accept 0 byte argument. Maybe we should teach the callers to check
> len == 0 or not, but there are too many such places. For now, I would
> like to keep the current behavior (allow to length == 0). Attached is
> a patch to implement that way. (with slight commit message change and
> indentation change in the code to follow our coding standard).

pushed. Thanks!
https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=3fb1d89cea0a6d7a098ac0a8851663c1a531b3e9
--
Tatsuo Ishii
SRA OSS K.K.
English: http://www.sraoss.co.jp/index_en/
Japanese:http://www.sraoss.co.jp

In response to

Browse pgpool-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2026-09-30 02:13:21 Re: [PATCH] Two small track_table_mutation follow-ups: doc figures and unused counters
Previous Message Nadav Shatz 2026-09-22 06:30:27 [PATCH] Two small track_table_mutation follow-ups: doc figures and unused counters