diff options
author | Andres Freund <andres@anarazel.de> | 2014-09-19 15:17:12 +0200 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2014-09-19 16:20:29 +0200 |
commit | 728f152e07f998d2cb4fe5f24ec8da2c3bda98f2 (patch) | |
tree | 3d7f2d8a04764a093a340af3f82b0cd15f44a6c1 /src/backend/access/rmgrdesc/gindesc.c | |
parent | 7e3f728353fa9b36c7f98b6ec447d3f1b8deec14 (diff) | |
download | postgresql-728f152e07f998d2cb4fe5f24ec8da2c3bda98f2.tar.gz postgresql-728f152e07f998d2cb4fe5f24ec8da2c3bda98f2.zip |
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/gindesc.c')
-rw-r--r-- | src/backend/access/rmgrdesc/gindesc.c | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/src/backend/access/rmgrdesc/gindesc.c b/src/backend/access/rmgrdesc/gindesc.c index 12d68d7d40a..dd4c791864d 100644 --- a/src/backend/access/rmgrdesc/gindesc.c +++ b/src/backend/access/rmgrdesc/gindesc.c @@ -85,11 +85,9 @@ gin_desc(StringInfo buf, XLogRecord *record) switch (info) { case XLOG_GIN_CREATE_INDEX: - appendStringInfoString(buf, "Create index, "); desc_node(buf, *(RelFileNode *) rec, GIN_ROOT_BLKNO); break; case XLOG_GIN_CREATE_PTREE: - appendStringInfoString(buf, "Create posting tree, "); desc_node(buf, ((ginxlogCreatePostingTree *) rec)->node, ((ginxlogCreatePostingTree *) rec)->blkno); break; case XLOG_GIN_INSERT: @@ -97,7 +95,6 @@ gin_desc(StringInfo buf, XLogRecord *record) ginxlogInsert *xlrec = (ginxlogInsert *) rec; char *payload = rec + sizeof(ginxlogInsert); - appendStringInfoString(buf, "Insert item, "); desc_node(buf, xlrec->node, xlrec->blkno); appendStringInfo(buf, " isdata: %c isleaf: %c", (xlrec->flags & GIN_INSERT_ISDATA) ? 'T' : 'F', @@ -142,7 +139,6 @@ gin_desc(StringInfo buf, XLogRecord *record) { ginxlogSplit *xlrec = (ginxlogSplit *) rec; - appendStringInfoString(buf, "Page split, "); desc_node(buf, ((ginxlogSplit *) rec)->node, ((ginxlogSplit *) rec)->lblkno); appendStringInfo(buf, " isrootsplit: %c", (((ginxlogSplit *) rec)->flags & GIN_SPLIT_ROOT) ? 'T' : 'F'); appendStringInfo(buf, " isdata: %c isleaf: %c", @@ -151,14 +147,12 @@ gin_desc(StringInfo buf, XLogRecord *record) } break; case XLOG_GIN_VACUUM_PAGE: - appendStringInfoString(buf, "Vacuum page, "); desc_node(buf, ((ginxlogVacuumPage *) rec)->node, ((ginxlogVacuumPage *) rec)->blkno); break; case XLOG_GIN_VACUUM_DATA_LEAF_PAGE: { ginxlogVacuumDataLeafPage *xlrec = (ginxlogVacuumDataLeafPage *) rec; - appendStringInfoString(buf, "Vacuum data leaf page, "); desc_node(buf, xlrec->node, xlrec->blkno); if (record->xl_info & XLR_BKP_BLOCK(0)) appendStringInfo(buf, " (full page image)"); @@ -167,23 +161,59 @@ gin_desc(StringInfo buf, XLogRecord *record) } break; case XLOG_GIN_DELETE_PAGE: - appendStringInfoString(buf, "Delete page, "); desc_node(buf, ((ginxlogDeletePage *) rec)->node, ((ginxlogDeletePage *) rec)->blkno); break; case XLOG_GIN_UPDATE_META_PAGE: - appendStringInfoString(buf, "Update metapage, "); desc_node(buf, ((ginxlogUpdateMeta *) rec)->node, GIN_METAPAGE_BLKNO); break; case XLOG_GIN_INSERT_LISTPAGE: - appendStringInfoString(buf, "Insert new list page, "); desc_node(buf, ((ginxlogInsertListPage *) rec)->node, ((ginxlogInsertListPage *) rec)->blkno); break; case XLOG_GIN_DELETE_LISTPAGE: - appendStringInfo(buf, "Delete list pages (%d), ", ((ginxlogDeleteListPages *) rec)->ndeleted); + appendStringInfo(buf, "%d pages, ", ((ginxlogDeleteListPages *) rec)->ndeleted); desc_node(buf, ((ginxlogDeleteListPages *) rec)->node, GIN_METAPAGE_BLKNO); break; - default: - appendStringInfo(buf, "unknown gin op code %u", info); + } +} + +const char * +gin_identify(uint8 info) +{ + const char *id = NULL; + + switch (info) + { + case XLOG_GIN_CREATE_INDEX: + id = "CREATE_INDEX"; + break; + case XLOG_GIN_CREATE_PTREE: + id = "CREATE_PTREE"; + break; + case XLOG_GIN_INSERT: + id = "INSERT"; + break; + case XLOG_GIN_SPLIT: + id = "SPLIT"; + break; + case XLOG_GIN_VACUUM_PAGE: + id = "VACUUM_PAGE"; + break; + case XLOG_GIN_VACUUM_DATA_LEAF_PAGE: + id = "VACUUM_DATA_LEAF_PAGE"; + break; + case XLOG_GIN_DELETE_PAGE: + id = "DELETE_PAGE"; + break; + case XLOG_GIN_UPDATE_META_PAGE: + id = "UPDATE_META_PAGE"; + break; + case XLOG_GIN_INSERT_LISTPAGE: + id = "INSERT_LISTPAGE"; + break; + case XLOG_GIN_DELETE_LISTPAGE: + id = "DELETE_LISTPAGE"; break; } + + return id; } |