PostgreSQL Source Code  git master
walmethods.h File Reference
Include dependency graph for walmethods.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  WalWriteMethod


typedef void * Walfile
typedef struct WalWriteMethod WalWriteMethod




WalWriteMethodCreateWalDirectoryMethod (const char *basedir, pg_compress_algorithm compression_algo, int compression, bool sync)
WalWriteMethodCreateWalTarMethod (const char *tarbase, pg_compress_algorithm compression_algo, int compression, bool sync)
void FreeWalDirectoryMethod (void)
void FreeWalTarMethod (void)

Typedef Documentation

◆ Walfile

typedef void* Walfile

Definition at line 14 of file walmethods.h.

◆ WalWriteMethod

Definition at line 14 of file walmethods.h.

Enumeration Type Documentation

◆ WalCloseMethod


Definition at line 16 of file walmethods.h.

17 {
Definition: walmethods.h:17
Definition: walmethods.h:19
Definition: walmethods.h:20
Definition: walmethods.h:18

Function Documentation

◆ CreateWalDirectoryMethod()

WalWriteMethod* CreateWalDirectoryMethod ( const char *  basedir,
pg_compress_algorithm  compression_algo,
int  compression,
bool  sync 

Definition at line 625 of file walmethods.c.

628 {
629  WalWriteMethod *method;
631  method = pg_malloc0(sizeof(WalWriteMethod));
633  method->write = dir_write;
638  method->close = dir_close;
639  method->sync = dir_sync;
640  method->existsfile = dir_existsfile;
641  method->finish = dir_finish;
642  method->getlasterror = dir_getlasterror;
646  dir_data->compression_level = compression_level;
648  dir_data->sync = sync;
650  return method;
651 }
void * pg_malloc0(size_t size)
Definition: fe_memutils.c:53
char * pg_strdup(const char *in)
Definition: fe_memutils.c:85
static char * basedir
static pg_compress_algorithm compression_algorithm
Definition: pg_receivewal.c:55
pg_compress_algorithm compression_algorithm
Definition: walmethods.c:52
const char *(* getlasterror)(void)
Definition: walmethods.h:88
off_t(* get_current_pos)(Walfile f)
Definition: walmethods.h:72
ssize_t(* get_file_size)(const char *pathname)
Definition: walmethods.h:54
Walfile(* open_for_write)(const char *pathname, const char *temp_suffix, size_t pad_to_size)
Definition: walmethods.h:42
bool(* existsfile)(const char *pathname)
Definition: walmethods.h:51
int(* close)(Walfile f, WalCloseMethod method)
Definition: walmethods.h:48
char *(* get_file_name)(const char *pathname, const char *temp_suffix)
Definition: walmethods.h:60
int(* sync)(Walfile f)
Definition: walmethods.h:77
ssize_t(* write)(Walfile f, const void *buf, size_t count)
Definition: walmethods.h:69
pg_compress_algorithm(* compression_algorithm)(void)
Definition: walmethods.h:63
bool(* finish)(void)
Definition: walmethods.h:85
static bool dir_existsfile(const char *pathname)
Definition: walmethods.c:586
static Walfile dir_open_for_write(const char *pathname, const char *temp_suffix, size_t pad_to_size)
Definition: walmethods.c:108
static const char * dir_getlasterror(void)
Definition: walmethods.c:86
static ssize_t dir_write(Walfile f, const void *buf, size_t count)
Definition: walmethods.c:293
static bool dir_finish(void)
Definition: walmethods.c:604
static char * dir_get_file_name(const char *pathname, const char *temp_suffix)
Definition: walmethods.c:94
static ssize_t dir_get_file_size(const char *pathname)
Definition: walmethods.c:562
static off_t dir_get_current_pos(Walfile f)
Definition: walmethods.c:374
static int dir_close(Walfile f, WalCloseMethod method)
Definition: walmethods.c:384
static int dir_sync(Walfile f)
Definition: walmethods.c:511
static DirectoryMethodData * dir_data
Definition: walmethods.c:58
static pg_compress_algorithm dir_compression_algorithm(void)
Definition: walmethods.c:580

References basedir, DirectoryMethodData::basedir, WalWriteMethod::close, compression_algorithm, DirectoryMethodData::compression_algorithm, WalWriteMethod::compression_algorithm, DirectoryMethodData::compression_level, dir_close(), dir_compression_algorithm(), dir_data, dir_existsfile(), dir_finish(), dir_get_current_pos(), dir_get_file_name(), dir_get_file_size(), dir_getlasterror(), dir_open_for_write(), dir_sync(), dir_write(), WalWriteMethod::existsfile, WalWriteMethod::finish, WalWriteMethod::get_current_pos, WalWriteMethod::get_file_name, WalWriteMethod::get_file_size, WalWriteMethod::getlasterror, WalWriteMethod::open_for_write, pg_malloc0(), pg_strdup(), DirectoryMethodData::sync, WalWriteMethod::sync, and WalWriteMethod::write.

Referenced by LogStreamerMain(), and StreamLog().

◆ CreateWalTarMethod()

WalWriteMethod* CreateWalTarMethod ( const char *  tarbase,
pg_compress_algorithm  compression_algo,
int  compression,
bool  sync 

Definition at line 1338 of file walmethods.c.

1341 {
1342  WalWriteMethod *method;
1343  const char *suffix = (compression_algorithm == PG_COMPRESSION_GZIP) ?
1344  ".tar.gz" : ".tar";
1346  method = pg_malloc0(sizeof(WalWriteMethod));
1348  method->write = tar_write;
1350  method->get_file_size = tar_get_file_size;
1351  method->get_file_name = tar_get_file_name;
1353  method->close = tar_close;
1354  method->sync = tar_sync;
1355  method->existsfile = tar_existsfile;
1356  method->finish = tar_finish;
1357  method->getlasterror = tar_getlasterror;
1359  tar_data = pg_malloc0(sizeof(TarMethodData));
1360  tar_data->tarfilename = pg_malloc0(strlen(tarbase) + strlen(suffix) + 1);
1361  sprintf(tar_data->tarfilename, "%s%s", tarbase, suffix);
1362  tar_data->fd = -1;
1364  tar_data->compression_level = compression_level;
1365  tar_data->sync = sync;
1366 #ifdef HAVE_LIBZ
1368  tar_data->zlibOut = (char *) pg_malloc(ZLIB_OUT_SIZE + 1);
1369 #endif
1371  return method;
1372 }
Definition: compression.h:20
void * pg_malloc(size_t size)
Definition: fe_memutils.c:47
#define sprintf
Definition: port.h:227
int compression_level
Definition: walmethods.c:681
pg_compress_algorithm compression_algorithm
Definition: walmethods.c:680
char * tarfilename
Definition: walmethods.c:678
static bool tar_finish(void)
Definition: walmethods.c:1224
static int tar_sync(Walfile f)
Definition: walmethods.c:1017
static pg_compress_algorithm tar_compression_algorithm(void)
Definition: walmethods.c:1002
static Walfile tar_open_for_write(const char *pathname, const char *temp_suffix, size_t pad_to_size)
Definition: walmethods.c:829
static const char * tar_getlasterror(void)
Definition: walmethods.c:699
static off_t tar_get_current_pos(Walfile f)
Definition: walmethods.c:1008
Definition: walmethods.c:36
static int tar_close(Walfile f, WalCloseMethod method)
Definition: walmethods.c:1041
static TarMethodData * tar_data
Definition: walmethods.c:691
static ssize_t tar_get_file_size(const char *pathname)
Definition: walmethods.c:992
static char * tar_get_file_name(const char *pathname, const char *temp_suffix)
Definition: walmethods.c:818
static ssize_t tar_write(Walfile f, const void *buf, size_t count)
Definition: walmethods.c:759
static bool tar_existsfile(const char *pathname)
Definition: walmethods.c:1216

References WalWriteMethod::close, compression_algorithm, TarMethodData::compression_algorithm, WalWriteMethod::compression_algorithm, TarMethodData::compression_level, WalWriteMethod::existsfile, TarMethodData::fd, WalWriteMethod::finish, WalWriteMethod::get_current_pos, WalWriteMethod::get_file_name, WalWriteMethod::get_file_size, WalWriteMethod::getlasterror, WalWriteMethod::open_for_write, PG_COMPRESSION_GZIP, pg_malloc(), pg_malloc0(), sprintf, TarMethodData::sync, WalWriteMethod::sync, tar_close(), tar_compression_algorithm(), tar_data, tar_existsfile(), tar_finish(), tar_get_current_pos(), tar_get_file_name(), tar_get_file_size(), tar_getlasterror(), tar_open_for_write(), tar_sync(), tar_write(), TarMethodData::tarfilename, WalWriteMethod::write, and ZLIB_OUT_SIZE.

Referenced by LogStreamerMain().

◆ FreeWalDirectoryMethod()

void FreeWalDirectoryMethod ( void  )

Definition at line 654 of file walmethods.c.

655 {
657  pg_free(dir_data);
658  dir_data = NULL;
659 }
void pg_free(void *ptr)
Definition: fe_memutils.c:105

References DirectoryMethodData::basedir, dir_data, and pg_free().

Referenced by LogStreamerMain(), and StreamLog().

◆ FreeWalTarMethod()

void FreeWalTarMethod ( void  )

Definition at line 1375 of file walmethods.c.

1376 {
1378 #ifdef HAVE_LIBZ
1380  pg_free(tar_data->zlibOut);
1381 #endif
1382  pg_free(tar_data);
1383  tar_data = NULL;
1384 }

References TarMethodData::compression_algorithm, PG_COMPRESSION_GZIP, pg_free(), tar_data, and TarMethodData::tarfilename.

Referenced by LogStreamerMain().