| 1 |
/*------------------------------------------------------------------------- |
| 2 |
* |
| 3 |
* gistdesc.c |
| 4 |
* rmgr descriptor routines for access/gist/gistxlog.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/gistdesc.c |
| 12 |
* |
| 13 |
*------------------------------------------------------------------------- |
| 14 |
*/ |
| 15 |
#include "postgres.h" |
| 16 |
|
| 17 |
#include "access/gistxlog.h" |
| 18 |
#include "lib/stringinfo.h" |
| 19 |
|
| 20 |
static void |
| 21 |
out_gistxlogPageUpdate(StringInfo buf, gistxlogPageUpdate *xlrec) |
| 22 |
{ |
| 23 |
} |
| 24 |
|
| 25 |
static void |
| 26 |
out_gistxlogPageReuse(StringInfo buf, gistxlogPageReuse *xlrec) |
| 27 |
{ |
| 28 |
appendStringInfo(buf, "rel %u/%u/%u; blk %u; snapshotConflictHorizon %u:%u, isCatalogRel %c", |
| 29 |
xlrec->locator.spcOid, xlrec->locator.dbOid, |
| 30 |
xlrec->locator.relNumber, xlrec->block, |
| 31 |
EpochFromFullTransactionId(xlrec->snapshotConflictHorizon), |
| 32 |
XidFromFullTransactionId(xlrec->snapshotConflictHorizon), |
| 33 |
xlrec->isCatalogRel ? 'T' : 'F'); |
| 34 |
} |
| 35 |
|
| 36 |
static void |
| 37 |
out_gistxlogDelete(StringInfo buf, gistxlogDelete *xlrec) |
| 38 |
{ |
| 39 |
appendStringInfo(buf, "delete: snapshotConflictHorizon %u, nitems: %u, isCatalogRel %c", |
| 40 |
xlrec->snapshotConflictHorizon, xlrec->ntodelete, |
| 41 |
xlrec->isCatalogRel ? 'T' : 'F'); |
| 42 |
} |
| 43 |
|
| 44 |
static void |
| 45 |
out_gistxlogPageSplit(StringInfo buf, gistxlogPageSplit *xlrec) |
| 46 |
{ |
| 47 |
appendStringInfo(buf, "page_split: splits to %d pages", |
| 48 |
xlrec->npage); |
| 49 |
} |
| 50 |
|
| 51 |
static void |
| 52 |
out_gistxlogPageDelete(StringInfo buf, gistxlogPageDelete *xlrec) |
| 53 |
{ |
| 54 |
appendStringInfo(buf, "deleteXid %u:%u; downlink %u", |
| 55 |
EpochFromFullTransactionId(xlrec->deleteXid), |
| 56 |
XidFromFullTransactionId(xlrec->deleteXid), |
| 57 |
xlrec->downlinkOffset); |
| 58 |
} |
| 59 |
|
| 60 |
void |
| 61 |
gist_desc(StringInfo buf, XLogReaderState *record) |
| 62 |
{ |
| 63 |
char *rec = XLogRecGetData(record); |
| 64 |
uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK; |
| 65 |
|
| 66 |
switch (info) |
| 67 |
{ |
| 68 |
case XLOG_GIST_PAGE_UPDATE: |
| 69 |
out_gistxlogPageUpdate(buf, (gistxlogPageUpdate *) rec); |
| 70 |
break; |
| 71 |
case XLOG_GIST_PAGE_REUSE: |
| 72 |
out_gistxlogPageReuse(buf, (gistxlogPageReuse *) rec); |
| 73 |
break; |
| 74 |
case XLOG_GIST_DELETE: |
| 75 |
out_gistxlogDelete(buf, (gistxlogDelete *) rec); |
| 76 |
break; |
| 77 |
case XLOG_GIST_PAGE_SPLIT: |
| 78 |
out_gistxlogPageSplit(buf, (gistxlogPageSplit *) rec); |
| 79 |
break; |
| 80 |
case XLOG_GIST_PAGE_DELETE: |
| 81 |
out_gistxlogPageDelete(buf, (gistxlogPageDelete *) rec); |
| 82 |
break; |
| 83 |
case XLOG_GIST_ASSIGN_LSN: |
| 84 |
/* No details to write out */ |
| 85 |
break; |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
const char * |
| 90 |
gist_identify(uint8 info) |
| 91 |
{ |
| 92 |
const char *id = NULL; |
| 93 |
|
| 94 |
switch (info & ~XLR_INFO_MASK) |
| 95 |
{ |
| 96 |
case XLOG_GIST_PAGE_UPDATE: |
| 97 |
id = "PAGE_UPDATE"; |
| 98 |
break; |
| 99 |
case XLOG_GIST_DELETE: |
| 100 |
id = "DELETE"; |
| 101 |
break; |
| 102 |
case XLOG_GIST_PAGE_REUSE: |
| 103 |
id = "PAGE_REUSE"; |
| 104 |
break; |
| 105 |
case XLOG_GIST_PAGE_SPLIT: |
| 106 |
id = "PAGE_SPLIT"; |
| 107 |
break; |
| 108 |
case XLOG_GIST_PAGE_DELETE: |
| 109 |
id = "PAGE_DELETE"; |
| 110 |
break; |
| 111 |
case XLOG_GIST_ASSIGN_LSN: |
| 112 |
id = "ASSIGN_LSN"; |
| 113 |
break; |
| 114 |
} |
| 115 |
|
| 116 |
return id; |
| 117 |
} |