Re: Add LZ4 compression in pg_dump
Michael Paquier <michael@paquier.xyz>
On Tue, Jul 05, 2022 at 01:22:47PM +0000, gkokolatos@pm.me wrote: > I have updated for "some" of the comments. This is not an unwillingness to > incorporate those specific comments. Simply this patchset had started to divert > heavily already based on comments from Mr. Paquier who had already requested for > the APIs to be refactored to use function pointers. This is happening in 0002 of > the patchset. 0001 of the patchset is using the new compression.h under common. > > This patchset should be considered a late draft, as commentary, documentation, > and some finer details are not yet finalized; because I am expecting the proposed > refactor to receive a wealth of comments. It would be helpful to understand if > the proposed direction is something worth to be worked upon, before moving to the > finer details. I have read through the patch set, and I like a lot the separation you are doing here with CompressFileHandle where a compression method has to specify a full set of callbacks depending on the actions that need to be taken. One advantage, as you patch shows, is that you reduce the dependency of each code path depending on the compression method, with #ifdefs and such located mostly into their own file structure, so as adding a new compression method becomes really easier. These callbacks are going to require much more documentation to describe what anybody using them should expect from them, and perhaps they could be renamed in a more generic way as the currect names come from POSIX (say read_char(), read_string()?), even if this patch has just inherited the names coming from pg_dump itself, but this can be tuned over and over. The split into three parts as of 0001 to plug into pg_dump the new compression option set, 0002 to introduce the callbacks and 0003 to add LZ4, building on the two first parts, makes sense to me. 0001 and 0002 could be done in a reversed order as they are mostly independent, this order is fine as-is. In short, I am fine with the proposed approach. +#define K_VERS_1_15 MAKE_ARCHIVE_VERSION(1, 15, 0) /* add compressionMethod + * in header */ Indeed, the dump format needs a version bump for this information. +static bool +parse_compression_option(const char *opt, + pg_compress_specification *compress_spec) This parsing logic in pg_dump.c looks a lot like what pg_receivewal.c does with its parse_compress_options() where, for compatibility: - If only a number is given: -- Assume no compression if level is 0. -- Assume gzip with given compression if level > 0. - If a string is found, assume a full spec, with optionally a level. So some consolidation could be done between both. By the way, I can see that GZCLOSE(), etc. are still defined in compress_io.h but they are not used. -- Michael
Commits
-
Advance input pointer when LZ4 compressing data
- 1a05c1d25299 16.0 landed
-
Null-terminate the output buffer of LZ4Stream_gets
- 3c18d90f8907 16.0 landed
-
Rework code defining default compression for dir/custom formats in pg_dump
- bedc1f0564d1 16.0 landed
-
pg_dump: Use only LZ4 frame format for compression
- 0070b66fef21 16.0 landed
-
Minor comment improvements for compress_lz4
- d0160ca11e31 16.0 landed
-
Unify buffer sizes in pg_dump compression API
- f081a48f9a91 16.0 landed
-
Improve type handling in pg_dump's compress file API
- d3b57755e60c 16.0 landed
-
Improve wording in pg_dump compression docs
- 6095069b40d7 16.0 landed
-
Fix condition in pg_dump TAP test
- 34ce11437497 16.0 landed
-
Add LZ4 compression to pg_dump
- 0da243fed087 16.0 landed
-
Introduce a generic pg_dump compression API
- e9960732a961 16.0 landed
-
Prepare pg_dump internals for additional compression methods
- 03d02f54a640 16.0 landed
-
Fix behavior with pg_restore -l and compressed dumps
- 783d8abc3b63 16.0 landed
-
Add 250c8ee07ed to git-blame-ignore-revs
- ff23b592ad66 16.0 cited
-
Provide test coverage in pg_dump for default behaviors with compression
- a7885c9bb22d 16.0 landed
-
Switch pg_dump to use compression specifications
- 5e73a6048849 16.0 landed
-
Refactor code parsing compression option values (-Z/--compress)
- d18655cc037a 16.0 landed
-
meson: Add some missing env settings for tests of pg_dump and pg_verifybackup
- 00ae5d6f588e 16.0 landed
-
Extend TAP tests of pg_dump to test for compression with gzip
- 98fe74218d97 15.0 landed
-
Clean up some dead code in pg_dump with tar format and gzip compression
- 8ac4c25a05d1 15.0 landed
-
Add TAP test in pg_dump with --format=tar and --compress
- edcedcc2c7bb 15.0 landed
-
Replace BASE_BACKUP COMPRESSION_LEVEL option with COMPRESSION_DETAIL.
- ffd53659c46a 15.0 cited
-
Refactor the pg_dump zlib code from pg_backup_custom.c to a separate file,
- bf9aa490db24 9.1.0 cited