Header And Logo

PostgreSQL
| The world's most advanced open source database.

nbtdesc.c

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * nbtdesc.c
00004  *    rmgr descriptor routines for access/nbtree/nbtxlog.c
00005  *
00006  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00007  * Portions Copyright (c) 1994, Regents of the University of California
00008  *
00009  *
00010  * IDENTIFICATION
00011  *    src/backend/access/rmgrdesc/nbtdesc.c
00012  *
00013  *-------------------------------------------------------------------------
00014  */
00015 #include "postgres.h"
00016 
00017 #include "access/nbtree.h"
00018 
00019 static void
00020 out_target(StringInfo buf, xl_btreetid *target)
00021 {
00022     appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
00023              target->node.spcNode, target->node.dbNode, target->node.relNode,
00024                      ItemPointerGetBlockNumber(&(target->tid)),
00025                      ItemPointerGetOffsetNumber(&(target->tid)));
00026 }
00027 
00028 void
00029 btree_desc(StringInfo buf, uint8 xl_info, char *rec)
00030 {
00031     uint8       info = xl_info & ~XLR_INFO_MASK;
00032 
00033     switch (info)
00034     {
00035         case XLOG_BTREE_INSERT_LEAF:
00036             {
00037                 xl_btree_insert *xlrec = (xl_btree_insert *) rec;
00038 
00039                 appendStringInfo(buf, "insert: ");
00040                 out_target(buf, &(xlrec->target));
00041                 break;
00042             }
00043         case XLOG_BTREE_INSERT_UPPER:
00044             {
00045                 xl_btree_insert *xlrec = (xl_btree_insert *) rec;
00046 
00047                 appendStringInfo(buf, "insert_upper: ");
00048                 out_target(buf, &(xlrec->target));
00049                 break;
00050             }
00051         case XLOG_BTREE_INSERT_META:
00052             {
00053                 xl_btree_insert *xlrec = (xl_btree_insert *) rec;
00054 
00055                 appendStringInfo(buf, "insert_meta: ");
00056                 out_target(buf, &(xlrec->target));
00057                 break;
00058             }
00059         case XLOG_BTREE_SPLIT_L:
00060             {
00061                 xl_btree_split *xlrec = (xl_btree_split *) rec;
00062 
00063                 appendStringInfo(buf, "split_l: rel %u/%u/%u ",
00064                                  xlrec->node.spcNode, xlrec->node.dbNode,
00065                                  xlrec->node.relNode);
00066                 appendStringInfo(buf, "left %u, right %u, next %u, level %u, firstright %d",
00067                                xlrec->leftsib, xlrec->rightsib, xlrec->rnext,
00068                                  xlrec->level, xlrec->firstright);
00069                 break;
00070             }
00071         case XLOG_BTREE_SPLIT_R:
00072             {
00073                 xl_btree_split *xlrec = (xl_btree_split *) rec;
00074 
00075                 appendStringInfo(buf, "split_r: rel %u/%u/%u ",
00076                                  xlrec->node.spcNode, xlrec->node.dbNode,
00077                                  xlrec->node.relNode);
00078                 appendStringInfo(buf, "left %u, right %u, next %u, level %u, firstright %d",
00079                                xlrec->leftsib, xlrec->rightsib, xlrec->rnext,
00080                                  xlrec->level, xlrec->firstright);
00081                 break;
00082             }
00083         case XLOG_BTREE_SPLIT_L_ROOT:
00084             {
00085                 xl_btree_split *xlrec = (xl_btree_split *) rec;
00086 
00087                 appendStringInfo(buf, "split_l_root: rel %u/%u/%u ",
00088                                  xlrec->node.spcNode, xlrec->node.dbNode,
00089                                  xlrec->node.relNode);
00090                 appendStringInfo(buf, "left %u, right %u, next %u, level %u, firstright %d",
00091                                xlrec->leftsib, xlrec->rightsib, xlrec->rnext,
00092                                  xlrec->level, xlrec->firstright);
00093                 break;
00094             }
00095         case XLOG_BTREE_SPLIT_R_ROOT:
00096             {
00097                 xl_btree_split *xlrec = (xl_btree_split *) rec;
00098 
00099                 appendStringInfo(buf, "split_r_root: rel %u/%u/%u ",
00100                                  xlrec->node.spcNode, xlrec->node.dbNode,
00101                                  xlrec->node.relNode);
00102                 appendStringInfo(buf, "left %u, right %u, next %u, level %u, firstright %d",
00103                                xlrec->leftsib, xlrec->rightsib, xlrec->rnext,
00104                                  xlrec->level, xlrec->firstright);
00105                 break;
00106             }
00107         case XLOG_BTREE_VACUUM:
00108             {
00109                 xl_btree_vacuum *xlrec = (xl_btree_vacuum *) rec;
00110 
00111                 appendStringInfo(buf, "vacuum: rel %u/%u/%u; blk %u, lastBlockVacuumed %u",
00112                                  xlrec->node.spcNode, xlrec->node.dbNode,
00113                                  xlrec->node.relNode, xlrec->block,
00114                                  xlrec->lastBlockVacuumed);
00115                 break;
00116             }
00117         case XLOG_BTREE_DELETE:
00118             {
00119                 xl_btree_delete *xlrec = (xl_btree_delete *) rec;
00120 
00121                 appendStringInfo(buf, "delete: index %u/%u/%u; iblk %u, heap %u/%u/%u;",
00122                 xlrec->node.spcNode, xlrec->node.dbNode, xlrec->node.relNode,
00123                                  xlrec->block,
00124                                  xlrec->hnode.spcNode, xlrec->hnode.dbNode, xlrec->hnode.relNode);
00125                 break;
00126             }
00127         case XLOG_BTREE_DELETE_PAGE:
00128         case XLOG_BTREE_DELETE_PAGE_META:
00129         case XLOG_BTREE_DELETE_PAGE_HALF:
00130             {
00131                 xl_btree_delete_page *xlrec = (xl_btree_delete_page *) rec;
00132 
00133                 appendStringInfo(buf, "delete_page: ");
00134                 out_target(buf, &(xlrec->target));
00135                 appendStringInfo(buf, "; dead %u; left %u; right %u",
00136                             xlrec->deadblk, xlrec->leftblk, xlrec->rightblk);
00137                 break;
00138             }
00139         case XLOG_BTREE_NEWROOT:
00140             {
00141                 xl_btree_newroot *xlrec = (xl_btree_newroot *) rec;
00142 
00143                 appendStringInfo(buf, "newroot: rel %u/%u/%u; root %u lev %u",
00144                                  xlrec->node.spcNode, xlrec->node.dbNode,
00145                                  xlrec->node.relNode,
00146                                  xlrec->rootblk, xlrec->level);
00147                 break;
00148             }
00149         case XLOG_BTREE_REUSE_PAGE:
00150             {
00151                 xl_btree_reuse_page *xlrec = (xl_btree_reuse_page *) rec;
00152 
00153                 appendStringInfo(buf, "reuse_page: rel %u/%u/%u; latestRemovedXid %u",
00154                                  xlrec->node.spcNode, xlrec->node.dbNode,
00155                                xlrec->node.relNode, xlrec->latestRemovedXid);
00156                 break;
00157             }
00158         default:
00159             appendStringInfo(buf, "UNKNOWN");
00160             break;
00161     }
00162 }