agora inbox for [email protected]
help / color / mirror / Atom feedFrom: Justin Pryzby <[email protected]>
Subject: [PATCH 5/8] f!
Date: Sat, 14 Jan 2023 10:31:47 -0600
---
src/bin/pg_dump/compress_gzip.c | 13 +----------
src/bin/pg_dump/compress_io.c | 40 ++++++++++-----------------------
2 files changed, 13 insertions(+), 40 deletions(-)
diff --git a/src/bin/pg_dump/compress_gzip.c b/src/bin/pg_dump/compress_gzip.c
index 37c841c5a9b..a021d414624 100644
--- a/src/bin/pg_dump/compress_gzip.c
+++ b/src/bin/pg_dump/compress_gzip.c
@@ -220,8 +220,6 @@ InitCompressorGzip(CompressorState *cs, const pg_compress_specification *compres
cs->writeData = WriteDataToArchiveGzip;
cs->end = EndCompressorGzip;
- cs->compression_spec = *compression_spec;
-
gzipcs = (GzipCompressorState *) pg_malloc0(sizeof(GzipCompressorState));
cs->private_data = gzipcs;
@@ -291,17 +289,10 @@ static int
Gzip_close(CompressFileHandle *CFH)
{
gzFile gzfp = (gzFile) CFH->private_data;
- int save_errno;
- int ret;
CFH->private_data = NULL;
- ret = gzclose(gzfp);
-
- save_errno = errno;
- errno = save_errno;
-
- return ret;
+ return gzclose(gzfp);
}
static int
@@ -386,8 +377,6 @@ InitCompressGzip(CompressFileHandle *CFH, const pg_compress_specification *compr
CFH->eof_func = Gzip_eof;
CFH->get_error_func = Gzip_get_error;
- CFH->compression_spec = *compression_spec;
-
CFH->private_data = NULL;
}
#else /* HAVE_LIBZ */
diff --git a/src/bin/pg_dump/compress_io.c b/src/bin/pg_dump/compress_io.c
index c4ac4042794..7a1fd318c12 100644
--- a/src/bin/pg_dump/compress_io.c
+++ b/src/bin/pg_dump/compress_io.c
@@ -39,14 +39,13 @@
*
* The compressed stream API is a wrapper around the C standard fopen() and
* libz's gzopen() APIs and custom LZ4 calls which provide similar
- * functionality. It allows you to use the same functions for compressed and
- * uncompressed streams. cfopen_read() first tries to open the file with given
- * name, and if it fails, it tries to open the same file with the .gz suffix,
- * failing that it tries to open the same file with the .lz4 suffix.
- * cfopen_write() opens a file for writing, an extra argument specifies the
- * method to use should the file be compressed, and adds the appropriate
- * suffix, .gz or .lz4, to the filename if so. This allows you to easily handle
- * both compressed and uncompressed files.
+ * libz's gzopen() APIs. It allows you to use the same functions for
+ * compressed and uncompressed streams. cfopen_read() first tries to open
+ * the file with given name, and if it fails, it tries to open the same
+ * file with the .gz suffix. cfopen_write() opens a file for writing, an
+ * extra argument specifies if the file should be compressed, and adds the
+ * .gz suffix to the filename if so. This allows you to easily handle both
+ * compressed and uncompressed files.
*
* IDENTIFICATION
* src/bin/pg_dump/compress_io.c
@@ -110,8 +109,6 @@ InitCompressorNone(CompressorState *cs,
cs->readData = ReadDataFromArchiveNone;
cs->writeData = WriteDataToArchiveNone;
cs->end = EndCompressorNone;
-
- cs->compression_spec = *compression_spec;
}
/* Public interface routines */
@@ -126,7 +123,8 @@ AllocateCompressor(const pg_compress_specification *compression_spec,
cs = (CompressorState *) pg_malloc0(sizeof(CompressorState));
cs->readF = readF;
cs->writeF = writeF;
- cs->compression_spec = *compression_spec;
+ cs->compression_spec = *compression_spec; // XXX: should do this here rather than every compressor ?
+ // does it even need to be passed at all ?
switch (compression_spec->algorithm)
{
@@ -340,10 +338,9 @@ InitCompressFileHandle(const pg_compress_specification *compression_spec)
* Open a file for reading. 'path' is the file to open, and 'mode' should
* be either "r" or "rb".
*
- * If the file at 'path' does not exist, we append the "{.gz,.lz4}" suffix (i
- * 'path' doesn't already have it) and try again. So if you pass "foo" as
- * 'path', this will open either "foo" or "foo.gz" or "foo.lz4", trying in that
- * order.
+ * If the file at 'path' does not exist, we append the ".gz" suffix (if 'path'
+ * doesn't already have it) and try again. So if you pass "foo" as 'path',
+ * this will open either "foo" or "foo.gz".
*
* On failure, return NULL with an error code in errno.
*/
@@ -355,8 +352,6 @@ InitDiscoverCompressFileHandle(const char *path, const char *mode)
char *fname;
pg_compress_specification compression_spec = {0};
- // compression_spec.algorithm = PG_COMPRESSION_NONE;
-
Assert(strcmp(mode, "r") == 0 || strcmp(mode, "rb") == 0);
fname = strdup(path);
@@ -381,17 +376,6 @@ InitDiscoverCompressFileHandle(const char *path, const char *mode)
if (exists)
compression_spec.algorithm = PG_COMPRESSION_GZIP;
}
-#endif
-#ifdef USE_LZ4
- if (!exists)
- {
- free_keep_errno(fname);
- fname = psprintf("%s.lz4", path);
- exists = (stat(fname, &st) == 0);
-
- if (exists)
- compression_spec.algorithm = PG_COMPRESSION_LZ4;
- }
#endif
}
--
2.25.1
--aBaYPhOdNx+t7mr3
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="0006-Add-LZ4-compression-in-pg_-dump-restore.patch"
view thread (16+ messages) latest in thread
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: [email protected]
Cc: [email protected]
Subject: Re: [PATCH 5/8] f!
In-Reply-To: <no-message-id-105272@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox