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 individual source 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 check only 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 development environment 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: hex_encode_length_check_outside_loop.patch
Description: hex_encode_length_check_outside_loop.patch

Reply via email to