Header And Logo

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

Functions

xactdesc.c File Reference

#include "postgres.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "common/relpath.h"
#include "storage/sinval.h"
#include "utils/timestamp.h"
Include dependency graph for xactdesc.c:

Go to the source code of this file.

Functions

static void xact_desc_commit (StringInfo buf, xl_xact_commit *xlrec)
static void xact_desc_commit_compact (StringInfo buf, xl_xact_commit_compact *xlrec)
static void xact_desc_abort (StringInfo buf, xl_xact_abort *xlrec)
static void xact_desc_assignment (StringInfo buf, xl_xact_assignment *xlrec)
void xact_desc (StringInfo buf, uint8 xl_info, char *rec)

Function Documentation

void xact_desc ( StringInfo  buf,
uint8  xl_info,
char *  rec 
)

Definition at line 138 of file xactdesc.c.

References appendStringInfo(), xl_xact_abort_prepared::arec, xl_xact_commit_prepared::crec, xact_desc_abort(), xact_desc_assignment(), xact_desc_commit(), xact_desc_commit_compact(), xl_xact_abort_prepared::xid, xl_xact_commit_prepared::xid, XLOG_XACT_ABORT, XLOG_XACT_ABORT_PREPARED, XLOG_XACT_ASSIGNMENT, XLOG_XACT_COMMIT, XLOG_XACT_COMMIT_COMPACT, XLOG_XACT_COMMIT_PREPARED, XLOG_XACT_PREPARE, and xl_xact_assignment::xtop.

{
    uint8       info = xl_info & ~XLR_INFO_MASK;

    if (info == XLOG_XACT_COMMIT_COMPACT)
    {
        xl_xact_commit_compact *xlrec = (xl_xact_commit_compact *) rec;

        appendStringInfo(buf, "commit: ");
        xact_desc_commit_compact(buf, xlrec);
    }
    else if (info == XLOG_XACT_COMMIT)
    {
        xl_xact_commit *xlrec = (xl_xact_commit *) rec;

        appendStringInfo(buf, "commit: ");
        xact_desc_commit(buf, xlrec);
    }
    else if (info == XLOG_XACT_ABORT)
    {
        xl_xact_abort *xlrec = (xl_xact_abort *) rec;

        appendStringInfo(buf, "abort: ");
        xact_desc_abort(buf, xlrec);
    }
    else if (info == XLOG_XACT_PREPARE)
    {
        appendStringInfo(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);
        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);
        xact_desc_abort(buf, &xlrec->arec);
    }
    else if (info == XLOG_XACT_ASSIGNMENT)
    {
        xl_xact_assignment *xlrec = (xl_xact_assignment *) rec;

        /*
         * Note that we ignore the WAL record's xid, since we're more
         * 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);
        xact_desc_assignment(buf, xlrec);
    }
    else
        appendStringInfo(buf, "UNKNOWN");
}

static void xact_desc_abort ( StringInfo  buf,
xl_xact_abort xlrec 
) [static]

Definition at line 99 of file xactdesc.c.

References appendStringInfo(), appendStringInfoString(), i, MAIN_FORKNUM, xl_xact_abort::nrels, xl_xact_abort::nsubxacts, pfree(), relpathperm, timestamptz_to_str(), xl_xact_abort::xact_time, and xl_xact_abort::xnodes.

Referenced by xact_desc().

{
    int         i;

    appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));
    if (xlrec->nrels > 0)
    {
        appendStringInfo(buf, "; rels:");
        for (i = 0; i < xlrec->nrels; i++)
        {
            char       *path = relpathperm(xlrec->xnodes[i], MAIN_FORKNUM);

            appendStringInfo(buf, " %s", path);
            pfree(path);
        }
    }
    if (xlrec->nsubxacts > 0)
    {
        TransactionId *xacts = (TransactionId *)
        &xlrec->xnodes[xlrec->nrels];

        appendStringInfo(buf, "; subxacts:");
        for (i = 0; i < xlrec->nsubxacts; i++)
            appendStringInfo(buf, " %u", xacts[i]);
    }
}

static void xact_desc_assignment ( StringInfo  buf,
xl_xact_assignment xlrec 
) [static]

Definition at line 127 of file xactdesc.c.

References appendStringInfo(), i, xl_xact_assignment::nsubxacts, and xl_xact_assignment::xsub.

Referenced by xact_desc().

{
    int         i;

    appendStringInfo(buf, "subxacts:");

    for (i = 0; i < xlrec->nsubxacts; i++)
        appendStringInfo(buf, " %u", xlrec->xsub[i]);
}

static void xact_desc_commit ( StringInfo  buf,
xl_xact_commit xlrec 
) [static]

Definition at line 25 of file xactdesc.c.

References appendStringInfo(), appendStringInfoString(), SharedInvalidationMessage::cat, SharedInvalCatalogMsg::catId, xl_xact_commit::dbId, i, SharedInvalidationMessage::id, MAIN_FORKNUM, xl_xact_commit::nmsgs, xl_xact_commit::nrels, xl_xact_commit::nsubxacts, pfree(), SharedInvalidationMessage::rc, SharedInvalRelcacheMsg::relId, relpathperm, SHAREDINVALCATALOG_ID, SHAREDINVALRELCACHE_ID, SHAREDINVALRELMAP_ID, SHAREDINVALSMGR_ID, timestamptz_to_str(), xl_xact_commit::tsId, xl_xact_commit::xact_time, XactCompletionRelcacheInitFileInval, xl_xact_commit::xinfo, and xl_xact_commit::xnodes.

Referenced by xact_desc().

{
    int         i;
    TransactionId *subxacts;

    subxacts = (TransactionId *) &xlrec->xnodes[xlrec->nrels];

    appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));

    if (xlrec->nrels > 0)
    {
        appendStringInfo(buf, "; rels:");
        for (i = 0; i < xlrec->nrels; i++)
        {
            char       *path = relpathperm(xlrec->xnodes[i], MAIN_FORKNUM);

            appendStringInfo(buf, " %s", path);
            pfree(path);
        }
    }
    if (xlrec->nsubxacts > 0)
    {
        appendStringInfo(buf, "; subxacts:");
        for (i = 0; i < xlrec->nsubxacts; i++)
            appendStringInfo(buf, " %u", subxacts[i]);
    }
    if (xlrec->nmsgs > 0)
    {
        SharedInvalidationMessage *msgs;

        msgs = (SharedInvalidationMessage *) &subxacts[xlrec->nsubxacts];

        if (XactCompletionRelcacheInitFileInval(xlrec->xinfo))
            appendStringInfo(buf, "; relcache init file inval dbid %u tsid %u",
                             xlrec->dbId, xlrec->tsId);

        appendStringInfo(buf, "; inval msgs:");
        for (i = 0; i < xlrec->nmsgs; i++)
        {
            SharedInvalidationMessage *msg = &msgs[i];

            if (msg->id >= 0)
                appendStringInfo(buf, " catcache %d", msg->id);
            else if (msg->id == SHAREDINVALCATALOG_ID)
                appendStringInfo(buf, " catalog %u", msg->cat.catId);
            else if (msg->id == SHAREDINVALRELCACHE_ID)
                appendStringInfo(buf, " relcache %u", msg->rc.relId);
            /* remaining cases not expected, but print something anyway */
            else if (msg->id == SHAREDINVALSMGR_ID)
                appendStringInfo(buf, " smgr");
            else if (msg->id == SHAREDINVALRELMAP_ID)
                appendStringInfo(buf, " relmap");
            else
                appendStringInfo(buf, " unknown id %d", msg->id);
        }
    }
}

static void xact_desc_commit_compact ( StringInfo  buf,
xl_xact_commit_compact xlrec 
) [static]

Definition at line 84 of file xactdesc.c.

References appendStringInfo(), appendStringInfoString(), i, xl_xact_commit_compact::nsubxacts, xl_xact_commit_compact::subxacts, timestamptz_to_str(), and xl_xact_commit_compact::xact_time.

Referenced by xact_desc().

{
    int         i;

    appendStringInfoString(buf, timestamptz_to_str(xlrec->xact_time));

    if (xlrec->nsubxacts > 0)
    {
        appendStringInfo(buf, "; subxacts:");
        for (i = 0; i < xlrec->nsubxacts; i++)
            appendStringInfo(buf, " %u", xlrec->subxacts[i]);
    }
}