PostgreSQL Source Code git master
Loading...
Searching...
No Matches
heapdesc.c File Reference
Include dependency graph for heapdesc.c:

Go to the source code of this file.

Functions

static void infobits_desc (StringInfo buf, uint8 infobits, const char *keyname)
 
static void truncate_flags_desc (StringInfo buf, uint8 flags)
 
static void plan_elem_desc (StringInfo buf, void *plan, void *data)
 
void heap_xlog_deserialize_prune_and_freeze (char *cursor, uint16 flags, int *nplans, xlhp_freeze_plan **plans, OffsetNumber **frz_offsets, int *nredirected, OffsetNumber **redirected, int *ndead, OffsetNumber **nowdead, int *nunused, OffsetNumber **nowunused)
 
void heap_desc (StringInfo buf, XLogReaderState *record)
 
void heap2_desc (StringInfo buf, XLogReaderState *record)
 
const charheap_identify (uint8 info)
 
const charheap2_identify (uint8 info)
 

Function Documentation

◆ heap2_desc()

void heap2_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 265 of file heapdesc.c.

266{
267 char *rec = XLogRecGetData(record);
268 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
269
270 info &= XLOG_HEAP_OPMASK;
271 if (info == XLOG_HEAP2_PRUNE_ON_ACCESS ||
274 {
276
277 if (xlrec->flags & XLHP_HAS_CONFLICT_HORIZON)
278 {
280
282
283 appendStringInfo(buf, "snapshotConflictHorizon: %u",
285 }
286
287 appendStringInfo(buf, ", isCatalogRel: %c",
288 xlrec->flags & XLHP_IS_CATALOG_REL ? 'T' : 'F');
289
290 if (xlrec->flags & XLHP_VM_ALL_VISIBLE)
291 {
293
294 if (xlrec->flags & XLHP_VM_ALL_FROZEN)
296 appendStringInfo(buf, ", vm_flags: 0x%02X", vmflags);
297 }
298
299 if (XLogRecHasBlockData(record, 0))
300 {
301 Size datalen;
302 OffsetNumber *redirected;
303 OffsetNumber *nowdead;
304 OffsetNumber *nowunused;
305 int nredirected;
306 int nunused;
307 int ndead;
308 int nplans;
309 xlhp_freeze_plan *plans;
311
312 char *cursor = XLogRecGetBlockData(record, 0, &datalen);
313
315 &nplans, &plans, &frz_offsets,
316 &nredirected, &redirected,
317 &ndead, &nowdead,
318 &nunused, &nowunused);
319
320 appendStringInfo(buf, ", nplans: %u, nredirected: %u, ndead: %u, nunused: %u",
321 nplans, nredirected, ndead, nunused);
322
323 if (nplans > 0)
324 {
325 appendStringInfoString(buf, ", plans:");
326 array_desc(buf, plans, sizeof(xlhp_freeze_plan), nplans,
328 }
329
330 if (nredirected > 0)
331 {
332 appendStringInfoString(buf, ", redirected:");
333 array_desc(buf, redirected, sizeof(OffsetNumber) * 2,
334 nredirected, &redirect_elem_desc, NULL);
335 }
336
337 if (ndead > 0)
338 {
339 appendStringInfoString(buf, ", dead:");
340 array_desc(buf, nowdead, sizeof(OffsetNumber), ndead,
342 }
343
344 if (nunused > 0)
345 {
346 appendStringInfoString(buf, ", unused:");
347 array_desc(buf, nowunused, sizeof(OffsetNumber), nunused,
349 }
350 }
351 }
352 else if (info == XLOG_HEAP2_MULTI_INSERT)
353 {
355 bool isinit = (XLogRecGetInfo(record) & XLOG_HEAP_INIT_PAGE) != 0;
356
357 appendStringInfo(buf, "ntuples: %d, flags: 0x%02X", xlrec->ntuples,
358 xlrec->flags);
359
360 if (xlrec->flags & XLH_INSERT_ALL_FROZEN_SET)
361 appendStringInfo(buf, ", vm_flags: 0x%02X",
364
365 if (XLogRecHasBlockData(record, 0) && !isinit)
366 {
367 appendStringInfoString(buf, ", offsets:");
368 array_desc(buf, xlrec->offsets, sizeof(OffsetNumber),
369 xlrec->ntuples, &offset_elem_desc, NULL);
370 }
371 }
372 else if (info == XLOG_HEAP2_LOCK_UPDATED)
373 {
375
376 appendStringInfo(buf, "xmax: %u, off: %u, ",
377 xlrec->xmax, xlrec->offnum);
378 infobits_desc(buf, xlrec->infobits_set, "infobits");
379 appendStringInfo(buf, ", flags: 0x%02X", xlrec->flags);
380 }
381 else if (info == XLOG_HEAP2_NEW_CID)
382 {
384
385 appendStringInfo(buf, "rel: %u/%u/%u, tid: %u/%u",
386 xlrec->target_locator.spcOid,
387 xlrec->target_locator.dbOid,
388 xlrec->target_locator.relNumber,
389 ItemPointerGetBlockNumber(&(xlrec->target_tid)),
390 ItemPointerGetOffsetNumber(&(xlrec->target_tid)));
391 appendStringInfo(buf, ", cmin: %u, cmax: %u, combo: %u",
392 xlrec->cmin, xlrec->cmax, xlrec->combocid);
393 }
394}
uint8_t uint8
Definition c.h:616
uint32 TransactionId
Definition c.h:738
size_t Size
Definition c.h:691
#define XLOG_HEAP2_MULTI_INSERT
Definition heapam_xlog.h:64
#define XLHP_HAS_CONFLICT_HORIZON
#define XLHP_VM_ALL_VISIBLE
#define XLH_INSERT_ALL_FROZEN_SET
Definition heapam_xlog.h:79
#define XLOG_HEAP_OPMASK
Definition heapam_xlog.h:42
#define SizeOfHeapPrune
#define XLHP_VM_ALL_FROZEN
#define XLOG_HEAP2_PRUNE_VACUUM_SCAN
Definition heapam_xlog.h:61
#define XLOG_HEAP2_LOCK_UPDATED
Definition heapam_xlog.h:65
#define XLOG_HEAP2_PRUNE_ON_ACCESS
Definition heapam_xlog.h:60
#define XLOG_HEAP2_NEW_CID
Definition heapam_xlog.h:66
#define XLOG_HEAP2_PRUNE_VACUUM_CLEANUP
Definition heapam_xlog.h:62
#define XLHP_IS_CATALOG_REL
#define XLOG_HEAP_INIT_PAGE
Definition heapam_xlog.h:47
void heap_xlog_deserialize_prune_and_freeze(char *cursor, uint16 flags, int *nplans, xlhp_freeze_plan **plans, OffsetNumber **frz_offsets, int *nredirected, OffsetNumber **redirected, int *ndead, OffsetNumber **nowdead, int *nunused, OffsetNumber **nowunused)
Definition heapdesc.c:106
static void plan_elem_desc(StringInfo buf, void *plan, void *data)
Definition heapdesc.c:77
static void infobits_desc(StringInfo buf, uint8 infobits, const char *keyname)
Definition heapdesc.c:27
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
Definition itemptr.h:124
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
Definition itemptr.h:103
uint16 OffsetNumber
Definition off.h:24
static char buf[DEFAULT_XLOG_SEG_SIZE]
static int fb(int x)
void redirect_elem_desc(StringInfo buf, void *offset, void *data)
void array_desc(StringInfo buf, void *array, size_t elem_size, int count, void(*elem_desc)(StringInfo buf, void *elem, void *data), void *data)
void offset_elem_desc(StringInfo buf, void *offset, void *data)
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition stringinfo.c:145
void appendStringInfoString(StringInfo str, const char *s)
Definition stringinfo.c:230
Definition type.h:138
#define VISIBILITYMAP_ALL_FROZEN
#define VISIBILITYMAP_ALL_VISIBLE
char * XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len)
#define XLogRecHasBlockData(decoder, block_id)
Definition xlogreader.h:427
#define XLogRecGetInfo(decoder)
Definition xlogreader.h:410
#define XLogRecGetData(decoder)
Definition xlogreader.h:415

References appendStringInfo(), appendStringInfoString(), array_desc(), buf, fb(), heap_xlog_deserialize_prune_and_freeze(), infobits_desc(), ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), offset_elem_desc(), plan_elem_desc(), redirect_elem_desc(), SizeOfHeapPrune, VISIBILITYMAP_ALL_FROZEN, VISIBILITYMAP_ALL_VISIBLE, XLH_INSERT_ALL_FROZEN_SET, XLHP_HAS_CONFLICT_HORIZON, XLHP_IS_CATALOG_REL, XLHP_VM_ALL_FROZEN, XLHP_VM_ALL_VISIBLE, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_PRUNE_ON_ACCESS, XLOG_HEAP2_PRUNE_VACUUM_CLEANUP, XLOG_HEAP2_PRUNE_VACUUM_SCAN, XLOG_HEAP_INIT_PAGE, XLOG_HEAP_OPMASK, XLogRecGetBlockData(), XLogRecGetData, XLogRecGetInfo, and XLogRecHasBlockData.

◆ heap2_identify()

const char * heap2_identify ( uint8  info)

Definition at line 442 of file heapdesc.c.

443{
444 const char *id = NULL;
445
446 switch (info & ~XLR_INFO_MASK)
447 {
449 id = "PRUNE_ON_ACCESS";
450 break;
452 id = "PRUNE_VACUUM_SCAN";
453 break;
455 id = "PRUNE_VACUUM_CLEANUP";
456 break;
458 id = "MULTI_INSERT";
459 break;
461 id = "MULTI_INSERT+INIT";
462 break;
464 id = "LOCK_UPDATED";
465 break;
467 id = "NEW_CID";
468 break;
470 id = "REWRITE";
471 break;
472 }
473
474 return id;
475}
#define XLOG_HEAP2_REWRITE
Definition heapam_xlog.h:59
#define XLR_INFO_MASK
Definition xlogrecord.h:62

References fb(), XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_PRUNE_ON_ACCESS, XLOG_HEAP2_PRUNE_VACUUM_CLEANUP, XLOG_HEAP2_PRUNE_VACUUM_SCAN, XLOG_HEAP2_REWRITE, XLOG_HEAP_INIT_PAGE, and XLR_INFO_MASK.

◆ heap_desc()

void heap_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 185 of file heapdesc.c.

186{
187 char *rec = XLogRecGetData(record);
188 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
189
190 info &= XLOG_HEAP_OPMASK;
191 if (info == XLOG_HEAP_INSERT)
192 {
194
195 appendStringInfo(buf, "off: %u, flags: 0x%02X",
196 xlrec->offnum,
197 xlrec->flags);
198 }
199 else if (info == XLOG_HEAP_DELETE)
200 {
202
203 appendStringInfo(buf, "xmax: %u, off: %u, ",
204 xlrec->xmax, xlrec->offnum);
205 infobits_desc(buf, xlrec->infobits_set, "infobits");
206 appendStringInfo(buf, ", flags: 0x%02X", xlrec->flags);
207 }
208 else if (info == XLOG_HEAP_UPDATE)
209 {
211
212 appendStringInfo(buf, "old_xmax: %u, old_off: %u, ",
213 xlrec->old_xmax, xlrec->old_offnum);
214 infobits_desc(buf, xlrec->old_infobits_set, "old_infobits");
215 appendStringInfo(buf, ", flags: 0x%02X, new_xmax: %u, new_off: %u",
216 xlrec->flags, xlrec->new_xmax, xlrec->new_offnum);
217 }
218 else if (info == XLOG_HEAP_HOT_UPDATE)
219 {
221
222 appendStringInfo(buf, "old_xmax: %u, old_off: %u, ",
223 xlrec->old_xmax, xlrec->old_offnum);
224 infobits_desc(buf, xlrec->old_infobits_set, "old_infobits");
225 appendStringInfo(buf, ", flags: 0x%02X, new_xmax: %u, new_off: %u",
226 xlrec->flags, xlrec->new_xmax, xlrec->new_offnum);
227 }
228 else if (info == XLOG_HEAP_TRUNCATE)
229 {
231
233 appendStringInfo(buf, ", nrelids: %u", xlrec->nrelids);
234 appendStringInfoString(buf, ", relids:");
235 array_desc(buf, xlrec->relids, sizeof(Oid), xlrec->nrelids,
237 }
238 else if (info == XLOG_HEAP_CONFIRM)
239 {
241
242 appendStringInfo(buf, "off: %u", xlrec->offnum);
243 }
244 else if (info == XLOG_HEAP_LOCK)
245 {
247
248 appendStringInfo(buf, "xmax: %u, off: %u, ",
249 xlrec->xmax, xlrec->offnum);
250 infobits_desc(buf, xlrec->infobits_set, "infobits");
251 appendStringInfo(buf, ", flags: 0x%02X", xlrec->flags);
252 }
253 else if (info == XLOG_HEAP_INPLACE)
254 {
256
257 appendStringInfo(buf, "off: %u", xlrec->offnum);
259 xlrec->dbId, xlrec->tsId,
260 xlrec->relcacheInitFileInval);
261 }
262}
#define XLOG_HEAP_HOT_UPDATE
Definition heapam_xlog.h:37
#define XLOG_HEAP_DELETE
Definition heapam_xlog.h:34
#define XLOG_HEAP_TRUNCATE
Definition heapam_xlog.h:36
#define XLOG_HEAP_UPDATE
Definition heapam_xlog.h:35
#define XLOG_HEAP_INPLACE
Definition heapam_xlog.h:40
#define XLOG_HEAP_LOCK
Definition heapam_xlog.h:39
#define XLOG_HEAP_INSERT
Definition heapam_xlog.h:33
#define XLOG_HEAP_CONFIRM
Definition heapam_xlog.h:38
static void truncate_flags_desc(StringInfo buf, uint8 flags)
Definition heapdesc.c:56
unsigned int Oid
void oid_elem_desc(StringInfo buf, void *relid, void *data)
void standby_desc_invalidations(StringInfo buf, int nmsgs, SharedInvalidationMessage *msgs, Oid dbId, Oid tsId, bool relcacheInitFileInval)

References appendStringInfo(), appendStringInfoString(), array_desc(), buf, fb(), infobits_desc(), oid_elem_desc(), standby_desc_invalidations(), truncate_flags_desc(), XLOG_HEAP_CONFIRM, XLOG_HEAP_DELETE, XLOG_HEAP_HOT_UPDATE, XLOG_HEAP_INPLACE, XLOG_HEAP_INSERT, XLOG_HEAP_LOCK, XLOG_HEAP_OPMASK, XLOG_HEAP_TRUNCATE, XLOG_HEAP_UPDATE, XLogRecGetData, and XLogRecGetInfo.

◆ heap_identify()

const char * heap_identify ( uint8  info)

Definition at line 397 of file heapdesc.c.

398{
399 const char *id = NULL;
400
401 switch (info & ~XLR_INFO_MASK)
402 {
403 case XLOG_HEAP_INSERT:
404 id = "INSERT";
405 break;
407 id = "INSERT+INIT";
408 break;
409 case XLOG_HEAP_DELETE:
410 id = "DELETE";
411 break;
412 case XLOG_HEAP_UPDATE:
413 id = "UPDATE";
414 break;
416 id = "UPDATE+INIT";
417 break;
419 id = "HOT_UPDATE";
420 break;
422 id = "HOT_UPDATE+INIT";
423 break;
425 id = "TRUNCATE";
426 break;
428 id = "HEAP_CONFIRM";
429 break;
430 case XLOG_HEAP_LOCK:
431 id = "LOCK";
432 break;
434 id = "INPLACE";
435 break;
436 }
437
438 return id;
439}

References fb(), XLOG_HEAP_CONFIRM, XLOG_HEAP_DELETE, XLOG_HEAP_HOT_UPDATE, XLOG_HEAP_INIT_PAGE, XLOG_HEAP_INPLACE, XLOG_HEAP_INSERT, XLOG_HEAP_LOCK, XLOG_HEAP_TRUNCATE, XLOG_HEAP_UPDATE, and XLR_INFO_MASK.

◆ heap_xlog_deserialize_prune_and_freeze()

void heap_xlog_deserialize_prune_and_freeze ( char cursor,
uint16  flags,
int nplans,
xlhp_freeze_plan **  plans,
OffsetNumber **  frz_offsets,
int nredirected,
OffsetNumber **  redirected,
int ndead,
OffsetNumber **  nowdead,
int nunused,
OffsetNumber **  nowunused 
)

Definition at line 106 of file heapdesc.c.

112{
113 if (flags & XLHP_HAS_FREEZE_PLANS)
114 {
116
117 *nplans = freeze_plans->nplans;
118 Assert(*nplans > 0);
119 *plans = freeze_plans->plans;
120
122 cursor += sizeof(xlhp_freeze_plan) * *nplans;
123 }
124 else
125 {
126 *nplans = 0;
127 *plans = NULL;
128 }
129
130 if (flags & XLHP_HAS_REDIRECTIONS)
131 {
133
134 *nredirected = subrecord->ntargets;
135 Assert(*nredirected > 0);
136 *redirected = &subrecord->data[0];
137
139 cursor += sizeof(OffsetNumber[2]) * *nredirected;
140 }
141 else
142 {
143 *nredirected = 0;
144 *redirected = NULL;
145 }
146
147 if (flags & XLHP_HAS_DEAD_ITEMS)
148 {
150
151 *ndead = subrecord->ntargets;
152 Assert(*ndead > 0);
153 *nowdead = subrecord->data;
154
156 cursor += sizeof(OffsetNumber) * *ndead;
157 }
158 else
159 {
160 *ndead = 0;
161 *nowdead = NULL;
162 }
163
164 if (flags & XLHP_HAS_NOW_UNUSED_ITEMS)
165 {
167
168 *nunused = subrecord->ntargets;
169 Assert(*nunused > 0);
170 *nowunused = subrecord->data;
171
173 cursor += sizeof(OffsetNumber) * *nunused;
174 }
175 else
176 {
177 *nunused = 0;
178 *nowunused = NULL;
179 }
180
182}
#define Assert(condition)
Definition c.h:945
#define XLHP_HAS_FREEZE_PLANS
#define XLHP_HAS_NOW_UNUSED_ITEMS
#define XLHP_HAS_REDIRECTIONS
#define XLHP_HAS_DEAD_ITEMS
const void * data

References Assert, data, fb(), XLHP_HAS_DEAD_ITEMS, XLHP_HAS_FREEZE_PLANS, XLHP_HAS_NOW_UNUSED_ITEMS, and XLHP_HAS_REDIRECTIONS.

Referenced by heap2_desc(), and heap_xlog_prune_freeze().

◆ infobits_desc()

static void infobits_desc ( StringInfo  buf,
uint8  infobits,
const char keyname 
)
static

Definition at line 27 of file heapdesc.c.

28{
29 appendStringInfo(buf, "%s: [", keyname);
30
31 Assert(buf->data[buf->len - 1] != ' ');
32
34 appendStringInfoString(buf, "IS_MULTI, ");
36 appendStringInfoString(buf, "LOCK_ONLY, ");
38 appendStringInfoString(buf, "EXCL_LOCK, ");
40 appendStringInfoString(buf, "KEYSHR_LOCK, ");
42 appendStringInfoString(buf, "KEYS_UPDATED, ");
43
44 if (buf->data[buf->len - 1] == ' ')
45 {
46 /* Truncate-away final unneeded ", " */
47 Assert(buf->data[buf->len - 2] == ',');
48 buf->len -= 2;
49 buf->data[buf->len] = '\0';
50 }
51
53}
#define XLHL_XMAX_KEYSHR_LOCK
#define XLHL_XMAX_IS_MULTI
#define XLHL_XMAX_LOCK_ONLY
#define XLHL_XMAX_EXCL_LOCK
#define XLHL_KEYS_UPDATED
void appendStringInfoChar(StringInfo str, char ch)
Definition stringinfo.c:242

References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), Assert, buf, fb(), XLHL_KEYS_UPDATED, XLHL_XMAX_EXCL_LOCK, XLHL_XMAX_IS_MULTI, XLHL_XMAX_KEYSHR_LOCK, and XLHL_XMAX_LOCK_ONLY.

Referenced by heap2_desc(), and heap_desc().

◆ plan_elem_desc()

static void plan_elem_desc ( StringInfo  buf,
void plan,
void data 
)
static

Definition at line 77 of file heapdesc.c.

78{
80 OffsetNumber **offsets = data;
81
82 appendStringInfo(buf, "{ xmax: %u, infomask: %u, infomask2: %u, ntuples: %u",
83 new_plan->xmax,
84 new_plan->t_infomask, new_plan->t_infomask2,
85 new_plan->ntuples);
86
87 appendStringInfoString(buf, ", offsets:");
88 array_desc(buf, *offsets, sizeof(OffsetNumber), new_plan->ntuples,
90
91 *offsets += new_plan->ntuples;
92
94}
#define plan(x)
Definition pg_regress.c:161

References appendStringInfo(), appendStringInfoString(), array_desc(), buf, data, fb(), offset_elem_desc(), and plan.

Referenced by heap2_desc().

◆ truncate_flags_desc()

static void truncate_flags_desc ( StringInfo  buf,
uint8  flags 
)
static

Definition at line 56 of file heapdesc.c.

57{
58 appendStringInfoString(buf, "flags: [");
59
60 if (flags & XLH_TRUNCATE_CASCADE)
61 appendStringInfoString(buf, "CASCADE, ");
62 if (flags & XLH_TRUNCATE_RESTART_SEQS)
63 appendStringInfoString(buf, "RESTART_SEQS, ");
64
65 if (buf->data[buf->len - 1] == ' ')
66 {
67 /* Truncate-away final unneeded ", " */
68 Assert(buf->data[buf->len - 2] == ',');
69 buf->len -= 2;
70 buf->data[buf->len] = '\0';
71 }
72
74}
#define XLH_TRUNCATE_RESTART_SEQS
#define XLH_TRUNCATE_CASCADE

References appendStringInfoChar(), appendStringInfoString(), Assert, buf, XLH_TRUNCATE_CASCADE, and XLH_TRUNCATE_RESTART_SEQS.

Referenced by heap_desc().