On Mon, Apr 23, 2018 at 01:02:16PM -0300, Alvaro Herrera wrote:
> Andres Freund wrote:
> > On 2018-04-23 12:37:20 -0300, Alvaro Herrera wrote:
> > > Me too. Should we consider this for pg11? My vote is yes, with no
> > > backpatch (might break scripts reading pg_{wal,xlog}dump output.
> > > Though, really!?).Breaking the output format is exactly one reason to not patch v10 and older versions. > > It's low risk enough, but why should we try to get it into v11? Flags > > been around for years now. > > I was thinking the newly added flags would make for possibly more > confusing scenarios, but now that I look again, the new ones are XLHL > flags not the XLOG flags being handled in this patch. > > Now, frankly, this being mostly a debugging tool, I think it would be > better to have the output as complete as we can. Otherwise, when > debugging some hideous problem we find ourselves patching the tool > during an emergency in order to figure out what is going on. For this, > I would rather patch the earliest version we conveniently can. We > cannot patch pg10 because it's already out there, but not so for pg11. OK, that works for me. Attached is a patch using hex values for the flags of all those records (the comment could be fixed further down but let's not bother about it). There are a couple of things I noticed on the way: 1) xl_heap_lock prints flags, but not in hexa but using %u. 2) xl_heap_visible prints flags, not in hexa but using %d. 3) xl_heap_lock_updated prints flags, not in hexa but using %u. 4) xl_hash_split_allocate_page has flags, those are handled as directly text (see hashdesc.c). 5) Most GIN records also have flags, which are handled. 6) xl_smgr_truncate as records, which are not showed up yet. So I have hacked the patch so as all flags show up in hexa format, except those which are already handled and print text. -- Michael
diff --git a/src/backend/access/rmgrdesc/heapdesc.c b/src/backend/access/rmgrdesc/heapdesc.c
index 318a281d7f..f63b8f844d 100644
--- a/src/backend/access/rmgrdesc/heapdesc.c
+++ b/src/backend/access/rmgrdesc/heapdesc.c
@@ -42,22 +42,26 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_insert *xlrec = (xl_heap_insert *) rec;
- appendStringInfo(buf, "off %u", xlrec->offnum);
+ appendStringInfo(buf, "off %u flags %02X", xlrec->offnum,
+ xlrec->flags);
}
else if (info == XLOG_HEAP_DELETE)
{
xl_heap_delete *xlrec = (xl_heap_delete *) rec;
- appendStringInfo(buf, "off %u ", xlrec->offnum);
+ appendStringInfo(buf, "off %u flags %02X ",
+ xlrec->offnum,
+ xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
else if (info == XLOG_HEAP_UPDATE)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u ",
+ appendStringInfo(buf, "off %u xmax %u flags %02X ",
xlrec->old_offnum,
- xlrec->old_xmax);
+ xlrec->old_xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->old_infobits_set);
appendStringInfo(buf, "; new off %u xmax %u",
xlrec->new_offnum,
@@ -67,9 +71,10 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_update *xlrec = (xl_heap_update *) rec;
- appendStringInfo(buf, "off %u xmax %u ",
+ appendStringInfo(buf, "off %u xmax %u flags %02X ",
xlrec->old_offnum,
- xlrec->old_xmax);
+ xlrec->old_xmax,
+ xlrec->flags);
out_infobits(buf, xlrec->old_infobits_set);
appendStringInfo(buf, "; new off %u xmax %u",
xlrec->new_offnum,
@@ -98,7 +103,7 @@ heap_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_lock *xlrec = (xl_heap_lock *) rec;
- appendStringInfo(buf, "off %u: xid %u: flags %u ",
+ appendStringInfo(buf, "off %u: xid %u: flags %02X ",
xlrec->offnum, xlrec->locking_xid, xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
@@ -139,20 +144,21 @@ heap2_desc(StringInfo buf, XLogReaderState *record)
{
xl_heap_visible *xlrec = (xl_heap_visible *) rec;
- appendStringInfo(buf, "cutoff xid %u flags %d",
+ appendStringInfo(buf, "cutoff xid %u flags %02X",
xlrec->cutoff_xid, xlrec->flags);
}
else if (info == XLOG_HEAP2_MULTI_INSERT)
{
xl_heap_multi_insert *xlrec = (xl_heap_multi_insert *) rec;
- appendStringInfo(buf, "%d tuples", xlrec->ntuples);
+ appendStringInfo(buf, "%d tuples flags %02X", xlrec->ntuples,
+ xlrec->flags);
}
else if (info == XLOG_HEAP2_LOCK_UPDATED)
{
xl_heap_lock_updated *xlrec = (xl_heap_lock_updated *) rec;
- appendStringInfo(buf, "off %u: xmax %u: flags %u ",
+ appendStringInfo(buf, "off %u: xmax %u: flags %02X ",
xlrec->offnum, xlrec->xmax, xlrec->flags);
out_infobits(buf, xlrec->infobits_set);
}
diff --git a/src/backend/access/rmgrdesc/smgrdesc.c b/src/backend/access/rmgrdesc/smgrdesc.c
index df1ad38b5a..604604ac04 100644
--- a/src/backend/access/rmgrdesc/smgrdesc.c
+++ b/src/backend/access/rmgrdesc/smgrdesc.c
@@ -36,7 +36,7 @@ smgr_desc(StringInfo buf, XLogReaderState *record)
xl_smgr_truncate *xlrec = (xl_smgr_truncate *) rec;
char *path = relpathperm(xlrec->rnode, MAIN_FORKNUM);
- appendStringInfo(buf, "%s to %u blocks flags %d", path,
+ appendStringInfo(buf, "%s to %u blocks flags %02X", path,
xlrec->blkno, xlrec->flags);
pfree(path);
}
diff --git a/src/include/access/heapam_xlog.h b/src/include/access/heapam_xlog.h
index cf88ff7cb4..cc85f4b3c7 100644
--- a/src/include/access/heapam_xlog.h
+++ b/src/include/access/heapam_xlog.h
@@ -111,7 +111,7 @@ typedef struct xl_heap_delete
#define SizeOfHeapDelete (offsetof(xl_heap_delete, flags) + sizeof(uint8))
/*
- * xl_heap_delete flag values, 8 bits are available.
+ * xl_heap_truncate flag values, 8 bits are available.
*/
#define XLH_TRUNCATE_CASCADE (1<<0)
#define XLH_TRUNCATE_RESTART_SEQS (1<<1)
signature.asc
Description: PGP signature
