pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pg_dump: Fix gzip compression of empty data
Date: Wed, 29 Mar 2023 00:37:14 +0000
Message-ID: <E1phJoP-000Eif-Ex@gemulon.postgresql.org> (raw)

pg_dump: Fix gzip compression of empty data

The pg_dump Compressor API has three basic callbacks - Allocate, Write
and End.  The gzip implementation (since e9960732a) wrongly assumed the
Write function would always be called, and deferred the initialization
of the internal compression system until the first such call.  But when
there's no data to compress (e.g. for empty LO), this would result in
not finalizing the compression state (because it was not actually
initialized), producing invalid dump.

Fixed by initializing the internal compression system in the Allocate
call, whenever the caller provides the Write.  For decompression the
state is not needed, so we leave the private_data member unpopulated.

Introduces a pg_dump TAP test compressing an empty large object.

This also rearranges the functions to their original order, to make
diffs against older code simpler to understand.  Finally, replace an
unreachable pg_fatal() with a simple assert check.

Reported-by: Justin Pryzby
Author: Justin Pryzby, Georgios Kokolatos
Reviewed-by: Georgios Kokolatos, Tomas Vondra

https://postgr.es/m/20230228235834.GC30529%40telsasoft.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/00d9dcf5bebbb355152a60f0e2120cdf7f9e7ddd

Modified Files
--------------
src/bin/pg_dump/compress_gzip.c  | 136 ++++++++++++++++++++++-----------------
src/bin/pg_dump/t/002_pg_dump.pl |  23 +++++++
2 files changed, 100 insertions(+), 59 deletions(-)



Message-ID: <E1phJoP-000Eif-Ex@gemulon.postgresql.org>
Permalink:  ../E1phJoP-000Eif-Ex@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1phJoP-000Eif-Ex@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tomas.vondra@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: pg_dump: Fix gzip compression of empty data
  In-Reply-To: <E1phJoP-000Eif-Ex@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox