Header And Logo

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

mxactdesc.c

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * mxactdesc.c
00004  *    rmgr descriptor routines for access/transam/multixact.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/mxactdesc.c
00012  *
00013  *-------------------------------------------------------------------------
00014  */
00015 #include "postgres.h"
00016 
00017 #include "access/multixact.h"
00018 
00019 static void
00020 out_member(StringInfo buf, MultiXactMember *member)
00021 {
00022     appendStringInfo(buf, "%u ", member->xid);
00023     switch (member->status)
00024     {
00025         case MultiXactStatusForKeyShare:
00026             appendStringInfoString(buf, "(keysh) ");
00027             break;
00028         case MultiXactStatusForShare:
00029             appendStringInfoString(buf, "(sh) ");
00030             break;
00031         case MultiXactStatusForNoKeyUpdate:
00032             appendStringInfoString(buf, "(fornokeyupd) ");
00033             break;
00034         case MultiXactStatusForUpdate:
00035             appendStringInfoString(buf, "(forupd) ");
00036             break;
00037         case MultiXactStatusNoKeyUpdate:
00038             appendStringInfoString(buf, "(nokeyupd) ");
00039             break;
00040         case MultiXactStatusUpdate:
00041             appendStringInfoString(buf, "(upd) ");
00042             break;
00043         default:
00044             appendStringInfoString(buf, "(unk) ");
00045             break;
00046     }
00047 }
00048 
00049 void
00050 multixact_desc(StringInfo buf, uint8 xl_info, char *rec)
00051 {
00052     uint8       info = xl_info & ~XLR_INFO_MASK;
00053 
00054     if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE)
00055     {
00056         int         pageno;
00057 
00058         memcpy(&pageno, rec, sizeof(int));
00059         appendStringInfo(buf, "zero offsets page: %d", pageno);
00060     }
00061     else if (info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
00062     {
00063         int         pageno;
00064 
00065         memcpy(&pageno, rec, sizeof(int));
00066         appendStringInfo(buf, "zero members page: %d", pageno);
00067     }
00068     else if (info == XLOG_MULTIXACT_CREATE_ID)
00069     {
00070         xl_multixact_create *xlrec = (xl_multixact_create *) rec;
00071         int         i;
00072 
00073         appendStringInfo(buf, "create mxid %u offset %u nmembers %d: ", xlrec->mid,
00074                          xlrec->moff, xlrec->nmembers);
00075         for (i = 0; i < xlrec->nmembers; i++)
00076             out_member(buf, &xlrec->members[i]);
00077     }
00078     else
00079         appendStringInfo(buf, "UNKNOWN");
00080 }