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 31 of file walmethods.h.

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

Function Documentation

◆ CreateWalDirectoryMethod()

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

Definition at line 640 of file walmethods.c.

643 {
644  DirectoryMethodData *wwmethod;
645 
646  wwmethod = pg_malloc0(sizeof(DirectoryMethodData));
647  *((const WalWriteMethodOps **) &wwmethod->base.ops) =
650  wwmethod->base.compression_level = compression_level;
651  wwmethod->base.sync = sync;
652  clear_error(&wwmethod->base);
653  wwmethod->basedir = pg_strdup(basedir);
654 
655  return &wwmethod->base;
656 }
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:107
const WalWriteMethodOps * ops
Definition: walmethods.h:105
pg_compress_algorithm compression_algorithm
Definition: walmethods.h:106
#define clear_error(wwmethod)
Definition: walmethods.c:98
static 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 1355 of file walmethods.c.

1358 {
1359  TarMethodData *wwmethod;
1360  const char *suffix = (compression_algorithm == PG_COMPRESSION_GZIP) ?
1361  ".tar.gz" : ".tar";
1362 
1363  wwmethod = pg_malloc0(sizeof(TarMethodData));
1364  *((const WalWriteMethodOps **) &wwmethod->base.ops) =
1365  &WalTarMethodOps;
1367  wwmethod->base.compression_level = compression_level;
1368  wwmethod->base.sync = sync;
1369  clear_error(&wwmethod->base);
1370 
1371  wwmethod->tarfilename = pg_malloc0(strlen(tarbase) + strlen(suffix) + 1);
1372  sprintf(wwmethod->tarfilename, "%s%s", tarbase, suffix);
1373  wwmethod->fd = -1;
1374 #ifdef HAVE_LIBZ
1376  wwmethod->zlibOut = (char *) pg_malloc(ZLIB_OUT_SIZE + 1);
1377 #endif
1378 
1379  return &wwmethod->base;
1380 }
@ PG_COMPRESSION_GZIP
Definition: compression.h:24
void * pg_malloc(size_t size)
Definition: fe_memutils.c:47
#define sprintf
Definition: port.h:240
WalWriteMethod base
Definition: walmethods.c:701
char * tarfilename
Definition: walmethods.c:702
static const WalWriteMethodOps WalTarMethodOps
Definition: walmethods.c:679
#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 1383 of file walmethods.c.

1384 {
1385  if (wwmethod->lasterrstring)
1386  return wwmethod->lasterrstring;
1387  return strerror(wwmethod->lasterrno);
1388 }
#define strerror
Definition: port.h:251
const char * lasterrstring
Definition: walmethods.h:109

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().