|
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 "fe_utils/version.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 bool | mxid_given = false |
| static MultiXactId | set_mxid = 0 |
| static bool | mxoff_given = false |
| static MultiXactOffset | set_mxoff = 0 |
| static TimeLineID | minXlogTli = 0 |
| static XLogSegNo | minXlogSegNo = 0 |
| static int | WalSegSz |
| static int | set_wal_segsize |
| static int | set_char_signedness = -1 |
| #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 546 of file pg_resetwal.c.
References GET_PG_MAJORVERSION_NUM, get_pg_version(), pg_log_error, and pg_log_error_detail.
Referenced by main().
|
static |
Definition at line 927 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 644 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, 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::slru_pages_per_segment, SLRU_PAGES_PER_SEGMENT, 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 1026 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 1063 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 993 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 98 of file pg_resetwal.c.
References _, CheckDataVersion(), ControlFileData::checkPointCopy, ControlFile, DataDir, DB_SHUTDOWNED, ControlFileData::default_char_signedness, EpochFromFullTransactionId, fd(), FindEndOfXLOG(), FirstMultiXactId, FirstNormalTransactionId, FullTransactionIdFromEpochAndXid(), get_progname(), get_restricted_token(), GetDataDirectoryCreatePerm(), getopt_long(), GuessControlValues(), guessed, InvalidOid, InvalidTransactionId, IsValidWalSegSize, KillExistingArchiveStatus(), KillExistingWALSummaries(), KillExistingXLOG(), MaxMultiXactOffset, minXlogSegNo, minXlogTli, mxid_given, mxoff_given, 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_strcasecmp(), pg_strdup(), PG_TEXTDOMAIN, CheckPoint::PrevTimeLineID, PrintControlValues(), printf, PrintNewControlValues(), progname, read_controlfile(), required_argument, RewriteControlFile(), set_char_signedness, 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 728 of file pg_resetwal.c.
References _, ControlFileData::blcksz, ControlFileData::catalog_version_no, ControlFileData::checkPointCopy, ControlFile, ControlFileData::data_checksum_version, ControlFileData::default_char_signedness, 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::slru_pages_per_segment, 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 805 of file pg_resetwal.c.
References _, ControlFileData::checkPointCopy, ControlFile, EpochFromFullTransactionId, MAXFNAMELEN, mxid_given, mxoff_given, CheckPoint::newestCommitTsXid, newXlogSegNo, CheckPoint::nextMulti, CheckPoint::nextMultiOffset, CheckPoint::nextOid, CheckPoint::nextXid, CheckPoint::oldestCommitTsXid, CheckPoint::oldestMulti, CheckPoint::oldestMultiDB, CheckPoint::oldestXid, CheckPoint::oldestXidDB, printf, set_newest_commit_ts_xid, set_oid, set_oldest_commit_ts_xid, set_oldest_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 570 of file pg_resetwal.c.
References close, COMP_CRC32C, ControlFile, crc, EQ_CRC32C, 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 881 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 1099 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 63 of file pg_resetwal.c.
Referenced by FindEndOfXLOG(), GuessControlValues(), main(), PrintControlValues(), PrintNewControlValues(), read_controlfile(), RewriteControlFile(), and WriteEmptyXLOG().
|
static |
Definition at line 65 of file pg_resetwal.c.
Referenced by GuessControlValues(), main(), PrintControlValues(), and read_controlfile().
|
static |
Definition at line 78 of file pg_resetwal.c.
Referenced by main().
|
static |
Definition at line 77 of file pg_resetwal.c.
Referenced by main().
|
static |
Definition at line 73 of file pg_resetwal.c.
Referenced by main(), and PrintNewControlValues().
|
static |
Definition at line 75 of file pg_resetwal.c.
Referenced by main(), and PrintNewControlValues().
|
static |
Definition at line 64 of file pg_resetwal.c.
Referenced by FindEndOfXLOG(), main(), PrintNewControlValues(), RewriteControlFile(), and WriteEmptyXLOG().
|
static |
Definition at line 66 of file pg_resetwal.c.
|
static |
Definition at line 81 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 76 of file pg_resetwal.c.
Referenced by main().
|
static |
Definition at line 71 of file pg_resetwal.c.
Referenced by main(), and PrintNewControlValues().
|
static |
Definition at line 72 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 68 of file pg_resetwal.c.
Referenced by main(), and PrintNewControlValues().
|
static |
Definition at line 80 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().
Definition at line 67 of file pg_resetwal.c.
Referenced by main(), and PrintNewControlValues().
|
static |
Definition at line 79 of file pg_resetwal.c.
Referenced by FindEndOfXLOG(), main(), PrintNewControlValues(), RewriteControlFile(), and WriteEmptyXLOG().