17
17
#include "access/heapam_xlog.h"
18
18
#include "access/rmgrdesc_utils.h"
19
19
20
+ /*
21
+ * NOTE: "keyname" argument cannot have trailing spaces or punctuation
22
+ * characters
23
+ */
20
24
static void
21
- out_infobits (StringInfo buf , uint8 infobits )
25
+ infobits_desc (StringInfo buf , uint8 infobits , const char * keyname )
22
26
{
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 );
29
28
30
- appendStringInfoString (buf , ", infobits: [" );
29
+ Assert (buf -> data [ buf -> len - 1 ] != ' ' );
31
30
32
31
if (infobits & XLHL_XMAX_IS_MULTI )
33
- appendStringInfoString (buf , " IS_MULTI" );
32
+ appendStringInfoString (buf , "IS_MULTI, " );
34
33
if (infobits & XLHL_XMAX_LOCK_ONLY )
35
- appendStringInfoString (buf , ", LOCK_ONLY " );
34
+ appendStringInfoString (buf , "LOCK_ONLY, " );
36
35
if (infobits & XLHL_XMAX_EXCL_LOCK )
37
- appendStringInfoString (buf , ", EXCL_LOCK " );
36
+ appendStringInfoString (buf , "EXCL_LOCK, " );
38
37
if (infobits & XLHL_XMAX_KEYSHR_LOCK )
39
- appendStringInfoString (buf , ", KEYSHR_LOCK " );
38
+ appendStringInfoString (buf , "KEYSHR_LOCK, " );
40
39
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
+ }
42
49
43
- appendStringInfoString (buf , " ]" );
50
+ appendStringInfoString (buf , "]" );
51
+ }
52
+
53
+ static void
54
+ truncate_flags_desc (StringInfo buf , uint8 flags )
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 , "]" );
44
72
}
45
73
46
74
static void
@@ -82,48 +110,36 @@ heap_desc(StringInfo buf, XLogReaderState *record)
82
110
{
83
111
xl_heap_delete * xlrec = (xl_heap_delete * ) rec ;
84
112
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 );
89
117
}
90
118
else if (info == XLOG_HEAP_UPDATE )
91
119
{
92
120
xl_heap_update * xlrec = (xl_heap_update * ) rec ;
93
121
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 );
102
127
}
103
128
else if (info == XLOG_HEAP_HOT_UPDATE )
104
129
{
105
130
xl_heap_update * xlrec = (xl_heap_update * ) rec ;
106
131
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 );
115
137
}
116
138
else if (info == XLOG_HEAP_TRUNCATE )
117
139
{
118
140
xl_heap_truncate * xlrec = (xl_heap_truncate * ) rec ;
119
141
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 );
127
143
appendStringInfo (buf , ", nrelids: %u" , xlrec -> nrelids );
128
144
appendStringInfoString (buf , ", relids:" );
129
145
array_desc (buf , xlrec -> relids , sizeof (Oid ), xlrec -> nrelids ,
@@ -139,9 +155,10 @@ heap_desc(StringInfo buf, XLogReaderState *record)
139
155
{
140
156
xl_heap_lock * xlrec = (xl_heap_lock * ) rec ;
141
157
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 );
145
162
}
146
163
else if (info == XLOG_HEAP_INPLACE )
147
164
{
@@ -230,7 +247,9 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
230
247
OffsetNumber * offsets ;
231
248
232
249
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 )));
234
253
appendStringInfoString (buf , ", plans:" );
235
254
array_desc (buf , plans , sizeof (xl_heap_freeze_plan ), xlrec -> nplans ,
236
255
& plan_elem_desc , & offsets );
@@ -251,18 +270,21 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
251
270
appendStringInfo (buf , "ntuples: %d, flags: 0x%02X" , xlrec -> ntuples ,
252
271
xlrec -> flags );
253
272
254
- appendStringInfoString (buf , ", offsets:" );
255
273
if (!XLogRecHasBlockImage (record , 0 ) && !isinit )
274
+ {
275
+ appendStringInfoString (buf , ", offsets:" );
256
276
array_desc (buf , xlrec -> offsets , sizeof (OffsetNumber ),
257
277
xlrec -> ntuples , & offset_elem_desc , NULL );
278
+ }
258
279
}
259
280
else if (info == XLOG_HEAP2_LOCK_UPDATED )
260
281
{
261
282
xl_heap_lock_updated * xlrec = (xl_heap_lock_updated * ) rec ;
262
283
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 );
266
288
}
267
289
else if (info == XLOG_HEAP2_NEW_CID )
268
290
{
0 commit comments