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+ */
2024static void
21- out_infobits (StringInfo buf ,uint8 infobits )
25+ infobits_desc (StringInfo buf ,uint8 infobits , const char * 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
3231if (infobits & XLHL_XMAX_IS_MULTI )
33- appendStringInfoString (buf ," IS_MULTI" );
32+ appendStringInfoString (buf ,"IS_MULTI, " );
3433if (infobits & XLHL_XMAX_LOCK_ONLY )
35- appendStringInfoString (buf ,", LOCK_ONLY " );
34+ appendStringInfoString (buf ,"LOCK_ONLY, " );
3635if (infobits & XLHL_XMAX_EXCL_LOCK )
37- appendStringInfoString (buf ,", EXCL_LOCK " );
36+ appendStringInfoString (buf ,"EXCL_LOCK, " );
3837if (infobits & XLHL_XMAX_KEYSHR_LOCK )
39- appendStringInfoString (buf ,", KEYSHR_LOCK " );
38+ appendStringInfoString (buf ,"KEYSHR_LOCK, " );
4039if (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+ 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 ,"]" );
4472}
4573
4674static void
@@ -82,48 +110,36 @@ heap_desc(StringInfo buf, XLogReaderState *record)
82110{
83111xl_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}
90118else if (info == XLOG_HEAP_UPDATE )
91119{
92120xl_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}
103128else if (info == XLOG_HEAP_HOT_UPDATE )
104129{
105130xl_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}
116138else if (info == XLOG_HEAP_TRUNCATE )
117139{
118140xl_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 );
127143appendStringInfo (buf ,", nrelids: %u" ,xlrec -> nrelids );
128144appendStringInfoString (buf ,", relids:" );
129145array_desc (buf ,xlrec -> relids ,sizeof (Oid ),xlrec -> nrelids ,
@@ -139,9 +155,10 @@ heap_desc(StringInfo buf, XLogReaderState *record)
139155{
140156xl_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}
146163else if (info == XLOG_HEAP_INPLACE )
147164{
@@ -230,7 +247,9 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
230247OffsetNumber * offsets ;
231248
232249plans = (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 )));
234253appendStringInfoString (buf ,", plans:" );
235254array_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)
251270appendStringInfo (buf ,"ntuples: %d, flags: 0x%02X" ,xlrec -> ntuples ,
252271xlrec -> flags );
253272
254- appendStringInfoString (buf ,", offsets:" );
255273if (!XLogRecHasBlockImage (record ,0 )&& !isinit )
274+ {
275+ appendStringInfoString (buf ,", offsets:" );
256276array_desc (buf ,xlrec -> offsets ,sizeof (OffsetNumber ),
257277xlrec -> ntuples ,& offset_elem_desc ,NULL );
278+ }
258279}
259280else if (info == XLOG_HEAP2_LOCK_UPDATED )
260281{
261282xl_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}
267289else if (info == XLOG_HEAP2_NEW_CID )
268290{