Skip to content

Commit 5dc851a

Browse files
committed
Fix incorrect output from gin_desc().
Previously gin_desc() displayed incorrect output "unknown action 0" for XLOG_GIN_INSERT and XLOG_GIN_VACUUM_DATA_LEAF_PAGE records with valid actions. The cause of this problem was that gin_desc() wrongly used XLogRecGetData() to extract data from those records. Since they were registered by XLogRegisterBufData(), gin_desc() should have used XLogRecGetBlockData(), instead, like gin_redo(). Also there were other differences about how to treat XLOG_GIN_INSERT record between gin_desc() and gin_redo(). This commit fixes gin_desc() routine so that it treats those records in the same way as gin_redo(). Batch-patch to 9.5 where WAL record format was revamped and XLogRegisterBufData() was added. Reported-By: Andres Freund Reviewed-By: Tom Lane Discussion: <20160509194645.7lewnpw647zegx2m@alap3.anarazel.de>
1 parent 3850723 commit 5dc851a

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

src/backend/access/rmgrdesc/gindesc.c

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ gin_desc(StringInfo buf, XLogReaderState *record)
8787
case XLOG_GIN_INSERT:
8888
{
8989
ginxlogInsert *xlrec = (ginxlogInsert *) rec;
90-
char *payload = rec + sizeof(ginxlogInsert);
9190

9291
appendStringInfo(buf, "isdata: %c isleaf: %c",
9392
(xlrec->flags & GIN_INSERT_ISDATA) ? 'T' : 'F',
9493
(xlrec->flags & GIN_INSERT_ISLEAF) ? 'T' : 'F');
9594
if (!(xlrec->flags & GIN_INSERT_ISLEAF))
9695
{
96+
char *payload = rec + sizeof(ginxlogInsert);
9797
BlockNumber leftChildBlkno;
9898
BlockNumber rightChildBlkno;
9999

@@ -104,27 +104,27 @@ gin_desc(StringInfo buf, XLogReaderState *record)
104104
appendStringInfo(buf, " children: %u/%u",
105105
leftChildBlkno, rightChildBlkno);
106106
}
107-
if (!(xlrec->flags & GIN_INSERT_ISDATA))
108-
appendStringInfo(buf, " isdelete: %c",
109-
(((ginxlogInsertEntry *) payload)->isDelete) ? 'T' : 'F');
110-
else if (xlrec->flags & GIN_INSERT_ISLEAF)
111-
{
112-
ginxlogRecompressDataLeaf *insertData =
113-
(ginxlogRecompressDataLeaf *) payload;
114-
115-
if (XLogRecHasBlockImage(record, 0))
116-
appendStringInfoString(buf, " (full page image)");
117-
else
118-
desc_recompress_leaf(buf, insertData);
119-
}
107+
if (XLogRecHasBlockImage(record, 0))
108+
appendStringInfoString(buf, " (full page image)");
120109
else
121110
{
122-
ginxlogInsertDataInternal *insertData = (ginxlogInsertDataInternal *) payload;
111+
char *payload = XLogRecGetBlockData(record, 0, NULL);
123112

124-
appendStringInfo(buf, " pitem: %u-%u/%u",
125-
PostingItemGetBlockNumber(&insertData->newitem),
126-
ItemPointerGetBlockNumber(&insertData->newitem.key),
127-
ItemPointerGetOffsetNumber(&insertData->newitem.key));
113+
if (!(xlrec->flags & GIN_INSERT_ISDATA))
114+
appendStringInfo(buf, " isdelete: %c",
115+
(((ginxlogInsertEntry *) payload)->isDelete) ? 'T' : 'F');
116+
else if (xlrec->flags & GIN_INSERT_ISLEAF)
117+
desc_recompress_leaf(buf, (ginxlogRecompressDataLeaf *) payload);
118+
else
119+
{
120+
ginxlogInsertDataInternal *insertData =
121+
(ginxlogInsertDataInternal *) payload;
122+
123+
appendStringInfo(buf, " pitem: %u-%u/%u",
124+
PostingItemGetBlockNumber(&insertData->newitem),
125+
ItemPointerGetBlockNumber(&insertData->newitem.key),
126+
ItemPointerGetOffsetNumber(&insertData->newitem.key));
127+
}
128128
}
129129
}
130130
break;
@@ -144,12 +144,15 @@ gin_desc(StringInfo buf, XLogReaderState *record)
144144
break;
145145
case XLOG_GIN_VACUUM_DATA_LEAF_PAGE:
146146
{
147-
ginxlogVacuumDataLeafPage *xlrec = (ginxlogVacuumDataLeafPage *) rec;
148-
149147
if (XLogRecHasBlockImage(record, 0))
150148
appendStringInfoString(buf, " (full page image)");
151149
else
150+
{
151+
ginxlogVacuumDataLeafPage *xlrec =
152+
(ginxlogVacuumDataLeafPage *) XLogRecGetBlockData(record, 0, NULL);
153+
152154
desc_recompress_leaf(buf, &xlrec->data);
155+
}
153156
}
154157
break;
155158
case XLOG_GIN_DELETE_PAGE:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy