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>
This commit is contained in:
parent
25c06a1ed6
commit
8606271640
|
@ -87,13 +87,13 @@ gin_desc(StringInfo buf, XLogReaderState *record)
|
||||||
case XLOG_GIN_INSERT:
|
case XLOG_GIN_INSERT:
|
||||||
{
|
{
|
||||||
ginxlogInsert *xlrec = (ginxlogInsert *) rec;
|
ginxlogInsert *xlrec = (ginxlogInsert *) rec;
|
||||||
char *payload = rec + sizeof(ginxlogInsert);
|
|
||||||
|
|
||||||
appendStringInfo(buf, "isdata: %c isleaf: %c",
|
appendStringInfo(buf, "isdata: %c isleaf: %c",
|
||||||
(xlrec->flags & GIN_INSERT_ISDATA) ? 'T' : 'F',
|
(xlrec->flags & GIN_INSERT_ISDATA) ? 'T' : 'F',
|
||||||
(xlrec->flags & GIN_INSERT_ISLEAF) ? 'T' : 'F');
|
(xlrec->flags & GIN_INSERT_ISLEAF) ? 'T' : 'F');
|
||||||
if (!(xlrec->flags & GIN_INSERT_ISLEAF))
|
if (!(xlrec->flags & GIN_INSERT_ISLEAF))
|
||||||
{
|
{
|
||||||
|
char *payload = rec + sizeof(ginxlogInsert);
|
||||||
BlockNumber leftChildBlkno;
|
BlockNumber leftChildBlkno;
|
||||||
BlockNumber rightChildBlkno;
|
BlockNumber rightChildBlkno;
|
||||||
|
|
||||||
|
@ -104,27 +104,27 @@ gin_desc(StringInfo buf, XLogReaderState *record)
|
||||||
appendStringInfo(buf, " children: %u/%u",
|
appendStringInfo(buf, " children: %u/%u",
|
||||||
leftChildBlkno, rightChildBlkno);
|
leftChildBlkno, rightChildBlkno);
|
||||||
}
|
}
|
||||||
if (!(xlrec->flags & GIN_INSERT_ISDATA))
|
if (XLogRecHasBlockImage(record, 0))
|
||||||
appendStringInfo(buf, " isdelete: %c",
|
appendStringInfoString(buf, " (full page image)");
|
||||||
(((ginxlogInsertEntry *) payload)->isDelete) ? 'T' : 'F');
|
|
||||||
else if (xlrec->flags & GIN_INSERT_ISLEAF)
|
|
||||||
{
|
|
||||||
ginxlogRecompressDataLeaf *insertData =
|
|
||||||
(ginxlogRecompressDataLeaf *) payload;
|
|
||||||
|
|
||||||
if (XLogRecHasBlockImage(record, 0))
|
|
||||||
appendStringInfoString(buf, " (full page image)");
|
|
||||||
else
|
|
||||||
desc_recompress_leaf(buf, insertData);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ginxlogInsertDataInternal *insertData = (ginxlogInsertDataInternal *) payload;
|
char *payload = XLogRecGetBlockData(record, 0, NULL);
|
||||||
|
|
||||||
appendStringInfo(buf, " pitem: %u-%u/%u",
|
if (!(xlrec->flags & GIN_INSERT_ISDATA))
|
||||||
PostingItemGetBlockNumber(&insertData->newitem),
|
appendStringInfo(buf, " isdelete: %c",
|
||||||
ItemPointerGetBlockNumber(&insertData->newitem.key),
|
(((ginxlogInsertEntry *) payload)->isDelete) ? 'T' : 'F');
|
||||||
ItemPointerGetOffsetNumber(&insertData->newitem.key));
|
else if (xlrec->flags & GIN_INSERT_ISLEAF)
|
||||||
|
desc_recompress_leaf(buf, (ginxlogRecompressDataLeaf *) payload);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ginxlogInsertDataInternal *insertData =
|
||||||
|
(ginxlogInsertDataInternal *) payload;
|
||||||
|
|
||||||
|
appendStringInfo(buf, " pitem: %u-%u/%u",
|
||||||
|
PostingItemGetBlockNumber(&insertData->newitem),
|
||||||
|
ItemPointerGetBlockNumber(&insertData->newitem.key),
|
||||||
|
ItemPointerGetOffsetNumber(&insertData->newitem.key));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -144,12 +144,15 @@ gin_desc(StringInfo buf, XLogReaderState *record)
|
||||||
break;
|
break;
|
||||||
case XLOG_GIN_VACUUM_DATA_LEAF_PAGE:
|
case XLOG_GIN_VACUUM_DATA_LEAF_PAGE:
|
||||||
{
|
{
|
||||||
ginxlogVacuumDataLeafPage *xlrec = (ginxlogVacuumDataLeafPage *) rec;
|
|
||||||
|
|
||||||
if (XLogRecHasBlockImage(record, 0))
|
if (XLogRecHasBlockImage(record, 0))
|
||||||
appendStringInfoString(buf, " (full page image)");
|
appendStringInfoString(buf, " (full page image)");
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
ginxlogVacuumDataLeafPage *xlrec =
|
||||||
|
(ginxlogVacuumDataLeafPage *) XLogRecGetBlockData(record, 0, NULL);
|
||||||
|
|
||||||
desc_recompress_leaf(buf, &xlrec->data);
|
desc_recompress_leaf(buf, &xlrec->data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case XLOG_GIN_DELETE_PAGE:
|
case XLOG_GIN_DELETE_PAGE:
|
||||||
|
|
Loading…
Reference in New Issue