mirror of
https://github.com/postgres/postgres.git
synced 2025-11-15 03:41:20 +03:00
Split out rmgr rm_desc functions into their own files
This is necessary (but not sufficient) to have them compilable outside of a backend environment.
This commit is contained in:
@@ -768,26 +768,3 @@ clog_redo(XLogRecPtr lsn, XLogRecord *record)
|
||||
else
|
||||
elog(PANIC, "clog_redo: unknown op code %u", info);
|
||||
}
|
||||
|
||||
void
|
||||
clog_desc(StringInfo buf, uint8 xl_info, char *rec)
|
||||
{
|
||||
uint8 info = xl_info & ~XLR_INFO_MASK;
|
||||
|
||||
if (info == CLOG_ZEROPAGE)
|
||||
{
|
||||
int pageno;
|
||||
|
||||
memcpy(&pageno, rec, sizeof(int));
|
||||
appendStringInfo(buf, "zeropage: %d", pageno);
|
||||
}
|
||||
else if (info == CLOG_TRUNCATE)
|
||||
{
|
||||
int pageno;
|
||||
|
||||
memcpy(&pageno, rec, sizeof(int));
|
||||
appendStringInfo(buf, "truncate before: %d", pageno);
|
||||
}
|
||||
else
|
||||
appendStringInfo(buf, "UNKNOWN");
|
||||
}
|
||||
|
||||
@@ -2053,36 +2053,3 @@ multixact_redo(XLogRecPtr lsn, XLogRecord *record)
|
||||
else
|
||||
elog(PANIC, "multixact_redo: unknown op code %u", info);
|
||||
}
|
||||
|
||||
void
|
||||
multixact_desc(StringInfo buf, uint8 xl_info, char *rec)
|
||||
{
|
||||
uint8 info = xl_info & ~XLR_INFO_MASK;
|
||||
|
||||
if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
|
||||
{
|
||||
int pageno;
|
||||
|
||||
memcpy(&pageno, rec, sizeof(int));
|
||||
appendStringInfo(buf, "zero offsets page: %d", pageno);
|
||||
}
|
||||
else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
|
||||
{
|
||||
int pageno;
|
||||
|
||||
memcpy(&pageno, rec, sizeof(int));
|
||||
appendStringInfo(buf, "zero members page: %d", pageno);
|
||||
}
|
||||
else if (info == XLOG_MULTIXACT_CREATE_ID)
|
||||
{
|
||||
xl_multixact_create *xlrec = (xl_multixact_create *) rec;
|
||||
int i;
|
||||
|
||||
appendStringInfo(buf, "create multixact %u offset %u:",
|
||||
xlrec->mid, xlrec->moff);
|
||||
for (i = 0; i < xlrec->nxids; i++)
|
||||
appendStringInfo(buf, " %u", xlrec->xids[i]);
|
||||
}
|
||||
else
|
||||
appendStringInfo(buf, "UNKNOWN");
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "access/spgist.h"
|
||||
#include "access/xact.h"
|
||||
#include "access/xlog_internal.h"
|
||||
#include "catalog/storage.h"
|
||||
#include "catalog/storage_xlog.h"
|
||||
#include "commands/dbcommands.h"
|
||||
#include "commands/sequence.h"
|
||||
#include "commands/tablespace.h"
|
||||
|
||||
@@ -4825,176 +4825,3 @@ xact_redo(XLogRecPtr lsn, XLogRecord *record)
|
||||
else
|
||||
elog(PANIC, "xact_redo: unknown op code %u", info);
|
||||
}
|
||||
|
||||
static void
|
||||
xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
|
||||
{
|
||||
int i;
|
||||
TransactionId *subxacts;
|
||||
|
||||
subxacts = (TransactionId *) &xlrec->xnodes[xlrec->nrels];
|
||||
|
||||
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
|
||||
|
||||
if (xlrec->nrels > 0)
|
||||
{
|
||||
appendStringInfo(buf, "; rels:");
|
||||
for (i = 0; i < xlrec->nrels; i++)
|
||||
{
|
||||
char *path = relpathperm(xlrec->xnodes[i], MAIN_FORKNUM);
|
||||
|
||||
appendStringInfo(buf, " %s", path);
|
||||
pfree(path);
|
||||
}
|
||||
}
|
||||
if (xlrec->nsubxacts > 0)
|
||||
{
|
||||
appendStringInfo(buf, "; subxacts:");
|
||||
for (i = 0; i < xlrec->nsubxacts; i++)
|
||||
appendStringInfo(buf, " %u", subxacts[i]);
|
||||
}
|
||||
if (xlrec->nmsgs > 0)
|
||||
{
|
||||
SharedInvalidationMessage *msgs;
|
||||
|
||||
msgs = (SharedInvalidationMessage *) &subxacts[xlrec->nsubxacts];
|
||||
|
||||
if (XactCompletionRelcacheInitFileInval(xlrec->xinfo))
|
||||
appendStringInfo(buf, "; relcache init file inval dbid %u tsid %u",
|
||||
xlrec->dbId, xlrec->tsId);
|
||||
|
||||
appendStringInfo(buf, "; inval msgs:");
|
||||
for (i = 0; i < xlrec->nmsgs; i++)
|
||||
{
|
||||
SharedInvalidationMessage *msg = &msgs[i];
|
||||
|
||||
if (msg->id >= 0)
|
||||
appendStringInfo(buf, " catcache %d", msg->id);
|
||||
else if (msg->id == SHAREDINVALCATALOG_ID)
|
||||
appendStringInfo(buf, " catalog %u", msg->cat.catId);
|
||||
else if (msg->id == SHAREDINVALRELCACHE_ID)
|
||||
appendStringInfo(buf, " relcache %u", msg->rc.relId);
|
||||
/* remaining cases not expected, but print something anyway */
|
||||
else if (msg->id == SHAREDINVALSMGR_ID)
|
||||
appendStringInfo(buf, " smgr");
|
||||
else if (msg->id == SHAREDINVALRELMAP_ID)
|
||||
appendStringInfo(buf, " relmap");
|
||||
else
|
||||
appendStringInfo(buf, " unknown id %d", msg->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xact_desc_commit_compact(StringInfo buf, xl_xact_commit_compact *xlrec)
|
||||
{
|
||||
int i;
|
||||
|
||||
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
|
||||
|
||||
if (xlrec->nsubxacts > 0)
|
||||
{
|
||||
appendStringInfo(buf, "; subxacts:");
|
||||
for (i = 0; i < xlrec->nsubxacts; i++)
|
||||
appendStringInfo(buf, " %u", xlrec->subxacts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xact_desc_abort(StringInfo buf, xl_xact_abort *xlrec)
|
||||
{
|
||||
int i;
|
||||
|
||||
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
|
||||
if (xlrec->nrels > 0)
|
||||
{
|
||||
appendStringInfo(buf, "; rels:");
|
||||
for (i = 0; i < xlrec->nrels; i++)
|
||||
{
|
||||
char *path = relpathperm(xlrec->xnodes[i], MAIN_FORKNUM);
|
||||
|
||||
appendStringInfo(buf, " %s", path);
|
||||
pfree(path);
|
||||
}
|
||||
}
|
||||
if (xlrec->nsubxacts > 0)
|
||||
{
|
||||
TransactionId *xacts = (TransactionId *)
|
||||
&xlrec->xnodes[xlrec->nrels];
|
||||
|
||||
appendStringInfo(buf, "; subxacts:");
|
||||
for (i = 0; i < xlrec->nsubxacts; i++)
|
||||
appendStringInfo(buf, " %u", xacts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xact_desc_assignment(StringInfo buf, xl_xact_assignment *xlrec)
|
||||
{
|
||||
int i;
|
||||
|
||||
appendStringInfo(buf, "subxacts:");
|
||||
|
||||
for (i = 0; i < xlrec->nsubxacts; i++)
|
||||
appendStringInfo(buf, " %u", xlrec->xsub[i]);
|
||||
}
|
||||
|
||||
void
|
||||
xact_desc(StringInfo buf, uint8 xl_info, char *rec)
|
||||
{
|
||||
uint8 info = xl_info & ~XLR_INFO_MASK;
|
||||
|
||||
if (info == XLOG_XACT_COMMIT_COMPACT)
|
||||
{
|
||||
xl_xact_commit_compact *xlrec = (xl_xact_commit_compact *) rec;
|
||||
|
||||
appendStringInfo(buf, "commit: ");
|
||||
xact_desc_commit_compact(buf, xlrec);
|
||||
}
|
||||
else if (info == XLOG_XACT_COMMIT)
|
||||
{
|
||||
xl_xact_commit *xlrec = (xl_xact_commit *) rec;
|
||||
|
||||
appendStringInfo(buf, "commit: ");
|
||||
xact_desc_commit(buf, xlrec);
|
||||
}
|
||||
else if (info == XLOG_XACT_ABORT)
|
||||
{
|
||||
xl_xact_abort *xlrec = (xl_xact_abort *) rec;
|
||||
|
||||
appendStringInfo(buf, "abort: ");
|
||||
xact_desc_abort(buf, xlrec);
|
||||
}
|
||||
else if (info == XLOG_XACT_PREPARE)
|
||||
{
|
||||
appendStringInfo(buf, "prepare");
|
||||
}
|
||||
else if (info == XLOG_XACT_COMMIT_PREPARED)
|
||||
{
|
||||
xl_xact_commit_prepared *xlrec = (xl_xact_commit_prepared *) rec;
|
||||
|
||||
appendStringInfo(buf, "commit prepared %u: ", xlrec->xid);
|
||||
xact_desc_commit(buf, &xlrec->crec);
|
||||
}
|
||||
else if (info == XLOG_XACT_ABORT_PREPARED)
|
||||
{
|
||||
xl_xact_abort_prepared *xlrec = (xl_xact_abort_prepared *) rec;
|
||||
|
||||
appendStringInfo(buf, "abort prepared %u: ", xlrec->xid);
|
||||
xact_desc_abort(buf, &xlrec->arec);
|
||||
}
|
||||
else if (info == XLOG_XACT_ASSIGNMENT)
|
||||
{
|
||||
xl_xact_assignment *xlrec = (xl_xact_assignment *) rec;
|
||||
|
||||
/*
|
||||
* Note that we ignore the WAL record's xid, since we're more
|
||||
* interested in the top-level xid that issued the record and which
|
||||
* xids are being reported here.
|
||||
*/
|
||||
appendStringInfo(buf, "xid assignment xtop %u: ", xlrec->xtop);
|
||||
xact_desc_assignment(buf, xlrec);
|
||||
}
|
||||
else
|
||||
appendStringInfo(buf, "UNKNOWN");
|
||||
}
|
||||
|
||||
@@ -99,16 +99,10 @@ bool XLOG_DEBUG = false;
|
||||
*/
|
||||
#define XLOGfileslop (2*CheckPointSegments + 1)
|
||||
|
||||
|
||||
/*
|
||||
* GUC support
|
||||
*/
|
||||
const struct config_enum_entry wal_level_options[] = {
|
||||
{"minimal", WAL_LEVEL_MINIMAL, false},
|
||||
{"archive", WAL_LEVEL_ARCHIVE, false},
|
||||
{"hot_standby", WAL_LEVEL_HOT_STANDBY, false},
|
||||
{NULL, 0, false}
|
||||
};
|
||||
|
||||
const struct config_enum_entry sync_method_options[] = {
|
||||
{"fsync", SYNC_METHOD_FSYNC, false},
|
||||
#ifdef HAVE_FSYNC_WRITETHROUGH
|
||||
@@ -588,25 +582,6 @@ static bool InRedo = false;
|
||||
/* Have we launched bgwriter during recovery? */
|
||||
static bool bgwriterLaunched = false;
|
||||
|
||||
/*
|
||||
* Information logged when we detect a change in one of the parameters
|
||||
* important for Hot Standby.
|
||||
*/
|
||||
typedef struct xl_parameter_change
|
||||
{
|
||||
int MaxConnections;
|
||||
int max_prepared_xacts;
|
||||
int max_locks_per_xact;
|
||||
int wal_level;
|
||||
} xl_parameter_change;
|
||||
|
||||
/* logs restore point */
|
||||
typedef struct xl_restore_point
|
||||
{
|
||||
TimestampTz rp_time;
|
||||
char rp_name[MAXFNAMELEN];
|
||||
} xl_restore_point;
|
||||
|
||||
|
||||
static void readRecoveryCommandFile(void);
|
||||
static void exitArchiveRecovery(TimeLineID endTLI, XLogSegNo endLogSegNo);
|
||||
@@ -8031,97 +8006,6 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xlog_desc(StringInfo buf, uint8 xl_info, char *rec)
|
||||
{
|
||||
uint8 info = xl_info & ~XLR_INFO_MASK;
|
||||
|
||||
if (info == XLOG_CHECKPOINT_SHUTDOWN ||
|
||||
info == XLOG_CHECKPOINT_ONLINE)
|
||||
{
|
||||
CheckPoint *checkpoint = (CheckPoint *) rec;
|
||||
|
||||
appendStringInfo(buf, "checkpoint: redo %X/%X; "
|
||||
"tli %u; fpw %s; xid %u/%u; oid %u; multi %u; offset %u; "
|
||||
"oldest xid %u in DB %u; oldest running xid %u; %s",
|
||||
(uint32) (checkpoint->redo >> 32), (uint32) checkpoint->redo,
|
||||
checkpoint->ThisTimeLineID,
|
||||
checkpoint->fullPageWrites ? "true" : "false",
|
||||
checkpoint->nextXidEpoch, checkpoint->nextXid,
|
||||
checkpoint->nextOid,
|
||||
checkpoint->nextMulti,
|
||||
checkpoint->nextMultiOffset,
|
||||
checkpoint->oldestXid,
|
||||
checkpoint->oldestXidDB,
|
||||
checkpoint->oldestActiveXid,
|
||||
(info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
|
||||
}
|
||||
else if (info == XLOG_NOOP)
|
||||
{
|
||||
appendStringInfo(buf, "xlog no-op");
|
||||
}
|
||||
else if (info == XLOG_NEXTOID)
|
||||
{
|
||||
Oid nextOid;
|
||||
|
||||
memcpy(&nextOid, rec, sizeof(Oid));
|
||||
appendStringInfo(buf, "nextOid: %u", nextOid);
|
||||
}
|
||||
else if (info == XLOG_SWITCH)
|
||||
{
|
||||
appendStringInfo(buf, "xlog switch");
|
||||
}
|
||||
else if (info == XLOG_RESTORE_POINT)
|
||||
{
|
||||
xl_restore_point *xlrec = (xl_restore_point *) rec;
|
||||
|
||||
appendStringInfo(buf, "restore point: %s", xlrec->rp_name);
|
||||
|
||||
}
|
||||
else if (info == XLOG_BACKUP_END)
|
||||
{
|
||||
XLogRecPtr startpoint;
|
||||
|
||||
memcpy(&startpoint, rec, sizeof(XLogRecPtr));
|
||||
appendStringInfo(buf, "backup end: %X/%X",
|
||||
(uint32) (startpoint >> 32), (uint32) startpoint);
|
||||
}
|
||||
else if (info == XLOG_PARAMETER_CHANGE)
|
||||
{
|
||||
xl_parameter_change xlrec;
|
||||
const char *wal_level_str;
|
||||
const struct config_enum_entry *entry;
|
||||
|
||||
memcpy(&xlrec, rec, sizeof(xl_parameter_change));
|
||||
|
||||
/* Find a string representation for wal_level */
|
||||
wal_level_str = "?";
|
||||
for (entry = wal_level_options; entry->name; entry++)
|
||||
{
|
||||
if (entry->val == xlrec.wal_level)
|
||||
{
|
||||
wal_level_str = entry->name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
appendStringInfo(buf, "parameter change: max_connections=%d max_prepared_xacts=%d max_locks_per_xact=%d wal_level=%s",
|
||||
xlrec.MaxConnections,
|
||||
xlrec.max_prepared_xacts,
|
||||
xlrec.max_locks_per_xact,
|
||||
wal_level_str);
|
||||
}
|
||||
else if (info == XLOG_FPW_CHANGE)
|
||||
{
|
||||
bool fpw;
|
||||
|
||||
memcpy(&fpw, rec, sizeof(bool));
|
||||
appendStringInfo(buf, "full_page_writes: %s", fpw ? "true" : "false");
|
||||
}
|
||||
else
|
||||
appendStringInfo(buf, "UNKNOWN");
|
||||
}
|
||||
|
||||
#ifdef WAL_DEBUG
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user