summaryrefslogtreecommitdiff
path: root/src/backend/access/rmgrdesc/xactdesc.c
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2014-09-19 15:17:12 +0200
committerAndres Freund <andres@anarazel.de>2014-09-19 16:20:29 +0200
commit728f152e07f998d2cb4fe5f24ec8da2c3bda98f2 (patch)
tree3d7f2d8a04764a093a340af3f82b0cd15f44a6c1 /src/backend/access/rmgrdesc/xactdesc.c
parent7e3f728353fa9b36c7f98b6ec447d3f1b8deec14 (diff)
downloadpostgresql-728f152e07f998d2cb4fe5f24ec8da2c3bda98f2.tar.gz
Add rmgr callback to name xlog record types for display purposes.
This is primarily useful for the upcoming pg_xlogdump --stats feature, but also allows to remove some duplicated code in the rmgr_desc routines. Due to the separation and harmonization, the output of dipsplayed records changes somewhat. But since this isn't enduser oriented content that's ok. It's potentially desirable to further change pg_xlogdump's display of records. It previously wasn't possible to show the record type separately from the description forcing it to be in the last column. But that's better done in a separate commit. Author: Abhijit Menon-Sen, slightly editorialized by me Reviewed-By: Álvaro Herrera, Andres Freund, and Heikki Linnakangas Discussion: 20140604104716.GA3989@toroid.org
Diffstat (limited to 'src/backend/access/rmgrdesc/xactdesc.c')
-rw-r--r--src/backend/access/rmgrdesc/xactdesc.c48
1 files changed, 36 insertions, 12 deletions
diff --git a/src/backend/access/rmgrdesc/xactdesc.c b/src/backend/access/rmgrdesc/xactdesc.c
index 994931e66c..11e64af506 100644
--- a/src/backend/access/rmgrdesc/xactdesc.c
+++ b/src/backend/access/rmgrdesc/xactdesc.c
@@ -146,39 +146,32 @@ xact_desc(StringInfo buf, XLogRecord *record)
{
xl_xact_commit_compact *xlrec = (xl_xact_commit_compact *) rec;
- appendStringInfoString(buf, "commit: ");
xact_desc_commit_compact(buf, xlrec);
}
else if (info == XLOG_XACT_COMMIT)
{
xl_xact_commit *xlrec = (xl_xact_commit *) rec;
- appendStringInfoString(buf, "commit: ");
xact_desc_commit(buf, xlrec);
}
else if (info == XLOG_XACT_ABORT)
{
xl_xact_abort *xlrec = (xl_xact_abort *) rec;
- appendStringInfoString(buf, "abort: ");
xact_desc_abort(buf, xlrec);
}
- else if (info == XLOG_XACT_PREPARE)
- {
- appendStringInfoString(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);
+ appendStringInfo(buf, "%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);
+ appendStringInfo(buf, "%u: ", xlrec->xid);
xact_desc_abort(buf, &xlrec->arec);
}
else if (info == XLOG_XACT_ASSIGNMENT)
@@ -190,9 +183,40 @@ xact_desc(StringInfo buf, XLogRecord *record)
* 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);
+ appendStringInfo(buf, "xtop %u: ", xlrec->xtop);
xact_desc_assignment(buf, xlrec);
}
- else
- appendStringInfoString(buf, "UNKNOWN");
+}
+
+const char *
+xact_identify(uint8 info)
+{
+ const char *id = NULL;
+
+ switch (info)
+ {
+ case XLOG_XACT_COMMIT:
+ id = "COMMIT";
+ break;
+ case XLOG_XACT_PREPARE:
+ id = "PREPARE";
+ break;
+ case XLOG_XACT_ABORT:
+ id = "ABORT";
+ break;
+ case XLOG_XACT_COMMIT_PREPARED:
+ id = "COMMIT_PREPARED";
+ break;
+ case XLOG_XACT_ABORT_PREPARED:
+ id = "ABORT_PREPARED";
+ break;
+ case XLOG_XACT_ASSIGNMENT:
+ id = "ASSIGNMENT";
+ break;
+ case XLOG_XACT_COMMIT_COMPACT:
+ id = "COMMIT_COMPACT";
+ break;
+ }
+
+ return id;
}