Coverage Report

Created: 2025-06-13 06:06

/src/postgres/src/backend/access/rmgrdesc/brindesc.c
Line
Count
Source (jump to first uncovered line)
1
/*-------------------------------------------------------------------------
2
 *
3
 * brindesc.c
4
 *    rmgr descriptor routines for BRIN indexes
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/brindesc.c
12
 *
13
 *-------------------------------------------------------------------------
14
 */
15
#include "postgres.h"
16
17
#include "access/brin_xlog.h"
18
19
void
20
brin_desc(StringInfo buf, XLogReaderState *record)
21
0
{
22
0
  char     *rec = XLogRecGetData(record);
23
0
  uint8   info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
24
25
0
  info &= XLOG_BRIN_OPMASK;
26
0
  if (info == XLOG_BRIN_CREATE_INDEX)
27
0
  {
28
0
    xl_brin_createidx *xlrec = (xl_brin_createidx *) rec;
29
30
0
    appendStringInfo(buf, "v%d pagesPerRange %u",
31
0
             xlrec->version, xlrec->pagesPerRange);
32
0
  }
33
0
  else if (info == XLOG_BRIN_INSERT)
34
0
  {
35
0
    xl_brin_insert *xlrec = (xl_brin_insert *) rec;
36
37
0
    appendStringInfo(buf, "heapBlk %u pagesPerRange %u offnum %u",
38
0
             xlrec->heapBlk,
39
0
             xlrec->pagesPerRange,
40
0
             xlrec->offnum);
41
0
  }
42
0
  else if (info == XLOG_BRIN_UPDATE)
43
0
  {
44
0
    xl_brin_update *xlrec = (xl_brin_update *) rec;
45
46
0
    appendStringInfo(buf, "heapBlk %u pagesPerRange %u old offnum %u, new offnum %u",
47
0
             xlrec->insert.heapBlk,
48
0
             xlrec->insert.pagesPerRange,
49
0
             xlrec->oldOffnum,
50
0
             xlrec->insert.offnum);
51
0
  }
52
0
  else if (info == XLOG_BRIN_SAMEPAGE_UPDATE)
53
0
  {
54
0
    xl_brin_samepage_update *xlrec = (xl_brin_samepage_update *) rec;
55
56
0
    appendStringInfo(buf, "offnum %u", xlrec->offnum);
57
0
  }
58
0
  else if (info == XLOG_BRIN_REVMAP_EXTEND)
59
0
  {
60
0
    xl_brin_revmap_extend *xlrec = (xl_brin_revmap_extend *) rec;
61
62
0
    appendStringInfo(buf, "targetBlk %u", xlrec->targetBlk);
63
0
  }
64
0
  else if (info == XLOG_BRIN_DESUMMARIZE)
65
0
  {
66
0
    xl_brin_desummarize *xlrec = (xl_brin_desummarize *) rec;
67
68
0
    appendStringInfo(buf, "pagesPerRange %u, heapBlk %u, page offset %u",
69
0
             xlrec->pagesPerRange, xlrec->heapBlk, xlrec->regOffset);
70
0
  }
71
0
}
72
73
const char *
74
brin_identify(uint8 info)
75
0
{
76
0
  const char *id = NULL;
77
78
0
  switch (info & ~XLR_INFO_MASK)
79
0
  {
80
0
    case XLOG_BRIN_CREATE_INDEX:
81
0
      id = "CREATE_INDEX";
82
0
      break;
83
0
    case XLOG_BRIN_INSERT:
84
0
      id = "INSERT";
85
0
      break;
86
0
    case XLOG_BRIN_INSERT | XLOG_BRIN_INIT_PAGE:
87
0
      id = "INSERT+INIT";
88
0
      break;
89
0
    case XLOG_BRIN_UPDATE:
90
0
      id = "UPDATE";
91
0
      break;
92
0
    case XLOG_BRIN_UPDATE | XLOG_BRIN_INIT_PAGE:
93
0
      id = "UPDATE+INIT";
94
0
      break;
95
0
    case XLOG_BRIN_SAMEPAGE_UPDATE:
96
0
      id = "SAMEPAGE_UPDATE";
97
0
      break;
98
0
    case XLOG_BRIN_REVMAP_EXTEND:
99
0
      id = "REVMAP_EXTEND";
100
0
      break;
101
0
    case XLOG_BRIN_DESUMMARIZE:
102
0
      id = "DESUMMARIZE";
103
0
      break;
104
0
  }
105
106
0
  return id;
107
0
}