PostgreSQL Source Code  git master
xlogdesc.c File Reference
#include "postgres.h"
#include "access/transam.h"
#include "access/xlog.h"
#include "access/xlog_internal.h"
#include "catalog/pg_control.h"
#include "utils/guc.h"
#include "utils/timestamp.h"
Include dependency graph for xlogdesc.c:

Go to the source code of this file.

Functions

void xlog_desc (StringInfo buf, XLogReaderState *record)
 
const char * xlog_identify (uint8 info)
 

Variables

const struct config_enum_entry wal_level_options []
 

Function Documentation

◆ xlog_desc()

void xlog_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 37 of file xlogdesc.c.

References appendStringInfo(), appendStringInfoString(), xl_end_of_recovery::end_time, EpochFromFullTransactionId, CheckPoint::fullPageWrites, xl_parameter_change::max_locks_per_xact, xl_parameter_change::max_prepared_xacts, xl_parameter_change::max_wal_senders, xl_parameter_change::max_worker_processes, xl_parameter_change::MaxConnections, config_enum_entry::name, CheckPoint::newestCommitTsXid, CheckPoint::nextFullXid, CheckPoint::nextMulti, CheckPoint::nextMultiOffset, CheckPoint::nextOid, CheckPoint::oldestActiveXid, CheckPoint::oldestCommitTsXid, CheckPoint::oldestMulti, CheckPoint::oldestMultiDB, CheckPoint::oldestXid, CheckPoint::oldestXidDB, CheckPoint::PrevTimeLineID, xl_end_of_recovery::PrevTimeLineID, CheckPoint::redo, xl_restore_point::rp_name, CheckPoint::ThisTimeLineID, xl_end_of_recovery::ThisTimeLineID, timestamptz_to_str(), xl_parameter_change::track_commit_timestamp, config_enum_entry::val, xl_parameter_change::wal_level, wal_level_str(), xl_parameter_change::wal_log_hints, XidFromFullTransactionId, XLOG_BACKUP_END, XLOG_CHECKPOINT_ONLINE, XLOG_CHECKPOINT_SHUTDOWN, XLOG_END_OF_RECOVERY, XLOG_FPI, XLOG_FPI_FOR_HINT, XLOG_FPW_CHANGE, XLOG_NEXTOID, XLOG_PARAMETER_CHANGE, XLOG_RESTORE_POINT, XLogRecGetData, XLogRecGetInfo, and XLR_INFO_MASK.

38 {
39  char *rec = XLogRecGetData(record);
40  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
41 
42  if (info == XLOG_CHECKPOINT_SHUTDOWN ||
43  info == XLOG_CHECKPOINT_ONLINE)
44  {
45  CheckPoint *checkpoint = (CheckPoint *) rec;
46 
47  appendStringInfo(buf, "redo %X/%X; "
48  "tli %u; prev tli %u; fpw %s; xid %u:%u; oid %u; multi %u; offset %u; "
49  "oldest xid %u in DB %u; oldest multi %u in DB %u; "
50  "oldest/newest commit timestamp xid: %u/%u; "
51  "oldest running xid %u; %s",
52  (uint32) (checkpoint->redo >> 32), (uint32) checkpoint->redo,
53  checkpoint->ThisTimeLineID,
54  checkpoint->PrevTimeLineID,
55  checkpoint->fullPageWrites ? "true" : "false",
58  checkpoint->nextOid,
59  checkpoint->nextMulti,
60  checkpoint->nextMultiOffset,
61  checkpoint->oldestXid,
62  checkpoint->oldestXidDB,
63  checkpoint->oldestMulti,
64  checkpoint->oldestMultiDB,
65  checkpoint->oldestCommitTsXid,
66  checkpoint->newestCommitTsXid,
67  checkpoint->oldestActiveXid,
68  (info == XLOG_CHECKPOINT_SHUTDOWN) ? "shutdown" : "online");
69  }
70  else if (info == XLOG_NEXTOID)
71  {
72  Oid nextOid;
73 
74  memcpy(&nextOid, rec, sizeof(Oid));
75  appendStringInfo(buf, "%u", nextOid);
76  }
77  else if (info == XLOG_RESTORE_POINT)
78  {
79  xl_restore_point *xlrec = (xl_restore_point *) rec;
80 
81  appendStringInfoString(buf, xlrec->rp_name);
82  }
83  else if (info == XLOG_FPI || info == XLOG_FPI_FOR_HINT)
84  {
85  /* no further information to print */
86  }
87  else if (info == XLOG_BACKUP_END)
88  {
89  XLogRecPtr startpoint;
90 
91  memcpy(&startpoint, rec, sizeof(XLogRecPtr));
92  appendStringInfo(buf, "%X/%X",
93  (uint32) (startpoint >> 32), (uint32) startpoint);
94  }
95  else if (info == XLOG_PARAMETER_CHANGE)
96  {
97  xl_parameter_change xlrec;
98  const char *wal_level_str;
99  const struct config_enum_entry *entry;
100 
101  memcpy(&xlrec, rec, sizeof(xl_parameter_change));
102 
103  /* Find a string representation for wal_level */
104  wal_level_str = "?";
105  for (entry = wal_level_options; entry->name; entry++)
106  {
107  if (entry->val == xlrec.wal_level)
108  {
109  wal_level_str = entry->name;
110  break;
111  }
112  }
113 
114  appendStringInfo(buf, "max_connections=%d max_worker_processes=%d "
115  "max_wal_senders=%d max_prepared_xacts=%d "
116  "max_locks_per_xact=%d wal_level=%s "
117  "wal_log_hints=%s track_commit_timestamp=%s",
118  xlrec.MaxConnections,
119  xlrec.max_worker_processes,
120  xlrec.max_wal_senders,
121  xlrec.max_prepared_xacts,
122  xlrec.max_locks_per_xact,
123  wal_level_str,
124  xlrec.wal_log_hints ? "on" : "off",
125  xlrec.track_commit_timestamp ? "on" : "off");
126  }
127  else if (info == XLOG_FPW_CHANGE)
128  {
129  bool fpw;
130 
131  memcpy(&fpw, rec, sizeof(bool));
132  appendStringInfoString(buf, fpw ? "true" : "false");
133  }
134  else if (info == XLOG_END_OF_RECOVERY)
135  {
136  xl_end_of_recovery xlrec;
137 
138  memcpy(&xlrec, rec, sizeof(xl_end_of_recovery));
139  appendStringInfo(buf, "tli %u; prev tli %u; time %s",
140  xlrec.ThisTimeLineID, xlrec.PrevTimeLineID,
142  }
143 }
static const char * wal_level_str(WalLevel wal_level)
#define XLOG_FPW_CHANGE
Definition: pg_control.h:75
#define XLOG_CHECKPOINT_ONLINE
Definition: pg_control.h:68
Definition: guc.h:164
TimeLineID PrevTimeLineID
TransactionId oldestActiveXid
Definition: pg_control.h:63
unsigned char uint8
Definition: c.h:357
MultiXactId oldestMulti
Definition: pg_control.h:49
TimeLineID PrevTimeLineID
Definition: pg_control.h:40
#define XLOG_RESTORE_POINT
Definition: pg_control.h:74
TransactionId oldestXid
Definition: pg_control.h:47
unsigned int Oid
Definition: postgres_ext.h:31
#define XLOG_END_OF_RECOVERY
Definition: pg_control.h:76
#define XidFromFullTransactionId(x)
Definition: transam.h:48
MultiXactOffset nextMultiOffset
Definition: pg_control.h:46
#define XLOG_NEXTOID
Definition: pg_control.h:70
char rp_name[MAXFNAMELEN]
TransactionId oldestCommitTsXid
Definition: pg_control.h:52
#define XLogRecGetData(decoder)
Definition: xlogreader.h:283
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
#define XLOG_PARAMETER_CHANGE
Definition: pg_control.h:73
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
#define XLOG_CHECKPOINT_SHUTDOWN
Definition: pg_control.h:67
unsigned int uint32
Definition: c.h:359
#define XLOG_BACKUP_END
Definition: pg_control.h:72
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:279
int val
Definition: guc.h:167
TransactionId newestCommitTsXid
Definition: pg_control.h:54
Oid oldestMultiDB
Definition: pg_control.h:50
#define EpochFromFullTransactionId(x)
Definition: transam.h:47
Oid nextOid
Definition: pg_control.h:44
bool fullPageWrites
Definition: pg_control.h:42
TimestampTz end_time
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
FullTransactionId nextFullXid
Definition: pg_control.h:43
Oid oldestXidDB
Definition: pg_control.h:48
#define XLOG_FPI_FOR_HINT
Definition: pg_control.h:77
MultiXactId nextMulti
Definition: pg_control.h:45
const char * name
Definition: guc.h:166
const struct config_enum_entry wal_level_options[]
Definition: xlogdesc.c:27
TimeLineID ThisTimeLineID
#define XLOG_FPI
Definition: pg_control.h:78
TimeLineID ThisTimeLineID
Definition: pg_control.h:39
XLogRecPtr redo
Definition: pg_control.h:37
const char * timestamptz_to_str(TimestampTz t)
Definition: timestamp.c:1743

◆ xlog_identify()

const char* xlog_identify ( uint8  info)

Definition at line 146 of file xlogdesc.c.

References XLOG_BACKUP_END, XLOG_CHECKPOINT_ONLINE, XLOG_CHECKPOINT_SHUTDOWN, XLOG_END_OF_RECOVERY, XLOG_FPI, XLOG_FPI_FOR_HINT, XLOG_FPW_CHANGE, XLOG_NEXTOID, XLOG_NOOP, XLOG_PARAMETER_CHANGE, XLOG_RESTORE_POINT, XLOG_SWITCH, and XLR_INFO_MASK.

147 {
148  const char *id = NULL;
149 
150  switch (info & ~XLR_INFO_MASK)
151  {
153  id = "CHECKPOINT_SHUTDOWN";
154  break;
156  id = "CHECKPOINT_ONLINE";
157  break;
158  case XLOG_NOOP:
159  id = "NOOP";
160  break;
161  case XLOG_NEXTOID:
162  id = "NEXTOID";
163  break;
164  case XLOG_SWITCH:
165  id = "SWITCH";
166  break;
167  case XLOG_BACKUP_END:
168  id = "BACKUP_END";
169  break;
171  id = "PARAMETER_CHANGE";
172  break;
173  case XLOG_RESTORE_POINT:
174  id = "RESTORE_POINT";
175  break;
176  case XLOG_FPW_CHANGE:
177  id = "FPW_CHANGE";
178  break;
180  id = "END_OF_RECOVERY";
181  break;
182  case XLOG_FPI:
183  id = "FPI";
184  break;
185  case XLOG_FPI_FOR_HINT:
186  id = "FPI_FOR_HINT";
187  break;
188  }
189 
190  return id;
191 }
#define XLOG_FPW_CHANGE
Definition: pg_control.h:75
#define XLOG_CHECKPOINT_ONLINE
Definition: pg_control.h:68
#define XLOG_RESTORE_POINT
Definition: pg_control.h:74
#define XLOG_END_OF_RECOVERY
Definition: pg_control.h:76
#define XLOG_NEXTOID
Definition: pg_control.h:70
#define XLOG_PARAMETER_CHANGE
Definition: pg_control.h:73
#define XLOG_CHECKPOINT_SHUTDOWN
Definition: pg_control.h:67
#define XLOG_BACKUP_END
Definition: pg_control.h:72
#define XLOG_NOOP
Definition: pg_control.h:69
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_FPI_FOR_HINT
Definition: pg_control.h:77
#define XLOG_SWITCH
Definition: pg_control.h:71
#define XLOG_FPI
Definition: pg_control.h:78

Variable Documentation

◆ wal_level_options

const struct config_enum_entry wal_level_options[]
Initial value:
= {
{"minimal", WAL_LEVEL_MINIMAL, false},
{"replica", WAL_LEVEL_REPLICA, false},
{"archive", WAL_LEVEL_REPLICA, true},
{"hot_standby", WAL_LEVEL_REPLICA, true},
{"logical", WAL_LEVEL_LOGICAL, false},
{NULL, 0, false}
}

Definition at line 27 of file xlogdesc.c.