PostgreSQL Source Code  git master
genericdesc.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * genericdesc.c
4  * rmgr descriptor routines for access/transam/generic_xlog.c
5  *
6  *
7  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * src/backend/access/rmgrdesc/genericdesc.c
11  *
12  *-------------------------------------------------------------------------
13  */
14 #include "postgres.h"
15 
16 #include "access/generic_xlog.h"
17 #include "lib/stringinfo.h"
18 
19 /*
20  * Description of generic xlog record: write page regions that this record
21  * overrides.
22  */
23 void
25 {
26  Pointer ptr = XLogRecGetData(record),
27  end = ptr + XLogRecGetDataLen(record);
28 
29  while (ptr < end)
30  {
31  OffsetNumber offset,
32  length;
33 
34  memcpy(&offset, ptr, sizeof(offset));
35  ptr += sizeof(offset);
36  memcpy(&length, ptr, sizeof(length));
37  ptr += sizeof(length);
38  ptr += length;
39 
40  if (ptr < end)
41  appendStringInfo(buf, "offset %u, length %u; ", offset, length);
42  else
43  appendStringInfo(buf, "offset %u, length %u", offset, length);
44  }
45 }
46 
47 /*
48  * Identification of generic xlog record: we don't distinguish any subtypes
49  * inside generic xlog records.
50  */
51 const char *
53 {
54  return "Generic";
55 }
char * Pointer
Definition: c.h:483
unsigned char uint8
Definition: c.h:504
const char * generic_identify(uint8 info)
Definition: genericdesc.c:52
void generic_desc(StringInfo buf, XLogReaderState *record)
Definition: genericdesc.c:24
uint16 OffsetNumber
Definition: off.h:24
static char * buf
Definition: pg_test_fsync.c:73
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:97
#define XLogRecGetDataLen(decoder)
Definition: xlogreader.h:416
#define XLogRecGetData(decoder)
Definition: xlogreader.h:415