Implement ErrorIfInvalidRowNumber

To use the same logic when mapping tid's to row number's
pull/5052/head
Onur Tirtir 2021-05-03 19:21:52 +03:00
parent 7ae90b7f96
commit 181848cc80
1 changed files with 17 additions and 6 deletions

View File

@ -111,6 +111,7 @@ static HeapTuple ColumnarSlotCopyHeapTuple(TupleTableSlot *slot);
static void ColumnarCheckLogicalReplication(Relation rel); static void ColumnarCheckLogicalReplication(Relation rel);
static Datum * detoast_values(TupleDesc tupleDesc, Datum *orig_values, bool *isnull); static Datum * detoast_values(TupleDesc tupleDesc, Datum *orig_values, bool *isnull);
static ItemPointerData row_number_to_tid(uint64 rowNumber); static ItemPointerData row_number_to_tid(uint64 rowNumber);
static void ErrorIfInvalidRowNumber(uint64 rowNumber);
/* Custom tuple slot ops used for columnar. Initialized in columnar_tableam_init(). */ /* Custom tuple slot ops used for columnar. Initialized in columnar_tableam_init(). */
static TupleTableSlotOps TTSOpsColumnar; static TupleTableSlotOps TTSOpsColumnar;
@ -282,6 +283,22 @@ columnar_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlo
*/ */
static ItemPointerData static ItemPointerData
row_number_to_tid(uint64 rowNumber) row_number_to_tid(uint64 rowNumber)
{
ErrorIfInvalidRowNumber(rowNumber);
ItemPointerData tid = { 0 };
ItemPointerSetBlockNumber(&tid, rowNumber / VALID_ITEMPOINTER_OFFSETS);
ItemPointerSetOffsetNumber(&tid, rowNumber % VALID_ITEMPOINTER_OFFSETS +
FirstOffsetNumber);
return tid;
}
/*
* ErrorIfInvalidRowNumber errors out if given rowNumber is invalid.
*/
static void
ErrorIfInvalidRowNumber(uint64 rowNumber)
{ {
if (rowNumber == COLUMNAR_INVALID_ROW_NUMBER) if (rowNumber == COLUMNAR_INVALID_ROW_NUMBER)
{ {
@ -297,12 +314,6 @@ row_number_to_tid(uint64 rowNumber)
(uint64) COLUMNAR_MAX_ROW_NUMBER), (uint64) COLUMNAR_MAX_ROW_NUMBER),
errhint("Consider using VACUUM FULL for your table"))); errhint("Consider using VACUUM FULL for your table")));
} }
ItemPointerData tid = { 0 };
ItemPointerSetBlockNumber(&tid, rowNumber / VALID_ITEMPOINTER_OFFSETS);
ItemPointerSetOffsetNumber(&tid, rowNumber % VALID_ITEMPOINTER_OFFSETS +
FirstOffsetNumber);
return tid;
} }