PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include "access/heaptoast.h"
#include "access/multixact.h"
#include "access/transam.h"
#include "access/xlog.h"
#include "access/xlog_internal.h"
#include "common/controldata_utils.h"
#include "common/fe_memutils.h"
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/restricted_token.h"
#include "common/string.h"
#include "fe_utils/option_utils.h"
#include "getopt_long.h"
#include "pg_getopt.h"
#include "storage/large_object.h"
Go to the source code of this file.
Macros | |
#define | FRONTEND 1 |
#define | ARCHSTATDIR XLOGDIR "/archive_status" |
#define | WALSUMMARYDIR XLOGDIR "/summaries" |
#define | WALSUMMARY_NHEXCHARS 40 |
Functions | |
static void | CheckDataVersion (void) |
static bool | read_controlfile (void) |
static void | GuessControlValues (void) |
static void | PrintControlValues (bool guessed) |
static void | PrintNewControlValues (void) |
static void | RewriteControlFile (void) |
static void | FindEndOfXLOG (void) |
static void | KillExistingXLOG (void) |
static void | KillExistingArchiveStatus (void) |
static void | KillExistingWALSummaries (void) |
static void | WriteEmptyXLOG (void) |
static void | usage (void) |
int | main (int argc, char *argv[]) |
Variables | |
static ControlFileData | ControlFile |
static XLogSegNo | newXlogSegNo |
static bool | guessed = false |
static const char * | progname |
static uint32 | set_xid_epoch = (uint32) -1 |
static TransactionId | set_oldest_xid = 0 |
static TransactionId | set_xid = 0 |
static TransactionId | set_oldest_commit_ts_xid = 0 |
static TransactionId | set_newest_commit_ts_xid = 0 |
static Oid | set_oid = 0 |
static MultiXactId | set_mxid = 0 |
static MultiXactOffset | set_mxoff = (MultiXactOffset) -1 |
static TimeLineID | minXlogTli = 0 |
static XLogSegNo | minXlogSegNo = 0 |
static int | WalSegSz |
static int | set_wal_segsize |
#define ARCHSTATDIR XLOGDIR "/archive_status" |
#define FRONTEND 1 |
Definition at line 35 of file pg_resetwal.c.
#define WALSUMMARY_NHEXCHARS 40 |
#define WALSUMMARYDIR XLOGDIR "/summaries" |
|
static |
Definition at line 518 of file pg_resetwal.c.
References exit(), pg_fatal, pg_log_error, pg_log_error_detail, and pg_strip_crlf().
Referenced by main().
|
static |
Definition at line 907 of file pg_resetwal.c.
References ControlFileData::checkPointCopy, closedir(), ControlFile, dirent::d_name, IsPartialXLogFileName(), IsXLogFileName(), newXlogSegNo, opendir(), pg_fatal, readdir(), CheckPoint::redo, WalSegSz, XLByteToSeg, ControlFileData::xlog_seg_size, XLOGDIR, and XLogFromFileName().
Referenced by main().
|
static |
Definition at line 633 of file pg_resetwal.c.
References ControlFileData::blcksz, CATALOG_VERSION_NO, ControlFileData::catalog_version_no, ControlFileData::checkPoint, ControlFileData::checkPointCopy, ControlFile, DB_SHUTDOWNED, DEFAULT_XLOG_SEG_SIZE, FirstGenbkiObjectId, FirstMultiXactId, FirstNormalTransactionId, FirstNormalUnloggedLSN, ControlFileData::float8ByVal, FLOAT8PASSBYVAL, ControlFileData::floatFormat, FLOATFORMAT_VALUE, CheckPoint::fullPageWrites, FullTransactionIdFromEpochAndXid(), gettimeofday(), guessed, INDEX_MAX_KEYS, ControlFileData::indexMaxKeys, InvalidOid, InvalidTransactionId, ControlFileData::loblksize, LOBLKSIZE, ControlFileData::max_locks_per_xact, ControlFileData::max_prepared_xacts, ControlFileData::max_wal_senders, ControlFileData::max_worker_processes, ControlFileData::maxAlign, ControlFileData::MaxConnections, ControlFileData::nameDataLen, NAMEDATALEN, CheckPoint::nextMulti, CheckPoint::nextMultiOffset, CheckPoint::nextOid, CheckPoint::nextXid, CheckPoint::oldestActiveXid, CheckPoint::oldestMulti, CheckPoint::oldestMultiDB, CheckPoint::oldestXid, CheckPoint::oldestXidDB, PG_CONTROL_VERSION, ControlFileData::pg_control_version, CheckPoint::PrevTimeLineID, CheckPoint::redo, ControlFileData::relseg_size, SizeOfXLogLongPHD, ControlFileData::state, ControlFileData::system_identifier, CheckPoint::ThisTimeLineID, CheckPoint::time, ControlFileData::time, TOAST_MAX_CHUNK_SIZE, ControlFileData::toast_max_chunk_size, ControlFileData::track_commit_timestamp, ControlFileData::unloggedLSN, ControlFileData::wal_level, WAL_LEVEL_MINIMAL, ControlFileData::wal_log_hints, ControlFileData::xlog_blcksz, and ControlFileData::xlog_seg_size.
Referenced by main().
|
static |
Definition at line 1006 of file pg_resetwal.c.
References ARCHSTATDIR, closedir(), dirent::d_name, MAXPGPATH, opendir(), pg_fatal, readdir(), snprintf, and XLOG_FNAME_LEN.
Referenced by main().
|
static |
Definition at line 1043 of file pg_resetwal.c.
References ARCHSTATDIR, closedir(), dirent::d_name, MAXPGPATH, opendir(), pg_fatal, readdir(), snprintf, WALSUMMARY_NHEXCHARS, and WALSUMMARYDIR.
Referenced by main().
|
static |
Definition at line 973 of file pg_resetwal.c.
References closedir(), dirent::d_name, IsPartialXLogFileName(), IsXLogFileName(), MAXPGPATH, opendir(), pg_fatal, readdir(), snprintf, and XLOGDIR.
Referenced by main().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 94 of file pg_resetwal.c.
References _, CheckDataVersion(), ControlFileData::checkPointCopy, ControlFile, DataDir, DB_SHUTDOWNED, EpochFromFullTransactionId, exit(), fd(), FindEndOfXLOG(), FirstMultiXactId, FirstNormalTransactionId, FullTransactionIdFromEpochAndXid(), get_progname(), get_restricted_token(), GetDataDirectoryCreatePerm(), getopt_long(), GuessControlValues(), guessed, InvalidOid, InvalidTransactionId, IsValidWalSegSize, KillExistingArchiveStatus(), KillExistingWALSummaries(), KillExistingXLOG(), minXlogSegNo, minXlogTli, CheckPoint::newestCommitTsXid, newXlogSegNo, CheckPoint::nextMulti, CheckPoint::nextMultiOffset, CheckPoint::nextOid, CheckPoint::nextXid, no_argument, CheckPoint::oldestCommitTsXid, CheckPoint::oldestMulti, CheckPoint::oldestMultiDB, CheckPoint::oldestXid, CheckPoint::oldestXidDB, optarg, optind, option_parse_int(), pg_fatal, pg_log_error, pg_log_error_detail, pg_log_error_hint, pg_logging_init(), pg_mode_mask, pg_strdup(), PG_TEXTDOMAIN, CheckPoint::PrevTimeLineID, PrintControlValues(), printf, PrintNewControlValues(), progname, read_controlfile(), required_argument, RewriteControlFile(), set_mxid, set_mxoff, set_newest_commit_ts_xid, set_oid, set_oldest_commit_ts_xid, set_oldest_xid, set_pglocale_pgservice(), set_wal_segsize, set_xid, set_xid_epoch, ControlFileData::state, CheckPoint::ThisTimeLineID, TransactionIdIsNormal, usage(), WalSegSz, WriteEmptyXLOG(), XidFromFullTransactionId, XLOG_FNAME_LEN, ControlFileData::xlog_seg_size, and XLogFromFileName().
|
static |
Definition at line 716 of file pg_resetwal.c.
References _, ControlFileData::blcksz, ControlFileData::catalog_version_no, ControlFileData::checkPointCopy, ControlFile, ControlFileData::data_checksum_version, EpochFromFullTransactionId, ControlFileData::float8ByVal, CheckPoint::fullPageWrites, guessed, ControlFileData::indexMaxKeys, ControlFileData::loblksize, ControlFileData::maxAlign, ControlFileData::nameDataLen, CheckPoint::newestCommitTsXid, CheckPoint::nextMulti, CheckPoint::nextMultiOffset, CheckPoint::nextOid, CheckPoint::nextXid, CheckPoint::oldestActiveXid, CheckPoint::oldestCommitTsXid, CheckPoint::oldestMulti, CheckPoint::oldestMultiDB, CheckPoint::oldestXid, CheckPoint::oldestXidDB, ControlFileData::pg_control_version, printf, ControlFileData::relseg_size, ControlFileData::system_identifier, CheckPoint::ThisTimeLineID, ControlFileData::toast_max_chunk_size, XidFromFullTransactionId, ControlFileData::xlog_blcksz, and ControlFileData::xlog_seg_size.
Referenced by main().
|
static |
Definition at line 789 of file pg_resetwal.c.
References _, ControlFileData::checkPointCopy, ControlFile, EpochFromFullTransactionId, MAXFNAMELEN, CheckPoint::newestCommitTsXid, newXlogSegNo, CheckPoint::nextMulti, CheckPoint::nextMultiOffset, CheckPoint::nextOid, CheckPoint::nextXid, CheckPoint::oldestCommitTsXid, CheckPoint::oldestMulti, CheckPoint::oldestMultiDB, CheckPoint::oldestXid, CheckPoint::oldestXidDB, printf, set_mxid, set_mxoff, set_newest_commit_ts_xid, set_oid, set_oldest_commit_ts_xid, set_wal_segsize, set_xid, set_xid_epoch, CheckPoint::ThisTimeLineID, WalSegSz, XidFromFullTransactionId, ControlFileData::xlog_seg_size, and XLogFileName().
Referenced by main().
|
static |
Definition at line 559 of file pg_resetwal.c.
References close, COMP_CRC32C, ControlFile, crc, EQ_CRC32C, exit(), fd(), FIN_CRC32C, guessed, INIT_CRC32C, IsValidWalSegSize, len, ngettext, PG_BINARY, PG_CONTROL_FILE_SIZE, PG_CONTROL_VERSION, pg_fatal, pg_log_error, pg_log_error_hint, pg_log_warning, pg_malloc(), read, XLOG_CONTROL_FILE, and ControlFileData::xlog_seg_size.
Referenced by main().
|
static |
Definition at line 861 of file pg_resetwal.c.
References ControlFileData::backupEndPoint, ControlFileData::backupEndRequired, ControlFileData::backupStartPoint, ControlFileData::checkPoint, ControlFileData::checkPointCopy, ControlFile, DB_SHUTDOWNED, ControlFileData::max_locks_per_xact, ControlFileData::max_prepared_xacts, ControlFileData::max_wal_senders, ControlFileData::max_worker_processes, ControlFileData::MaxConnections, ControlFileData::minRecoveryPoint, ControlFileData::minRecoveryPointTLI, newXlogSegNo, CheckPoint::redo, SizeOfXLogLongPHD, ControlFileData::state, CheckPoint::time, ControlFileData::track_commit_timestamp, update_controlfile(), ControlFileData::wal_level, WAL_LEVEL_MINIMAL, ControlFileData::wal_log_hints, WalSegSz, and XLogSegNoOffsetToRecPtr.
Referenced by main().
|
static |
|
static |
Definition at line 1079 of file pg_resetwal.c.
References ControlFileData::checkPointCopy, close, COMP_CRC32C, ControlFile, crc, PGAlignedXLogBlock::data, fd(), FIN_CRC32C, fsync, INIT_CRC32C, InvalidTransactionId, MAXPGPATH, newXlogSegNo, PG_BINARY, pg_fatal, pg_file_create_mode, CheckPoint::redo, SizeOfXLogLongPHD, SizeOfXLogRecord, SizeOfXLogRecordDataHeaderShort, ControlFileData::system_identifier, CheckPoint::ThisTimeLineID, WalSegSz, write, XLogRecord::xl_crc, XLogRecord::xl_info, XLogRecord::xl_prev, XLogRecord::xl_rmid, XLogRecord::xl_tot_len, XLogRecord::xl_xid, XLOG_CHECKPOINT_SHUTDOWN, XLOG_PAGE_MAGIC, XLogFilePath(), XLogPageHeaderData::xlp_info, XLP_LONG_HEADER, XLogPageHeaderData::xlp_magic, XLogPageHeaderData::xlp_pageaddr, XLogLongPageHeaderData::xlp_seg_size, XLogLongPageHeaderData::xlp_sysid, XLogPageHeaderData::xlp_tli, XLogLongPageHeaderData::xlp_xlog_blcksz, and XLR_BLOCK_ID_DATA_SHORT.
Referenced by main().
|
static |
Definition at line 62 of file pg_resetwal.c.
Referenced by FindEndOfXLOG(), GuessControlValues(), main(), PrintControlValues(), PrintNewControlValues(), read_controlfile(), RewriteControlFile(), and WriteEmptyXLOG().
Definition at line 64 of file pg_resetwal.c.
Referenced by GuessControlValues(), main(), PrintControlValues(), and read_controlfile().
|
static |
Definition at line 75 of file pg_resetwal.c.
Referenced by main().
|
static |
Definition at line 74 of file pg_resetwal.c.
Referenced by main().
|
static |
Definition at line 63 of file pg_resetwal.c.
Referenced by FindEndOfXLOG(), main(), PrintNewControlValues(), RewriteControlFile(), and WriteEmptyXLOG().
|
static |
Definition at line 65 of file pg_resetwal.c.
|
static |
Definition at line 72 of file pg_resetwal.c.
Referenced by main(), and PrintNewControlValues().
|
static |
Definition at line 73 of file pg_resetwal.c.
Referenced by main(), and PrintNewControlValues().
|
static |
Definition at line 70 of file pg_resetwal.c.
Referenced by main(), and PrintNewControlValues().
|
static |
Definition at line 71 of file pg_resetwal.c.
Referenced by main(), and PrintNewControlValues().
|
static |
Definition at line 69 of file pg_resetwal.c.
Referenced by main(), and PrintNewControlValues().
|
static |
Definition at line 67 of file pg_resetwal.c.
Referenced by main().
|
static |
Definition at line 77 of file pg_resetwal.c.
Referenced by main(), and PrintNewControlValues().
|
static |
Definition at line 68 of file pg_resetwal.c.
Referenced by main(), and PrintNewControlValues().
Definition at line 66 of file pg_resetwal.c.
Referenced by main(), and PrintNewControlValues().
|
static |
Definition at line 76 of file pg_resetwal.c.
Referenced by FindEndOfXLOG(), main(), PrintNewControlValues(), RewriteControlFile(), and WriteEmptyXLOG().