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  Walfile
 
struct  WalWriteMethodOps
 
struct  WalWriteMethod
 

Typedefs

typedef struct WalWriteMethod WalWriteMethod
 
typedef struct WalWriteMethodOps WalWriteMethodOps
 

Enumerations

enum  WalCloseMethod { CLOSE_NORMAL , CLOSE_UNLINK , CLOSE_NO_RENAME }
 

Functions

WalWriteMethodCreateWalDirectoryMethod (const char *basedir, pg_compress_algorithm compression_algorithm, int compression_level, bool sync)
 
WalWriteMethodCreateWalTarMethod (const char *tarbase, pg_compress_algorithm compression_algorithm, int compression_level, bool sync)
 
const char * GetLastWalMethodError (WalWriteMethod *wwmethod)
 

Typedef Documentation

◆ WalWriteMethod

Definition at line 1 of file walmethods.h.

◆ WalWriteMethodOps

Enumeration Type Documentation

◆ WalCloseMethod

Enumerator
CLOSE_NORMAL 
CLOSE_UNLINK 
CLOSE_NO_RENAME 

Definition at line 30 of file walmethods.h.

31 {
WalCloseMethod
Definition: walmethods.h:31
@ CLOSE_UNLINK
Definition: walmethods.h:33
@ CLOSE_NO_RENAME
Definition: walmethods.h:34
@ CLOSE_NORMAL
Definition: walmethods.h:32

Function Documentation

◆ CreateWalDirectoryMethod()

WalWriteMethod* CreateWalDirectoryMethod ( const char *  basedir,
pg_compress_algorithm  compression_algorithm,
int  compression_level,
bool  sync 
)

Definition at line 635 of file walmethods.c.

638 {
639  DirectoryMethodData *wwmethod;
640 
641  wwmethod = pg_malloc0(sizeof(DirectoryMethodData));
642  *((const WalWriteMethodOps **) &wwmethod->base.ops) =
645  wwmethod->base.compression_level = compression_level;
646  wwmethod->base.sync = sync;
647  clear_error(&wwmethod->base);
648  wwmethod->basedir = pg_strdup(basedir);
649 
650  return &wwmethod->base;
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
WalWriteMethod base
Definition: walmethods.c:75
int compression_level
Definition: walmethods.h:106
const WalWriteMethodOps * ops
Definition: walmethods.h:104
pg_compress_algorithm compression_algorithm
Definition: walmethods.h:105
#define clear_error(wwmethod)
Definition: walmethods.c:98
const WalWriteMethodOps WalDirectoryMethodOps
Definition: walmethods.c:58

References DirectoryMethodData::base, basedir, DirectoryMethodData::basedir, clear_error, compression_algorithm, WalWriteMethod::compression_algorithm, WalWriteMethod::compression_level, WalWriteMethod::ops, pg_malloc0(), pg_strdup(), WalWriteMethod::sync, and WalDirectoryMethodOps.

Referenced by LogStreamerMain(), and StreamLog().

◆ CreateWalTarMethod()

WalWriteMethod* CreateWalTarMethod ( const char *  tarbase,
pg_compress_algorithm  compression_algorithm,
int  compression_level,
bool  sync 
)

Definition at line 1350 of file walmethods.c.

1353 {
1354  TarMethodData *wwmethod;
1355  const char *suffix = (compression_algorithm == PG_COMPRESSION_GZIP) ?
1356  ".tar.gz" : ".tar";
1357 
1358  wwmethod = pg_malloc0(sizeof(TarMethodData));
1359  *((const WalWriteMethodOps **) &wwmethod->base.ops) =
1360  &WalTarMethodOps;
1362  wwmethod->base.compression_level = compression_level;
1363  wwmethod->base.sync = sync;
1364  clear_error(&wwmethod->base);
1365 
1366  wwmethod->tarfilename = pg_malloc0(strlen(tarbase) + strlen(suffix) + 1);
1367  sprintf(wwmethod->tarfilename, "%s%s", tarbase, suffix);
1368  wwmethod->fd = -1;
1369 #ifdef HAVE_LIBZ
1371  wwmethod->zlibOut = (char *) pg_malloc(ZLIB_OUT_SIZE + 1);
1372 #endif
1373 
1374  return &wwmethod->base;
1375 }
@ PG_COMPRESSION_GZIP
Definition: compression.h:20
void * pg_malloc(size_t size)
Definition: fe_memutils.c:47
#define sprintf
Definition: port.h:240
WalWriteMethod base
Definition: walmethods.c:696
char * tarfilename
Definition: walmethods.c:697
const WalWriteMethodOps WalTarMethodOps
Definition: walmethods.c:674
#define ZLIB_OUT_SIZE
Definition: walmethods.c:33

References TarMethodData::base, clear_error, compression_algorithm, WalWriteMethod::compression_algorithm, WalWriteMethod::compression_level, TarMethodData::fd, WalWriteMethod::ops, PG_COMPRESSION_GZIP, pg_malloc(), pg_malloc0(), sprintf, WalWriteMethod::sync, TarMethodData::tarfilename, WalTarMethodOps, and ZLIB_OUT_SIZE.

Referenced by LogStreamerMain().

◆ GetLastWalMethodError()

const char* GetLastWalMethodError ( WalWriteMethod wwmethod)

Definition at line 1378 of file walmethods.c.

1379 {
1380  if (wwmethod->lasterrstring)
1381  return wwmethod->lasterrstring;
1382  return strerror(wwmethod->lasterrno);
1383 }
#define strerror
Definition: port.h:251
const char * lasterrstring
Definition: walmethods.h:108

References WalWriteMethod::lasterrno, WalWriteMethod::lasterrstring, and strerror.

Referenced by close_walfile(), HandleCopyStream(), mark_file_as_archived(), open_walfile(), ProcessKeepaliveMsg(), ProcessXLogDataMsg(), ReceiveXlogStream(), tar_close(), and writeTimeLineHistoryFile().