PostgreSQL Source Code  git master
clogdesc.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * clogdesc.c
4  * rmgr descriptor routines for access/transam/clog.c
5  *
6  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  * src/backend/access/rmgrdesc/clogdesc.c
12  *
13  *-------------------------------------------------------------------------
14  */
15 #include "postgres.h"
16 
17 #include "access/clog.h"
18 
19 
20 void
22 {
23  char *rec = XLogRecGetData(record);
24  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
25 
26  if (info == CLOG_ZEROPAGE)
27  {
28  int64 pageno;
29 
30  memcpy(&pageno, rec, sizeof(pageno));
31  appendStringInfo(buf, "page %lld", (long long) pageno);
32  }
33  else if (info == CLOG_TRUNCATE)
34  {
35  xl_clog_truncate xlrec;
36 
37  memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
38  appendStringInfo(buf, "page %lld; oldestXact %u",
39  (long long) xlrec.pageno, xlrec.oldestXact);
40  }
41 }
42 
43 const char *
45 {
46  const char *id = NULL;
47 
48  switch (info & ~XLR_INFO_MASK)
49  {
50  case CLOG_ZEROPAGE:
51  id = "ZEROPAGE";
52  break;
53  case CLOG_TRUNCATE:
54  id = "TRUNCATE";
55  break;
56  }
57 
58  return id;
59 }
unsigned char uint8
Definition: c.h:504
#define CLOG_ZEROPAGE
Definition: clog.h:55
#define CLOG_TRUNCATE
Definition: clog.h:56
const char * clog_identify(uint8 info)
Definition: clogdesc.c:44
void clog_desc(StringInfo buf, XLogReaderState *record)
Definition: clogdesc.c:21
static char * buf
Definition: pg_test_fsync.c:73
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:97
int64 pageno
Definition: clog.h:34
TransactionId oldestXact
Definition: clog.h:35
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:410
#define XLogRecGetData(decoder)
Definition: xlogreader.h:415
#define XLR_INFO_MASK
Definition: xlogrecord.h:62