summaryrefslogtreecommitdiffstats
path: root/src/backend/access/rmgrdesc/hashdesc.c
blob: b6810a932071bfd2f7dd70e8c20004f2c44095df (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*-------------------------------------------------------------------------
 *
 * hashdesc.c
 *	  rmgr descriptor routines for access/hash/hash.c
 *
 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 *
 * IDENTIFICATION
 *	  src/backend/access/rmgrdesc/hashdesc.c
 *
 *-------------------------------------------------------------------------
 */
#include "postgres.h"

#include "access/hash_xlog.h"

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

	switch (info)
	{
		case XLOG_HASH_INIT_META_PAGE:
			{
				xl_hash_init_meta_page *xlrec = (xl_hash_init_meta_page *) rec;

				appendStringInfo(buf, "num_tuples %g, fillfactor %d",
								 xlrec->num_tuples, xlrec->ffactor);
				break;
			}
		case XLOG_HASH_INIT_BITMAP_PAGE:
			{
				xl_hash_init_bitmap_page *xlrec = (xl_hash_init_bitmap_page *) rec;

				appendStringInfo(buf, "bmsize %d", xlrec->bmsize);
				break;
			}
		case XLOG_HASH_INSERT:
			{
				xl_hash_insert *xlrec = (xl_hash_insert *) rec;

				appendStringInfo(buf, "off %u", xlrec->offnum);
				break;
			}
		case XLOG_HASH_ADD_OVFL_PAGE:
			{
				xl_hash_add_ovfl_page *xlrec = (xl_hash_add_ovfl_page *) rec;

				appendStringInfo(buf, "bmsize %d, bmpage_found %c",
								 xlrec->bmsize, (xlrec->bmpage_found) ? 'T' : 'F');
				break;
			}
		case XLOG_HASH_SPLIT_ALLOCATE_PAGE:
			{
				xl_hash_split_allocate_page *xlrec = (xl_hash_split_allocate_page *) rec;

				appendStringInfo(buf, "new_bucket %u, meta_page_masks_updated %c, issplitpoint_changed %c",
								 xlrec->new_bucket,
								 (xlrec->flags & XLH_SPLIT_META_UPDATE_MASKS) ? 'T' : 'F',
								 (xlrec->flags & XLH_SPLIT_META_UPDATE_SPLITPOINT) ? 'T' : 'F');
				break;
			}
		case XLOG_HASH_SPLIT_COMPLETE:
			{
				xl_hash_split_complete *xlrec = (xl_hash_split_complete *) rec;

				appendStringInfo(buf, "old_bucket_flag %u, new_bucket_flag %u",
								 xlrec->old_bucket_flag, xlrec->new_bucket_flag);
				break;
			}
		case XLOG_HASH_MOVE_PAGE_CONTENTS:
			{
				xl_hash_move_page_contents *xlrec = (xl_hash_move_page_contents *) rec;

				appendStringInfo(buf, "ntups %d, is_primary %c",
								 xlrec->ntups,
								 xlrec->is_prim_bucket_same_wrt ? 'T' : 'F');
				break;
			}
		case XLOG_HASH_SQUEEZE_PAGE:
			{
				xl_hash_squeeze_page *xlrec = (xl_hash_squeeze_page *) rec;

				appendStringInfo(buf, "prevblkno %u, nextblkno %u, ntups %d, is_primary %c",
								 xlrec->prevblkno,
								 xlrec->nextblkno,
								 xlrec->ntups,
								 xlrec->is_prim_bucket_same_wrt ? 'T' : 'F');
				break;
			}
		case XLOG_HASH_DELETE:
			{
				xl_hash_delete *xlrec = (xl_hash_delete *) rec;

				appendStringInfo(buf, "clear_dead_marking %c, is_primary %c",
								 xlrec->clear_dead_marking ? 'T' : 'F',
								 xlrec->is_primary_bucket_page ? 'T' : 'F');
				break;
			}
		case XLOG_HASH_UPDATE_META_PAGE:
			{
				xl_hash_update_meta_page *xlrec = (xl_hash_update_meta_page *) rec;

				appendStringInfo(buf, "ntuples %g",
								 xlrec->ntuples);
				break;
			}
		case XLOG_HASH_VACUUM_ONE_PAGE:
			{
				xl_hash_vacuum_one_page *xlrec = (xl_hash_vacuum_one_page *) rec;

				appendStringInfo(buf, "ntuples %d, snapshotConflictHorizon %u",
								 xlrec->ntuples,
								 xlrec->snapshotConflictHorizon);
				break;
			}
	}
}

const char *
hash_identify(uint8 info)
{
	const char *id = NULL;

	switch (info & ~XLR_INFO_MASK)
	{
		case XLOG_HASH_INIT_META_PAGE:
			id = "INIT_META_PAGE";
			break;
		case XLOG_HASH_INIT_BITMAP_PAGE:
			id = "INIT_BITMAP_PAGE";
			break;
		case XLOG_HASH_INSERT:
			id = "INSERT";
			break;
		case XLOG_HASH_ADD_OVFL_PAGE:
			id = "ADD_OVFL_PAGE";
			break;
		case XLOG_HASH_SPLIT_ALLOCATE_PAGE:
			id = "SPLIT_ALLOCATE_PAGE";
			break;
		case XLOG_HASH_SPLIT_PAGE:
			id = "SPLIT_PAGE";
			break;
		case XLOG_HASH_SPLIT_COMPLETE:
			id = "SPLIT_COMPLETE";
			break;
		case XLOG_HASH_MOVE_PAGE_CONTENTS:
			id = "MOVE_PAGE_CONTENTS";
			break;
		case XLOG_HASH_SQUEEZE_PAGE:
			id = "SQUEEZE_PAGE";
			break;
		case XLOG_HASH_DELETE:
			id = "DELETE";
			break;
		case XLOG_HASH_SPLIT_CLEANUP:
			id = "SPLIT_CLEANUP";
			break;
		case XLOG_HASH_UPDATE_META_PAGE:
			id = "UPDATE_META_PAGE";
			break;
		case XLOG_HASH_VACUUM_ONE_PAGE:
			id = "VACUUM_ONE_PAGE";
	}

	return id;
}