| 1 |
/*------------------------------------------------------------------------- |
| 2 |
* |
| 3 |
* spgdesc.c |
| 4 |
* rmgr descriptor routines for access/spgist/spgxlog.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/spgdesc.c |
| 12 |
* |
| 13 |
*------------------------------------------------------------------------- |
| 14 |
*/ |
| 15 |
#include "postgres.h" |
| 16 |
|
| 17 |
#include "access/spgxlog.h" |
| 18 |
|
| 19 |
void |
| 20 |
spg_desc(StringInfo buf, XLogReaderState *record) |
| 21 |
{ |
| 22 |
char *rec = XLogRecGetData(record); |
| 23 |
uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK; |
| 24 |
|
| 25 |
switch (info) |
| 26 |
{ |
| 27 |
case XLOG_SPGIST_ADD_LEAF: |
| 28 |
{ |
| 29 |
spgxlogAddLeaf *xlrec = (spgxlogAddLeaf *) rec; |
| 30 |
|
| 31 |
appendStringInfo(buf, "off: %u, headoff: %u, parentoff: %u, nodeI: %u", |
| 32 |
xlrec->offnumLeaf, xlrec->offnumHeadLeaf, |
| 33 |
xlrec->offnumParent, xlrec->nodeI); |
| 34 |
if (xlrec->newPage) |
| 35 |
appendStringInfoString(buf, " (newpage)"); |
| 36 |
if (xlrec->storesNulls) |
| 37 |
appendStringInfoString(buf, " (nulls)"); |
| 38 |
} |
| 39 |
break; |
| 40 |
case XLOG_SPGIST_MOVE_LEAFS: |
| 41 |
{ |
| 42 |
spgxlogMoveLeafs *xlrec = (spgxlogMoveLeafs *) rec; |
| 43 |
|
| 44 |
appendStringInfo(buf, "nmoves: %u, parentoff: %u, nodeI: %u", |
| 45 |
xlrec->nMoves, |
| 46 |
xlrec->offnumParent, xlrec->nodeI); |
| 47 |
if (xlrec->newPage) |
| 48 |
appendStringInfoString(buf, " (newpage)"); |
| 49 |
if (xlrec->replaceDead) |
| 50 |
appendStringInfoString(buf, " (replacedead)"); |
| 51 |
if (xlrec->storesNulls) |
| 52 |
appendStringInfoString(buf, " (nulls)"); |
| 53 |
} |
| 54 |
break; |
| 55 |
case XLOG_SPGIST_ADD_NODE: |
| 56 |
{ |
| 57 |
spgxlogAddNode *xlrec = (spgxlogAddNode *) rec; |
| 58 |
|
| 59 |
appendStringInfo(buf, "off: %u, newoff: %u, parentBlk: %d, " |
| 60 |
"parentoff: %u, nodeI: %u", |
| 61 |
xlrec->offnum, |
| 62 |
xlrec->offnumNew, |
| 63 |
xlrec->parentBlk, |
| 64 |
xlrec->offnumParent, |
| 65 |
xlrec->nodeI); |
| 66 |
if (xlrec->newPage) |
| 67 |
appendStringInfoString(buf, " (newpage)"); |
| 68 |
} |
| 69 |
break; |
| 70 |
case XLOG_SPGIST_SPLIT_TUPLE: |
| 71 |
{ |
| 72 |
spgxlogSplitTuple *xlrec = (spgxlogSplitTuple *) rec; |
| 73 |
|
| 74 |
appendStringInfo(buf, "prefixoff: %u, postfixoff: %u", |
| 75 |
xlrec->offnumPrefix, |
| 76 |
xlrec->offnumPostfix); |
| 77 |
if (xlrec->newPage) |
| 78 |
appendStringInfoString(buf, " (newpage)"); |
| 79 |
if (xlrec->postfixBlkSame) |
| 80 |
appendStringInfoString(buf, " (same)"); |
| 81 |
} |
| 82 |
break; |
| 83 |
case XLOG_SPGIST_PICKSPLIT: |
| 84 |
{ |
| 85 |
spgxlogPickSplit *xlrec = (spgxlogPickSplit *) rec; |
| 86 |
|
| 87 |
appendStringInfo(buf, "ndelete: %u, ninsert: %u, inneroff: %u, " |
| 88 |
"parentoff: %u, nodeI: %u", |
| 89 |
xlrec->nDelete, xlrec->nInsert, |
| 90 |
xlrec->offnumInner, |
| 91 |
xlrec->offnumParent, xlrec->nodeI); |
| 92 |
if (xlrec->innerIsParent) |
| 93 |
appendStringInfoString(buf, " (innerIsParent)"); |
| 94 |
if (xlrec->storesNulls) |
| 95 |
appendStringInfoString(buf, " (nulls)"); |
| 96 |
if (xlrec->isRootSplit) |
| 97 |
appendStringInfoString(buf, " (isRootSplit)"); |
| 98 |
} |
| 99 |
break; |
| 100 |
case XLOG_SPGIST_VACUUM_LEAF: |
| 101 |
{ |
| 102 |
spgxlogVacuumLeaf *xlrec = (spgxlogVacuumLeaf *) rec; |
| 103 |
|
| 104 |
appendStringInfo(buf, "ndead: %u, nplaceholder: %u, nmove: %u, nchain: %u", |
| 105 |
xlrec->nDead, xlrec->nPlaceholder, |
| 106 |
xlrec->nMove, xlrec->nChain); |
| 107 |
} |
| 108 |
break; |
| 109 |
case XLOG_SPGIST_VACUUM_ROOT: |
| 110 |
{ |
| 111 |
spgxlogVacuumRoot *xlrec = (spgxlogVacuumRoot *) rec; |
| 112 |
|
| 113 |
appendStringInfo(buf, "ndelete: %u", |
| 114 |
xlrec->nDelete); |
| 115 |
} |
| 116 |
break; |
| 117 |
case XLOG_SPGIST_VACUUM_REDIRECT: |
| 118 |
{ |
| 119 |
spgxlogVacuumRedirect *xlrec = (spgxlogVacuumRedirect *) rec; |
| 120 |
|
| 121 |
appendStringInfo(buf, "ntoplaceholder: %u, firstplaceholder: %u, snapshotConflictHorizon: %u, isCatalogRel: %c", |
| 122 |
xlrec->nToPlaceholder, |
| 123 |
xlrec->firstPlaceholder, |
| 124 |
xlrec->snapshotConflictHorizon, |
| 125 |
xlrec->isCatalogRel ? 'T' : 'F'); |
| 126 |
} |
| 127 |
break; |
| 128 |
} |
| 129 |
} |
| 130 |
|
| 131 |
const char * |
| 132 |
spg_identify(uint8 info) |
| 133 |
{ |
| 134 |
const char *id = NULL; |
| 135 |
|
| 136 |
switch (info & ~XLR_INFO_MASK) |
| 137 |
{ |
| 138 |
case XLOG_SPGIST_ADD_LEAF: |
| 139 |
id = "ADD_LEAF"; |
| 140 |
break; |
| 141 |
case XLOG_SPGIST_MOVE_LEAFS: |
| 142 |
id = "MOVE_LEAFS"; |
| 143 |
break; |
| 144 |
case XLOG_SPGIST_ADD_NODE: |
| 145 |
id = "ADD_NODE"; |
| 146 |
break; |
| 147 |
case XLOG_SPGIST_SPLIT_TUPLE: |
| 148 |
id = "SPLIT_TUPLE"; |
| 149 |
break; |
| 150 |
case XLOG_SPGIST_PICKSPLIT: |
| 151 |
id = "PICKSPLIT"; |
| 152 |
break; |
| 153 |
case XLOG_SPGIST_VACUUM_LEAF: |
| 154 |
id = "VACUUM_LEAF"; |
| 155 |
break; |
| 156 |
case XLOG_SPGIST_VACUUM_ROOT: |
| 157 |
id = "VACUUM_ROOT"; |
| 158 |
break; |
| 159 |
case XLOG_SPGIST_VACUUM_REDIRECT: |
| 160 |
id = "VACUUM_REDIRECT"; |
| 161 |
break; |
| 162 |
} |
| 163 |
|
| 164 |
return id; |
| 165 |
} |