> On Nov 25, 2026, at 04:39, Álvaro Herrera <[email protected]> wrote:
>
> On 2026-Nov-23, Álvaro Herrera wrote:
>
>> I agree that there are more important things to fix. I thought using a
>> read-only StringInfo and getting rid of the global wasn't a completely
>> bad idea. I was reading this patch thinking it could be a quick push,
>> but I realized that it's not trivial to see from eyeballing alone that
>> we don't call walrcv_receive() one more time before consuming the whole
>> buffer (which libpqrcv_receive warns against). Admittedly, the same can
>> be said of the original code, so this is not a new concern. Maybe a few
>> extra comments would make this business clearer.
>
> I pushed this after all, thanks.
>
> --
> Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
> "Los minutos y los segundos son mercadería de la ciudad, donde un infeliz se
> afana por no perder ni siquiera un segundo y no advierte que obrando de ese
> modo pierde una vida." ("La vuelta de Don Camilo", G. Guareschi)
Thanks a lot for pushing this patch, and sorry for missing the previous
discussion.
I wasn’t aware of read-only StringInfo, but after reading f0efa5aec193, I agree
it’s a perfect fit for copybuf.
While reading the pushed commit, I just found a pre-existing bug in
copy_read_data():
```
/* If there are some leftover data from previous read, use it. */
avail = copybuf.len - copybuf.cursor;
if (avail)
{
if (avail > maxread)
avail = maxread;
memcpy(outbuf, ©buf.data[copybuf.cursor], avail);
copybuf.cursor += avail;
maxread -= avail;
bytesread += avail;
}
```
After copying the leftover bytes, copy_read_data() doesn’t advance outbuf. If
those bytes are less then minread, the next memcpy() would overwrite them. The
current caller only passes 1 for minread, so this bug cannot be triggered
today. I’ll propose a patch in a new thread.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/