PG14: Avoid checking output-buffer-length for every encoded byte during pg_hex_encode - Mailing list pgsql-hackers

From Hans Buschmann
Subject PG14: Avoid checking output-buffer-length for every encoded byte during pg_hex_encode
Date
Msg-id 1629039545467.80333@nidsa.net
Whole thread Raw
Responses Re: PG14: Avoid checking output-buffer-length for every encoded byte during pg_hex_encode  (Ranier Vilela <ranier.vf@gmail.com>)
Re: PG14: Avoid checking output-buffer-length for every encoded byte during pg_hex_encode  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
During some development on encoding-related parts of postgres I stumbled over the new length-checking-code in
common/hex.c/pg_hex_encode.

Differently when comparing it to all versions before the output-buffer-length is checked during encoding of every
individualsource byte. 

This may impose quite a regression when using pg_dump on databases with many/big bytea or lo columns.

Because all criteria to check buffer-length are known in advance of encoding (srclen and destlen) I propose doing the
checkonly once before starting the while-loop. 

Please find the attached patch for pg14 and master, older versions did not have this behavior.

Tested on pg14-beta3, but applies also on master.

PS: This is my very first patch, I am in no way an experienced C-developer and don't have a smoothly running
developmentenvironment or experience yet. (originally mostly dealing with postgres on Windows). 

If it seems useful somebody could enter it as an open item / resolved item for pg14 after beta 3.

Thanks for looking!

Hans Buschmann


Attachment

pgsql-hackers by date:

Previous
From: Justin Pryzby
Date:
Subject: Re: prion failed with ERROR: missing chunk number 0 for toast value 14334 in pg_toast_2619
Next
From: Zhihong Yu
Date:
Subject: Re: Keep notnullattrs in RelOptInfo (Was part of UniqueKey patch series)