1
/*-------------------------------------------------------------------------
4
* rmgr descriptor routines for access/transam/xact.c
6
* Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
7
* Portions Copyright (c) 1994, Regents of the University of California
11
* src/backend/access/rmgrdesc/xactdesc.c
13
*-------------------------------------------------------------------------
17
#include "access/xact.h"
18
#include "catalog/catalog.h"
19
#include "common/relpath.h"
20
#include "storage/sinval.h"
21
#include "utils/timestamp.h"
25
xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
28
TransactionId *subxacts;
30
subxacts = (TransactionId *) &xlrec->xnodes[xlrec->nrels];
32
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
36
appendStringInfo(buf, "; rels:");
37
for (i = 0; i < xlrec->nrels; i++)
39
char *path = relpathperm(xlrec->xnodes[i], MAIN_FORKNUM);
41
appendStringInfo(buf, " %s", path);
45
if (xlrec->nsubxacts > 0)
47
appendStringInfo(buf, "; subxacts:");
48
for (i = 0; i < xlrec->nsubxacts; i++)
49
appendStringInfo(buf, " %u", subxacts[i]);
53
SharedInvalidationMessage *msgs;
55
msgs = (SharedInvalidationMessage *) &subxacts[xlrec->nsubxacts];
57
if (XactCompletionRelcacheInitFileInval(xlrec->xinfo))
58
appendStringInfo(buf, "; relcache init file inval dbid %u tsid %u",
59
xlrec->dbId, xlrec->tsId);
61
appendStringInfo(buf, "; inval msgs:");
62
for (i = 0; i < xlrec->nmsgs; i++)
64
SharedInvalidationMessage *msg = &msgs[i];
67
appendStringInfo(buf, " catcache %d", msg->id);
68
else if (msg->id == SHAREDINVALCATALOG_ID)
69
appendStringInfo(buf, " catalog %u", msg->cat.catId);
70
else if (msg->id == SHAREDINVALRELCACHE_ID)
71
appendStringInfo(buf, " relcache %u", msg->rc.relId);
72
/* remaining cases not expected, but print something anyway */
73
else if (msg->id == SHAREDINVALSMGR_ID)
74
appendStringInfo(buf, " smgr");
75
else if (msg->id == SHAREDINVALRELMAP_ID)
76
appendStringInfo(buf, " relmap");
78
appendStringInfo(buf, " unknown id %d", msg->id);
84
xact_desc_commit_compact(StringInfo buf, xl_xact_commit_compact *xlrec)
88
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
90
if (xlrec->nsubxacts > 0)
92
appendStringInfo(buf, "; subxacts:");
93
for (i = 0; i < xlrec->nsubxacts; i++)
94
appendStringInfo(buf, " %u", xlrec->subxacts[i]);
99
xact_desc_abort(StringInfo buf, xl_xact_abort *xlrec)
103
appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
104
if (xlrec->nrels > 0)
106
appendStringInfo(buf, "; rels:");
107
for (i = 0; i < xlrec->nrels; i++)
109
char *path = relpathperm(xlrec->xnodes[i], MAIN_FORKNUM);
111
appendStringInfo(buf, " %s", path);
115
if (xlrec->nsubxacts > 0)
117
TransactionId *xacts = (TransactionId *)
118
&xlrec->xnodes[xlrec->nrels];
120
appendStringInfo(buf, "; subxacts:");
121
for (i = 0; i < xlrec->nsubxacts; i++)
122
appendStringInfo(buf, " %u", xacts[i]);
127
xact_desc_assignment(StringInfo buf, xl_xact_assignment *xlrec)
131
appendStringInfo(buf, "subxacts:");
133
for (i = 0; i < xlrec->nsubxacts; i++)
134
appendStringInfo(buf, " %u", xlrec->xsub[i]);
138
xact_desc(StringInfo buf, uint8 xl_info, char *rec)
140
uint8 info = xl_info & ~XLR_INFO_MASK;
142
if (info == XLOG_XACT_COMMIT_COMPACT)
144
xl_xact_commit_compact *xlrec = (xl_xact_commit_compact *) rec;
146
appendStringInfo(buf, "commit: ");
147
xact_desc_commit_compact(buf, xlrec);
149
else if (info == XLOG_XACT_COMMIT)
151
xl_xact_commit *xlrec = (xl_xact_commit *) rec;
153
appendStringInfo(buf, "commit: ");
154
xact_desc_commit(buf, xlrec);
156
else if (info == XLOG_XACT_ABORT)
158
xl_xact_abort *xlrec = (xl_xact_abort *) rec;
160
appendStringInfo(buf, "abort: ");
161
xact_desc_abort(buf, xlrec);
163
else if (info == XLOG_XACT_PREPARE)
165
appendStringInfo(buf, "prepare");
167
else if (info == XLOG_XACT_COMMIT_PREPARED)
169
xl_xact_commit_prepared *xlrec = (xl_xact_commit_prepared *) rec;
171
appendStringInfo(buf, "commit prepared %u: ", xlrec->xid);
172
xact_desc_commit(buf, &xlrec->crec);
174
else if (info == XLOG_XACT_ABORT_PREPARED)
176
xl_xact_abort_prepared *xlrec = (xl_xact_abort_prepared *) rec;
178
appendStringInfo(buf, "abort prepared %u: ", xlrec->xid);
179
xact_desc_abort(buf, &xlrec->arec);
181
else if (info == XLOG_XACT_ASSIGNMENT)
183
xl_xact_assignment *xlrec = (xl_xact_assignment *) rec;
186
* Note that we ignore the WAL record's xid, since we're more
187
* interested in the top-level xid that issued the record and which
188
* xids are being reported here.
190
appendStringInfo(buf, "xid assignment xtop %u: ", xlrec->xtop);
191
xact_desc_assignment(buf, xlrec);
194
appendStringInfo(buf, "UNKNOWN");