Coverage Report

Created: 2025-10-09 06:07

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/postgres/src/backend/access/rmgrdesc/mxactdesc.c
Line
Count
Source
1
/*-------------------------------------------------------------------------
2
 *
3
 * mxactdesc.c
4
 *    rmgr descriptor routines for access/transam/multixact.c
5
 *
6
 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7
 * Portions Copyright (c) 1994, Regents of the University of California
8
 *
9
 *
10
 * IDENTIFICATION
11
 *    src/backend/access/rmgrdesc/mxactdesc.c
12
 *
13
 *-------------------------------------------------------------------------
14
 */
15
#include "postgres.h"
16
17
#include "access/multixact.h"
18
19
static void
20
out_member(StringInfo buf, MultiXactMember *member)
21
0
{
22
0
  appendStringInfo(buf, "%u ", member->xid);
23
0
  switch (member->status)
24
0
  {
25
0
    case MultiXactStatusForKeyShare:
26
0
      appendStringInfoString(buf, "(keysh) ");
27
0
      break;
28
0
    case MultiXactStatusForShare:
29
0
      appendStringInfoString(buf, "(sh) ");
30
0
      break;
31
0
    case MultiXactStatusForNoKeyUpdate:
32
0
      appendStringInfoString(buf, "(fornokeyupd) ");
33
0
      break;
34
0
    case MultiXactStatusForUpdate:
35
0
      appendStringInfoString(buf, "(forupd) ");
36
0
      break;
37
0
    case MultiXactStatusNoKeyUpdate:
38
0
      appendStringInfoString(buf, "(nokeyupd) ");
39
0
      break;
40
0
    case MultiXactStatusUpdate:
41
0
      appendStringInfoString(buf, "(upd) ");
42
0
      break;
43
0
    default:
44
0
      appendStringInfoString(buf, "(unk) ");
45
0
      break;
46
0
  }
47
0
}
48
49
void
50
multixact_desc(StringInfo buf, XLogReaderState *record)
51
0
{
52
0
  char     *rec = XLogRecGetData(record);
53
0
  uint8   info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
54
55
0
  if (info == XLOG_MULTIXACT_ZERO_OFF_PAGE ||
56
0
    info == XLOG_MULTIXACT_ZERO_MEM_PAGE)
57
0
  {
58
0
    int64   pageno;
59
60
0
    memcpy(&pageno, rec, sizeof(pageno));
61
0
    appendStringInfo(buf, "%" PRId64, pageno);
62
0
  }
63
0
  else if (info == XLOG_MULTIXACT_CREATE_ID)
64
0
  {
65
0
    xl_multixact_create *xlrec = (xl_multixact_create *) rec;
66
0
    int     i;
67
68
0
    appendStringInfo(buf, "%u offset %u nmembers %d: ", xlrec->mid,
69
0
             xlrec->moff, xlrec->nmembers);
70
0
    for (i = 0; i < xlrec->nmembers; i++)
71
0
      out_member(buf, &xlrec->members[i]);
72
0
  }
73
0
  else if (info == XLOG_MULTIXACT_TRUNCATE_ID)
74
0
  {
75
0
    xl_multixact_truncate *xlrec = (xl_multixact_truncate *) rec;
76
77
0
    appendStringInfo(buf, "offsets [%u, %u), members [%u, %u)",
78
0
             xlrec->startTruncOff, xlrec->endTruncOff,
79
0
             xlrec->startTruncMemb, xlrec->endTruncMemb);
80
0
  }
81
0
}
82
83
const char *
84
multixact_identify(uint8 info)
85
0
{
86
0
  const char *id = NULL;
87
88
0
  switch (info & ~XLR_INFO_MASK)
89
0
  {
90
0
    case XLOG_MULTIXACT_ZERO_OFF_PAGE:
91
0
      id = "ZERO_OFF_PAGE";
92
0
      break;
93
0
    case XLOG_MULTIXACT_ZERO_MEM_PAGE:
94
0
      id = "ZERO_MEM_PAGE";
95
0
      break;
96
0
    case XLOG_MULTIXACT_CREATE_ID:
97
0
      id = "CREATE_ID";
98
0
      break;
99
0
    case XLOG_MULTIXACT_TRUNCATE_ID:
100
0
      id = "TRUNCATE_ID";
101
0
      break;
102
0
  }
103
104
0
  return id;
105
0
}