Re: Avoid unnecessary StringInfo allocation in tablesync COPY buffer

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, David Rowley <dgrowleyml(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Subject: Re: Avoid unnecessary StringInfo allocation in tablesync COPY buffer
Date: 2026-05-09 15:35:05
Message-ID: af9ROet_bQOYyr-g@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

On 2026-May-09, Chao Li wrote:

> I found this issue while reviewing the patch [1] and was suggested use
> a separate thread for the issue.
>
> In tablesync.c, copy_table() currently does:
> ```
> copybuf = makeStringInfo();
> ```
>
> But copybuf is only used by copy_read_data(), and there it's really
> just acting as a small state holder for data, len, and cursor, rather
> than as a normal growable StringInfo.

I find this coding pattern weird and ugly and confusing. If what we
need is three variables, shouldn't we have three variables instead of
this strange misuse of the StringInfo abstraction?

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"We have labored long to build a heaven, only (Prof. Milton Glass)
to find it populated with horrors" (Watchmen, Alan Moore)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-05-09 18:44:36 Re: [PATCH] psql: Make ParseVariableDouble reject values above max
Previous Message Henson Choi 2026-05-09 14:52:16 Re: [SQL/PGQ] Early pruning for GRAPH_TABLE path generation