summaryrefslogtreecommitdiffstats
path: root/src/backend/access/rmgrdesc/replorigindesc.c
blob: 19e14f910bafd465e3699caf17c56b5785b3b5c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*-------------------------------------------------------------------------
 *
 * replorigindesc.c
 *	  rmgr descriptor routines for replication/logical/origin.c
 *
 * Portions Copyright (c) 2015-2020, PostgreSQL Global Development Group
 *
 *
 * IDENTIFICATION
 *	  src/backend/access/rmgrdesc/replorigindesc.c
 *
 *-------------------------------------------------------------------------
 */
#include "postgres.h"

#include "replication/origin.h"

void
replorigin_desc(StringInfo buf, XLogReaderState *record)
{
	char	   *rec = XLogRecGetData(record);
	uint8		info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;

	switch (info)
	{
		case XLOG_REPLORIGIN_SET:
			{
				xl_replorigin_set *xlrec;

				xlrec = (xl_replorigin_set *) rec;

				appendStringInfo(buf, "set %u; lsn %X/%X; force: %d",
								 xlrec->node_id,
								 (uint32) (xlrec->remote_lsn >> 32),
								 (uint32) xlrec->remote_lsn,
								 xlrec->force);
				break;
			}
		case XLOG_REPLORIGIN_DROP:
			{
				xl_replorigin_drop *xlrec;

				xlrec = (xl_replorigin_drop *) rec;

				appendStringInfo(buf, "drop %u", xlrec->node_id);
				break;
			}
	}
}

const char *
replorigin_identify(uint8 info)
{
	switch (info)
	{
		case XLOG_REPLORIGIN_SET:
			return "SET";
		case XLOG_REPLORIGIN_DROP:
			return "DROP";
		default:
			return NULL;
	}
}