Header And Logo

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

standbydesc.c

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * standbydesc.c
00004  *    rmgr descriptor routines for storage/ipc/standby.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/standbydesc.c
00012  *
00013  *-------------------------------------------------------------------------
00014  */
00015 #include "postgres.h"
00016 
00017 #include "storage/standby.h"
00018 
00019 static void
00020 standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
00021 {
00022     int         i;
00023 
00024     appendStringInfo(buf, " nextXid %u latestCompletedXid %u oldestRunningXid %u",
00025                      xlrec->nextXid,
00026                      xlrec->latestCompletedXid,
00027                      xlrec->oldestRunningXid);
00028     if (xlrec->xcnt > 0)
00029     {
00030         appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
00031         for (i = 0; i < xlrec->xcnt; i++)
00032             appendStringInfo(buf, " %u", xlrec->xids[i]);
00033     }
00034 
00035     if (xlrec->subxid_overflow)
00036         appendStringInfo(buf, "; subxid ovf");
00037 }
00038 
00039 void
00040 standby_desc(StringInfo buf, uint8 xl_info, char *rec)
00041 {
00042     uint8       info = xl_info & ~XLR_INFO_MASK;
00043 
00044     if (info == XLOG_STANDBY_LOCK)
00045     {
00046         xl_standby_locks *xlrec = (xl_standby_locks *) rec;
00047         int         i;
00048 
00049         appendStringInfo(buf, "AccessExclusive locks:");
00050 
00051         for (i = 0; i < xlrec->nlocks; i++)
00052             appendStringInfo(buf, " xid %u db %u rel %u",
00053                              xlrec->locks[i].xid, xlrec->locks[i].dbOid,
00054                              xlrec->locks[i].relOid);
00055     }
00056     else if (info == XLOG_RUNNING_XACTS)
00057     {
00058         xl_running_xacts *xlrec = (xl_running_xacts *) rec;
00059 
00060         appendStringInfo(buf, "running xacts:");
00061         standby_desc_running_xacts(buf, xlrec);
00062     }
00063     else
00064         appendStringInfo(buf, "UNKNOWN");
00065 }