summaryrefslogtreecommitdiff
path: root/src/include/common/backup_compression.h
diff options
context:
space:
mode:
authorRobert Haas2022-03-23 13:19:14 +0000
committerRobert Haas2022-03-23 13:19:14 +0000
commitffd53659c46a54a6978bcb8c4424c1e157a2c0f1 (patch)
treef06520bc72f04ebb35b643a32e7a3ee42dee5378 /src/include/common/backup_compression.h
parent4a39f87acd6e681e5ded1239391d8a92645b43d6 (diff)
Replace BASE_BACKUP COMPRESSION_LEVEL option with COMPRESSION_DETAIL.
There are more compression parameters that can be specified than just an integer compression level, so rename the new COMPRESSION_LEVEL option to COMPRESSION_DETAIL before it gets released. Introduce a flexible syntax for that option to allow arbitrary options to be specified without needing to adjust the main replication grammar, and common code to parse it that is shared between the client and the server. This commit doesn't actually add any new compression parameters, so the only user-visible change is that you can now type something like pg_basebackup --compress gzip:level=5 instead of writing just pg_basebackup --compress gzip:5. However, it should make it easy to add new options. If for example gzip starts offering fries, we can support pg_basebackup --compress gzip:level=5,fries=true for the benefit of users who want fries with that. Along the way, this fixes a few things in pg_basebackup so that the pg_basebackup can be used with a server-side compression algorithm that pg_basebackup itself does not understand. For example, pg_basebackup --compress server-lz4 could still succeed even if only the server and not the client has LZ4 support, provided that the other options to pg_basebackup don't require the client to decompress the archive. Patch by me. Reviewed by Justin Pryzby and Dagfinn Ilmari Mannsåker. Discussion: http://postgr.es/m/CA+TgmoYvpetyRAbbg1M8b3-iHsaN4nsgmWPjOENu5-doHuJ7fA@mail.gmail.com
Diffstat (limited to 'src/include/common/backup_compression.h')
-rw-r--r--src/include/common/backup_compression.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/include/common/backup_compression.h b/src/include/common/backup_compression.h
new file mode 100644
index 00000000000..0565cbc657d
--- /dev/null
+++ b/src/include/common/backup_compression.h
@@ -0,0 +1,44 @@
+/*-------------------------------------------------------------------------
+ *
+ * backup_compression.h
+ *
+ * Shared definitions for backup compression methods and specifications.
+ *
+ * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * src/common/backup_compression.h
+ *-------------------------------------------------------------------------
+ */
+
+#ifndef BACKUP_COMPRESSION_H
+#define BACKUP_COMPRESSION_H
+
+typedef enum bc_algorithm
+{
+ BACKUP_COMPRESSION_NONE,
+ BACKUP_COMPRESSION_GZIP,
+ BACKUP_COMPRESSION_LZ4,
+ BACKUP_COMPRESSION_ZSTD
+} bc_algorithm;
+
+#define BACKUP_COMPRESSION_OPTION_LEVEL (1 << 0)
+
+typedef struct bc_specification
+{
+ bc_algorithm algorithm;
+ unsigned options; /* OR of BACKUP_COMPRESSION_OPTION constants */
+ int level;
+ char *parse_error; /* NULL if parsing was OK, else message */
+} bc_specification;
+
+extern bool parse_bc_algorithm(char *name, bc_algorithm *algorithm);
+extern const char *get_bc_algorithm_name(bc_algorithm algorithm);
+
+extern void parse_bc_specification(bc_algorithm algorithm,
+ char *specification,
+ bc_specification *result);
+
+extern char *validate_bc_specification(bc_specification *);
+
+#endif