PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include "common/file_perm.h"
#include "common/file_utils.h"
#include "common/logging.h"
#include "pgtar.h"
#include "receivelog.h"
#include "streamutil.h"
Go to the source code of this file.
Data Structures | |
struct | DirectoryMethodData |
struct | DirectoryMethodFile |
struct | TarMethodFile |
struct | TarMethodData |
Macros | |
#define | ZLIB_OUT_SIZE 4096 |
#define | LZ4_IN_SIZE 4096 |
#define | clear_error(wwmethod) ((wwmethod)->lasterrstring = NULL, (wwmethod)->lasterrno = 0) |
Typedefs | |
typedef struct DirectoryMethodData | DirectoryMethodData |
typedef struct DirectoryMethodFile | DirectoryMethodFile |
typedef struct TarMethodFile | TarMethodFile |
typedef struct TarMethodData | TarMethodData |
Functions | |
static Walfile * | dir_open_for_write (WalWriteMethod *wwmethod, const char *pathname, const char *temp_suffix, size_t pad_to_size) |
static int | dir_close (Walfile *f, WalCloseMethod method) |
static bool | dir_existsfile (WalWriteMethod *wwmethod, const char *pathname) |
static ssize_t | dir_get_file_size (WalWriteMethod *wwmethod, const char *pathname) |
static char * | dir_get_file_name (WalWriteMethod *wwmethod, const char *pathname, const char *temp_suffix) |
static ssize_t | dir_write (Walfile *f, const void *buf, size_t count) |
static int | dir_sync (Walfile *f) |
static bool | dir_finish (WalWriteMethod *wwmethod) |
static void | dir_free (WalWriteMethod *wwmethod) |
WalWriteMethod * | CreateWalDirectoryMethod (const char *basedir, pg_compress_algorithm compression_algorithm, int compression_level, bool sync) |
static Walfile * | tar_open_for_write (WalWriteMethod *wwmethod, const char *pathname, const char *temp_suffix, size_t pad_to_size) |
static int | tar_close (Walfile *f, WalCloseMethod method) |
static bool | tar_existsfile (WalWriteMethod *wwmethod, const char *pathname) |
static ssize_t | tar_get_file_size (WalWriteMethod *wwmethod, const char *pathname) |
static char * | tar_get_file_name (WalWriteMethod *wwmethod, const char *pathname, const char *temp_suffix) |
static ssize_t | tar_write (Walfile *f, const void *buf, size_t count) |
static int | tar_sync (Walfile *f) |
static bool | tar_finish (WalWriteMethod *wwmethod) |
static void | tar_free (WalWriteMethod *wwmethod) |
static bool | tar_write_padding_data (TarMethodFile *f, size_t bytes) |
WalWriteMethod * | CreateWalTarMethod (const char *tarbase, pg_compress_algorithm compression_algorithm, int compression_level, bool sync) |
const char * | GetLastWalMethodError (WalWriteMethod *wwmethod) |
Variables | |
static const WalWriteMethodOps | WalDirectoryMethodOps |
static const WalWriteMethodOps | WalTarMethodOps |
#define clear_error | ( | wwmethod | ) | ((wwmethod)->lasterrstring = NULL, (wwmethod)->lasterrno = 0) |
Definition at line 98 of file walmethods.c.
#define LZ4_IN_SIZE 4096 |
Definition at line 36 of file walmethods.c.
#define ZLIB_OUT_SIZE 4096 |
Definition at line 33 of file walmethods.c.
typedef struct DirectoryMethodData DirectoryMethodData |
typedef struct DirectoryMethodFile DirectoryMethodFile |
typedef struct TarMethodData TarMethodData |
typedef struct TarMethodFile TarMethodFile |
WalWriteMethod* CreateWalDirectoryMethod | ( | const char * | basedir, |
pg_compress_algorithm | compression_algorithm, | ||
int | compression_level, | ||
bool | sync | ||
) |
Definition at line 640 of file walmethods.c.
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().
WalWriteMethod* CreateWalTarMethod | ( | const char * | tarbase, |
pg_compress_algorithm | compression_algorithm, | ||
int | compression_level, | ||
bool | sync | ||
) |
Definition at line 1355 of file walmethods.c.
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().
|
static |
Definition at line 385 of file walmethods.c.
References Assert, DirectoryMethodFile::base, DirectoryMethodData::basedir, clear_error, close, CLOSE_NORMAL, CLOSE_UNLINK, WalWriteMethod::compression_algorithm, dir_get_file_name(), durable_rename(), DirectoryMethodFile::fd, filename, fsync_fname(), fsync_parent_path(), DirectoryMethodFile::fullpath, WalWriteMethod::lasterrno, WalWriteMethod::lasterrstring, MAXPGPATH, Walfile::pathname, PG_COMPRESSION_GZIP, PG_COMPRESSION_LZ4, pg_free(), pg_log_error, snprintf, WalWriteMethod::sync, DirectoryMethodFile::temp_suffix, write, and Walfile::wwmethod.
|
static |
Definition at line 584 of file walmethods.c.
References DirectoryMethodData::basedir, clear_error, close, fd(), MAXPGPATH, PG_BINARY, and snprintf.
|
static |
Definition at line 608 of file walmethods.c.
References DirectoryMethodData::basedir, clear_error, fsync_fname(), WalWriteMethod::lasterrno, and WalWriteMethod::sync.
|
static |
Definition at line 630 of file walmethods.c.
References DirectoryMethodData::basedir, and pg_free().
|
static |
Definition at line 102 of file walmethods.c.
References WalWriteMethod::compression_algorithm, filename, MAXPGPATH, PG_COMPRESSION_GZIP, PG_COMPRESSION_LZ4, pg_malloc0(), and snprintf.
Referenced by dir_close(), and dir_open_for_write().
|
static |
Definition at line 565 of file walmethods.c.
References DirectoryMethodData::basedir, WalWriteMethod::lasterrno, MAXPGPATH, snprintf, stat::st_size, and stat.
|
static |
Definition at line 117 of file walmethods.c.
References DirectoryMethodFile::base, DirectoryMethodData::basedir, clear_error, close, WalWriteMethod::compression_algorithm, WalWriteMethod::compression_level, Walfile::currpos, dir_get_file_name(), DirectoryMethodFile::fd, fd(), filename, fsync_fname(), fsync_parent_path(), DirectoryMethodFile::fullpath, WalWriteMethod::lasterrno, WalWriteMethod::lasterrstring, LZ4_IN_SIZE, MAXPGPATH, Walfile::pathname, PG_BINARY, PG_COMPRESSION_GZIP, PG_COMPRESSION_LZ4, PG_COMPRESSION_NONE, pg_file_create_mode, pg_free(), pg_malloc0(), pg_pwrite_zeros(), pg_strdup(), snprintf, WalWriteMethod::sync, DirectoryMethodFile::temp_suffix, write, and Walfile::wwmethod.
|
static |
Definition at line 514 of file walmethods.c.
References Assert, clear_error, WalWriteMethod::compression_algorithm, DirectoryMethodFile::fd, fd(), fsync, WalWriteMethod::lasterrno, WalWriteMethod::lasterrstring, PG_COMPRESSION_GZIP, PG_COMPRESSION_LZ4, WalWriteMethod::sync, write, and Walfile::wwmethod.
|
static |
Definition at line 304 of file walmethods.c.
References Assert, DirectoryMethodFile::base, buf, chunk, clear_error, WalWriteMethod::compression_algorithm, Walfile::currpos, DirectoryMethodFile::fd, WalWriteMethod::lasterrno, WalWriteMethod::lasterrstring, LZ4_IN_SIZE, PG_COMPRESSION_GZIP, PG_COMPRESSION_LZ4, remaining, write, and Walfile::wwmethod.
const char* GetLastWalMethodError | ( | WalWriteMethod * | wwmethod | ) |
Definition at line 1383 of file walmethods.c.
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().
|
static |
Definition at line 1042 of file walmethods.c.
References _, Assert, clear_error, CLOSE_NORMAL, CLOSE_UNLINK, WalWriteMethod::compression_algorithm, WalWriteMethod::compression_level, TarMethodData::currentfile, Walfile::currpos, TarMethodData::fd, ftruncate, GetLastWalMethodError(), TarMethodFile::header, WalWriteMethod::lasterrno, WalWriteMethod::lasterrstring, TarMethodFile::pad_to_size, PG_COMPRESSION_GZIP, PG_COMPRESSION_NONE, pg_fatal, pg_free(), print_tar_number(), strlcpy(), TAR_BLOCK_SIZE, TAR_OFFSET_CHECKSUM, TAR_OFFSET_NAME, TAR_OFFSET_SIZE, tar_sync(), tar_write(), tar_write_padding_data(), tarChecksum(), tarPaddingBytesRequired(), write, and Walfile::wwmethod.
Referenced by tar_finish().
|
static |
|
static |
Definition at line 1227 of file walmethods.c.
References _, Assert, TarMethodFile::base, clear_error, close, CLOSE_NORMAL, WalWriteMethod::compression_algorithm, TarMethodData::currentfile, TarMethodData::fd, fsync, fsync_fname(), fsync_parent_path(), WalWriteMethod::lasterrno, WalWriteMethod::lasterrstring, len, PG_COMPRESSION_GZIP, PG_COMPRESSION_NONE, WalWriteMethod::sync, tar_close(), TarMethodData::tarfilename, write, and ZLIB_OUT_SIZE.
|
static |
Definition at line 1336 of file walmethods.c.
References WalWriteMethod::compression_algorithm, PG_COMPRESSION_GZIP, pg_free(), and TarMethodData::tarfilename.
|
static |
Definition at line 825 of file walmethods.c.
References filename, MAXPGPATH, pg_malloc0(), and snprintf.
Referenced by tar_open_for_write().
|
static |
Definition at line 1007 of file walmethods.c.
References clear_error, and WalWriteMethod::lasterrno.
|
static |
Definition at line 837 of file walmethods.c.
References _, Assert, TarMethodFile::base, clear_error, WalWriteMethod::compression_algorithm, WalWriteMethod::compression_level, TarMethodData::currentfile, Walfile::currpos, TarMethodData::fd, TarMethodFile::header, WalWriteMethod::lasterrno, WalWriteMethod::lasterrstring, TarMethodFile::ofs_start, TarMethodFile::pad_to_size, Walfile::pathname, PG_BINARY, PG_COMPRESSION_GZIP, PG_COMPRESSION_NONE, pg_file_create_mode, pg_free(), pg_malloc(), pg_malloc0(), pg_strdup(), S_IRUSR, S_IWUSR, TAR_BLOCK_SIZE, tar_get_file_name(), TAR_OK, tar_write_padding_data(), tarCreateHeader(), TarMethodData::tarfilename, write, Walfile::wwmethod, and ZLIB_OUT_SIZE.
|
static |
Definition at line 1017 of file walmethods.c.
References Assert, clear_error, WalWriteMethod::compression_algorithm, TarMethodData::fd, fsync, WalWriteMethod::lasterrno, PG_COMPRESSION_NONE, WalWriteMethod::sync, and Walfile::wwmethod.
Referenced by tar_close().
|
static |
Definition at line 765 of file walmethods.c.
References Assert, buf, clear_error, WalWriteMethod::compression_algorithm, Walfile::currpos, TarMethodData::fd, WalWriteMethod::lasterrno, PG_COMPRESSION_GZIP, PG_COMPRESSION_NONE, write, and Walfile::wwmethod.
Referenced by tar_close(), and tar_write_padding_data().
|
static |
Definition at line 805 of file walmethods.c.
References TarMethodFile::base, PGAlignedXLogBlock::data, Min, and tar_write().
Referenced by tar_close(), and tar_open_for_write().
|
static |
Definition at line 58 of file walmethods.c.
Referenced by CreateWalDirectoryMethod().
|
static |
Definition at line 679 of file walmethods.c.
Referenced by CreateWalTarMethod().