Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit96149a1

Browse files
Fix Heap rmgr's desc output for infobits arrays.
Make heap desc routines that output status bit as arrays of constantsavoid outputting array literals that contain superfluous punctuationcharacters that complicate parsing the output. Also make sure that noheap desc routine repeats the same key name (at the same nesting level),for the same reason. Arguably, these were both oversights in commit7d8219a.In passing, make the desc output code (which covers Heap's DELETE,UPDATE, HOT_UPDATE, LOCK, and LOCK_UPDATED record types) consistent interms of the output order of each field. This order also matches WALrecord struct order. Heap's DELETE desc output now shows the record'sxmax field for the first time (just like UPDATE/HOT_UPDATE records).Author: Peter Geoghegan <pg@bowt.ie>Reviewed-By: Melanie Plageman <melanieplageman@gmail.com>Discussion:https://postgr.es/m/CAH2-Wz=pNYtxiJ2Jx5Lj=fKo1OEZ4GE0p_kct+ugAUTqBwU46g@mail.gmail.com
1 parente944063 commit96149a1

File tree

1 file changed

+71
-49
lines changed

1 file changed

+71
-49
lines changed

‎src/backend/access/rmgrdesc/heapdesc.c

Lines changed: 71 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,58 @@
1717
#include"access/heapam_xlog.h"
1818
#include"access/rmgrdesc_utils.h"
1919

20+
/*
21+
* NOTE: "keyname" argument cannot have trailing spaces or punctuation
22+
* characters
23+
*/
2024
staticvoid
21-
out_infobits(StringInfobuf,uint8infobits)
25+
infobits_desc(StringInfobuf,uint8infobits,constchar*keyname)
2226
{
23-
if ((infobits&XLHL_XMAX_IS_MULTI)==0&&
24-
(infobits&XLHL_XMAX_LOCK_ONLY)==0&&
25-
(infobits&XLHL_XMAX_EXCL_LOCK)==0&&
26-
(infobits&XLHL_XMAX_KEYSHR_LOCK)==0&&
27-
(infobits&XLHL_KEYS_UPDATED)==0)
28-
return;
27+
appendStringInfo(buf,"%s: [",keyname);
2928

30-
appendStringInfoString(buf,", infobits: [");
29+
Assert(buf->data[buf->len-1]!=' ');
3130

3231
if (infobits&XLHL_XMAX_IS_MULTI)
33-
appendStringInfoString(buf,"IS_MULTI");
32+
appendStringInfoString(buf,"IS_MULTI,");
3433
if (infobits&XLHL_XMAX_LOCK_ONLY)
35-
appendStringInfoString(buf,", LOCK_ONLY");
34+
appendStringInfoString(buf,"LOCK_ONLY,");
3635
if (infobits&XLHL_XMAX_EXCL_LOCK)
37-
appendStringInfoString(buf,", EXCL_LOCK");
36+
appendStringInfoString(buf,"EXCL_LOCK,");
3837
if (infobits&XLHL_XMAX_KEYSHR_LOCK)
39-
appendStringInfoString(buf,", KEYSHR_LOCK");
38+
appendStringInfoString(buf,"KEYSHR_LOCK,");
4039
if (infobits&XLHL_KEYS_UPDATED)
41-
appendStringInfoString(buf,", KEYS_UPDATED");
40+
appendStringInfoString(buf,"KEYS_UPDATED, ");
41+
42+
if (buf->data[buf->len-1]==' ')
43+
{
44+
/* Truncate-away final unneeded ", " */
45+
Assert(buf->data[buf->len-2]==',');
46+
buf->len-=2;
47+
buf->data[buf->len]='\0';
48+
}
4249

43-
appendStringInfoString(buf," ]");
50+
appendStringInfoString(buf,"]");
51+
}
52+
53+
staticvoid
54+
truncate_flags_desc(StringInfobuf,uint8flags)
55+
{
56+
appendStringInfoString(buf,"flags: [");
57+
58+
if (flags&XLH_TRUNCATE_CASCADE)
59+
appendStringInfoString(buf,"CASCADE, ");
60+
if (flags&XLH_TRUNCATE_RESTART_SEQS)
61+
appendStringInfoString(buf,"RESTART_SEQS, ");
62+
63+
if (buf->data[buf->len-1]==' ')
64+
{
65+
/* Truncate-away final unneeded ", " */
66+
Assert(buf->data[buf->len-2]==',');
67+
buf->len-=2;
68+
buf->data[buf->len]='\0';
69+
}
70+
71+
appendStringInfoString(buf,"]");
4472
}
4573

4674
staticvoid
@@ -82,48 +110,36 @@ heap_desc(StringInfo buf, XLogReaderState *record)
82110
{
83111
xl_heap_delete*xlrec= (xl_heap_delete*)rec;
84112

85-
appendStringInfo(buf,"off: %u,flags: 0x%02X",
86-
xlrec->offnum,
87-
xlrec->flags);
88-
out_infobits(buf,xlrec->infobits_set);
113+
appendStringInfo(buf,"xmax: %u,off: %u,",
114+
xlrec->xmax,xlrec->offnum);
115+
infobits_desc(buf,xlrec->infobits_set,"infobits");
116+
appendStringInfo(buf,", flags: 0x%02X",xlrec->flags);
89117
}
90118
elseif (info==XLOG_HEAP_UPDATE)
91119
{
92120
xl_heap_update*xlrec= (xl_heap_update*)rec;
93121

94-
appendStringInfo(buf,"off: %u, xmax: %u, flags: 0x%02X",
95-
xlrec->old_offnum,
96-
xlrec->old_xmax,
97-
xlrec->flags);
98-
out_infobits(buf,xlrec->old_infobits_set);
99-
appendStringInfo(buf,", new off: %u, xmax %u",
100-
xlrec->new_offnum,
101-
xlrec->new_xmax);
122+
appendStringInfo(buf,"old_xmax: %u, old_off: %u, ",
123+
xlrec->old_xmax,xlrec->old_offnum);
124+
infobits_desc(buf,xlrec->old_infobits_set,"old_infobits");
125+
appendStringInfo(buf,", flags: 0x%02X, new_xmax: %u, new_off: %u",
126+
xlrec->flags,xlrec->new_xmax,xlrec->new_offnum);
102127
}
103128
elseif (info==XLOG_HEAP_HOT_UPDATE)
104129
{
105130
xl_heap_update*xlrec= (xl_heap_update*)rec;
106131

107-
appendStringInfo(buf,"off: %u, xmax: %u, flags: 0x%02X",
108-
xlrec->old_offnum,
109-
xlrec->old_xmax,
110-
xlrec->flags);
111-
out_infobits(buf,xlrec->old_infobits_set);
112-
appendStringInfo(buf,", new off: %u, xmax: %u",
113-
xlrec->new_offnum,
114-
xlrec->new_xmax);
132+
appendStringInfo(buf,"old_xmax: %u, old_off: %u, ",
133+
xlrec->old_xmax,xlrec->old_offnum);
134+
infobits_desc(buf,xlrec->old_infobits_set,"old_infobits");
135+
appendStringInfo(buf,", flags: 0x%02X, new_xmax: %u, new_off: %u",
136+
xlrec->flags,xlrec->new_xmax,xlrec->new_offnum);
115137
}
116138
elseif (info==XLOG_HEAP_TRUNCATE)
117139
{
118140
xl_heap_truncate*xlrec= (xl_heap_truncate*)rec;
119141

120-
appendStringInfoString(buf,"flags: [");
121-
if (xlrec->flags&XLH_TRUNCATE_CASCADE)
122-
appendStringInfoString(buf," CASCADE");
123-
if (xlrec->flags&XLH_TRUNCATE_RESTART_SEQS)
124-
appendStringInfoString(buf,", RESTART_SEQS");
125-
appendStringInfoString(buf," ]");
126-
142+
truncate_flags_desc(buf,xlrec->flags);
127143
appendStringInfo(buf,", nrelids: %u",xlrec->nrelids);
128144
appendStringInfoString(buf,", relids:");
129145
array_desc(buf,xlrec->relids,sizeof(Oid),xlrec->nrelids,
@@ -139,9 +155,10 @@ heap_desc(StringInfo buf, XLogReaderState *record)
139155
{
140156
xl_heap_lock*xlrec= (xl_heap_lock*)rec;
141157

142-
appendStringInfo(buf,"off: %u, xmax: %u, flags: 0x%02X",
143-
xlrec->offnum,xlrec->xmax,xlrec->flags);
144-
out_infobits(buf,xlrec->infobits_set);
158+
appendStringInfo(buf,"xmax: %u, off: %u, ",
159+
xlrec->xmax,xlrec->offnum);
160+
infobits_desc(buf,xlrec->infobits_set,"infobits");
161+
appendStringInfo(buf,", flags: 0x%02X",xlrec->flags);
145162
}
146163
elseif (info==XLOG_HEAP_INPLACE)
147164
{
@@ -230,7 +247,9 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
230247
OffsetNumber*offsets;
231248

232249
plans= (xl_heap_freeze_plan*)XLogRecGetBlockData(record,0,NULL);
233-
offsets= (OffsetNumber*)&plans[xlrec->nplans];
250+
offsets= (OffsetNumber*) ((char*)plans+
251+
(xlrec->nplans*
252+
sizeof(xl_heap_freeze_plan)));
234253
appendStringInfoString(buf,", plans:");
235254
array_desc(buf,plans,sizeof(xl_heap_freeze_plan),xlrec->nplans,
236255
&plan_elem_desc,&offsets);
@@ -251,18 +270,21 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
251270
appendStringInfo(buf,"ntuples: %d, flags: 0x%02X",xlrec->ntuples,
252271
xlrec->flags);
253272

254-
appendStringInfoString(buf,", offsets:");
255273
if (!XLogRecHasBlockImage(record,0)&& !isinit)
274+
{
275+
appendStringInfoString(buf,", offsets:");
256276
array_desc(buf,xlrec->offsets,sizeof(OffsetNumber),
257277
xlrec->ntuples,&offset_elem_desc,NULL);
278+
}
258279
}
259280
elseif (info==XLOG_HEAP2_LOCK_UPDATED)
260281
{
261282
xl_heap_lock_updated*xlrec= (xl_heap_lock_updated*)rec;
262283

263-
appendStringInfo(buf,"off: %u, xmax: %u, flags: 0x%02X",
264-
xlrec->offnum,xlrec->xmax,xlrec->flags);
265-
out_infobits(buf,xlrec->infobits_set);
284+
appendStringInfo(buf,"xmax: %u, off: %u, ",
285+
xlrec->xmax,xlrec->offnum);
286+
infobits_desc(buf,xlrec->infobits_set,"infobits");
287+
appendStringInfo(buf,", flags: 0x%02X",xlrec->flags);
266288
}
267289
elseif (info==XLOG_HEAP2_NEW_CID)
268290
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp