1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-09 17:03:00 +03:00
Files
postgres/src/include/common/backup_compression.h
Robert Haas 51c0d186d9 Allow parallel zstd compression when taking a base backup.
libzstd allows transparent parallel compression just by setting
an option when creating the compression context, so permit that
for both client and server-side backup compression. To use this,
use something like pg_basebackup --compress WHERE-zstd:workers=N
where WHERE is "client" or "server" and N is an integer.

When compression is performed on the server side, this will spawn
threads inside the PostgreSQL backend. While there is almost no
PostgreSQL server code which is thread-safe, the threads here are used
internally by libzstd and touch only data structures controlled by
libzstd.

Patch by me, based in part on earlier work by Dipesh Pandit
and Jeevan Ladhe. Reviewed by Justin Pryzby.

Discussion: http://postgr.es/m/CA+Tgmobj6u-nWF-j=FemygUhobhryLxf9h-wJN7W-2rSsseHNA@mail.gmail.com
2022-03-30 09:41:26 -04:00

47 lines
1.3 KiB
C

/*-------------------------------------------------------------------------
*
* 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)
#define BACKUP_COMPRESSION_OPTION_WORKERS (1 << 1)
typedef struct bc_specification
{
bc_algorithm algorithm;
unsigned options; /* OR of BACKUP_COMPRESSION_OPTION constants */
int level;
int workers;
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