PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
xlogdesc.c File Reference
#include "postgres.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

void xlog_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 36 of file xlogdesc.c.

References appendStringInfo(), appendStringInfoString(), xl_end_of_recovery::end_time, CheckPoint::fullPageWrites, xl_parameter_change::max_locks_per_xact, xl_parameter_change::max_prepared_xacts, xl_parameter_change::max_worker_processes, xl_parameter_change::MaxConnections, config_enum_entry::name, CheckPoint::newestCommitTsXid, CheckPoint::nextMulti, CheckPoint::nextMultiOffset, CheckPoint::nextOid, CheckPoint::nextXid, CheckPoint::nextXidEpoch, 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, 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.

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

Definition at line 143 of file xlogdesc.c.

References NULL, 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.

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

Variable Documentation

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}
}
#define NULL
Definition: c.h:226

Definition at line 26 of file xlogdesc.c.