pgsql: Avoid unnecessary allocation for tablesync.c COPY buffer

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid unnecessary allocation for tablesync.c COPY buffer
Date: 2026-11-24 20:38:33
Message-ID: E1xVxHc-00000000B5L-3gj4@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid unnecessary allocation for tablesync.c COPY buffer

copybuf serves only as a read-only parse buffer and is never
appended-to, enlarged or reset. Previously it was a file-level static
StringInfoData, allocated via makeStringInfo(), but that was abusing the
StringInfo interface.

A function-level static read-only StringInfo, as introduced by commit
f0efa5aec193, works just as well, and is less notionally bogus.

There are no functional changes here: unconsumed leftover bytes are
still consumed in the next call to this function, just like in the
previous coding.

Author: Chao Li <lic(at)highgo(dot)com>
Reviewed-by: Denis Smirnov <darthunix(at)gmail(dot)com>
Reviewed-by: ZizhuanLiu (X-MAN) <44973863(at)qq(dot)com>
Commitfest: https://commitfest.postgresql.org/patch/6757/
Discussion: https://postgr.es/m/5B2C9B4C-EAE6-4F21-AF99-613A561D26DC@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7720f61b7d6f5b1f702ecc1d46dd87d25808a785

Modified Files
--------------
src/backend/replication/logical/tablesync.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2026-11-24 22:23:53 pgsql: Fix standby logical slot creation while enabling logical decodin
Previous Message Fujii Masao 2026-11-24 11:44:51 pgsql: Improve SQLSTATE reporting for several error conditions