mirror of https://github.com/citusdata/citus.git
Merge a58cf9d8ed into c569f8321f
commit
f716b78f9b
|
|
@ -1543,8 +1543,7 @@ ColumnarPerStripeScanCost(RelOptInfo *rel, Oid relationId, int numberOfColumnsRe
|
||||||
ereport(ERROR, (errmsg("could not open relation with OID %u", relationId)));
|
ereport(ERROR, (errmsg("could not open relation with OID %u", relationId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
List *stripeList = StripesForRelfilelocator(RelationPhysicalIdentifier_compat(
|
List *stripeList = StripesForRelfilelocator(relation);
|
||||||
relation));
|
|
||||||
RelationClose(relation);
|
RelationClose(relation);
|
||||||
|
|
||||||
uint32 maxColumnCount = 0;
|
uint32 maxColumnCount = 0;
|
||||||
|
|
@ -1601,8 +1600,7 @@ ColumnarTableStripeCount(Oid relationId)
|
||||||
ereport(ERROR, (errmsg("could not open relation with OID %u", relationId)));
|
ereport(ERROR, (errmsg("could not open relation with OID %u", relationId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
List *stripeList = StripesForRelfilelocator(RelationPhysicalIdentifier_compat(
|
List *stripeList = StripesForRelfilelocator(relation);
|
||||||
relation));
|
|
||||||
int stripeCount = list_length(stripeList);
|
int stripeCount = list_length(stripeList);
|
||||||
RelationClose(relation);
|
RelationClose(relation);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ static Oid ColumnarChunkGroupRelationId(void);
|
||||||
static Oid ColumnarChunkIndexRelationId(void);
|
static Oid ColumnarChunkIndexRelationId(void);
|
||||||
static Oid ColumnarChunkGroupIndexRelationId(void);
|
static Oid ColumnarChunkGroupIndexRelationId(void);
|
||||||
static Oid ColumnarNamespaceId(void);
|
static Oid ColumnarNamespaceId(void);
|
||||||
static uint64 LookupStorageId(RelFileLocator relfilelocator);
|
static uint64 LookupStorageId(Oid relationId, RelFileLocator relfilelocator);
|
||||||
static uint64 GetHighestUsedRowNumber(uint64 storageId);
|
static uint64 GetHighestUsedRowNumber(uint64 storageId);
|
||||||
static void DeleteStorageFromColumnarMetadataTable(Oid metadataTableId,
|
static void DeleteStorageFromColumnarMetadataTable(Oid metadataTableId,
|
||||||
AttrNumber storageIdAtrrNumber,
|
AttrNumber storageIdAtrrNumber,
|
||||||
|
|
@ -603,7 +603,7 @@ ReadColumnarOptions(Oid regclass, ColumnarOptions *options)
|
||||||
* of columnar.chunk.
|
* of columnar.chunk.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SaveStripeSkipList(RelFileLocator relfilelocator, uint64 stripe,
|
SaveStripeSkipList(Oid relid, RelFileLocator relfilelocator, uint64 stripe,
|
||||||
StripeSkipList *chunkList,
|
StripeSkipList *chunkList,
|
||||||
TupleDesc tupleDescriptor)
|
TupleDesc tupleDescriptor)
|
||||||
{
|
{
|
||||||
|
|
@ -611,7 +611,7 @@ SaveStripeSkipList(RelFileLocator relfilelocator, uint64 stripe,
|
||||||
uint32 chunkIndex = 0;
|
uint32 chunkIndex = 0;
|
||||||
uint32 columnCount = chunkList->columnCount;
|
uint32 columnCount = chunkList->columnCount;
|
||||||
|
|
||||||
uint64 storageId = LookupStorageId(relfilelocator);
|
uint64 storageId = LookupStorageId(relid, relfilelocator);
|
||||||
Oid columnarChunkOid = ColumnarChunkRelationId();
|
Oid columnarChunkOid = ColumnarChunkRelationId();
|
||||||
Relation columnarChunk = table_open(columnarChunkOid, RowExclusiveLock);
|
Relation columnarChunk = table_open(columnarChunkOid, RowExclusiveLock);
|
||||||
ModifyState *modifyState = StartModifyRelation(columnarChunk);
|
ModifyState *modifyState = StartModifyRelation(columnarChunk);
|
||||||
|
|
@ -672,10 +672,10 @@ SaveStripeSkipList(RelFileLocator relfilelocator, uint64 stripe,
|
||||||
* SaveChunkGroups saves the metadata for given chunk groups in columnar.chunk_group.
|
* SaveChunkGroups saves the metadata for given chunk groups in columnar.chunk_group.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
SaveChunkGroups(RelFileLocator relfilelocator, uint64 stripe,
|
SaveChunkGroups(Oid relid, RelFileLocator relfilelocator, uint64 stripe,
|
||||||
List *chunkGroupRowCounts)
|
List *chunkGroupRowCounts)
|
||||||
{
|
{
|
||||||
uint64 storageId = LookupStorageId(relfilelocator);
|
uint64 storageId = LookupStorageId(relid, relfilelocator);
|
||||||
Oid columnarChunkGroupOid = ColumnarChunkGroupRelationId();
|
Oid columnarChunkGroupOid = ColumnarChunkGroupRelationId();
|
||||||
Relation columnarChunkGroup = table_open(columnarChunkGroupOid, RowExclusiveLock);
|
Relation columnarChunkGroup = table_open(columnarChunkGroupOid, RowExclusiveLock);
|
||||||
ModifyState *modifyState = StartModifyRelation(columnarChunkGroup);
|
ModifyState *modifyState = StartModifyRelation(columnarChunkGroup);
|
||||||
|
|
@ -708,7 +708,7 @@ SaveChunkGroups(RelFileLocator relfilelocator, uint64 stripe,
|
||||||
* ReadStripeSkipList fetches chunk metadata for a given stripe.
|
* ReadStripeSkipList fetches chunk metadata for a given stripe.
|
||||||
*/
|
*/
|
||||||
StripeSkipList *
|
StripeSkipList *
|
||||||
ReadStripeSkipList(RelFileLocator relfilelocator, uint64 stripe,
|
ReadStripeSkipList(Relation rel, uint64 stripe,
|
||||||
TupleDesc tupleDescriptor,
|
TupleDesc tupleDescriptor,
|
||||||
uint32 chunkCount, Snapshot snapshot)
|
uint32 chunkCount, Snapshot snapshot)
|
||||||
{
|
{
|
||||||
|
|
@ -717,7 +717,8 @@ ReadStripeSkipList(RelFileLocator relfilelocator, uint64 stripe,
|
||||||
uint32 columnCount = tupleDescriptor->natts;
|
uint32 columnCount = tupleDescriptor->natts;
|
||||||
ScanKeyData scanKey[2];
|
ScanKeyData scanKey[2];
|
||||||
|
|
||||||
uint64 storageId = LookupStorageId(relfilelocator);
|
uint64 storageId = LookupStorageId(RelationPrecomputeOid(rel),
|
||||||
|
RelationPhysicalIdentifier_compat(rel));
|
||||||
|
|
||||||
Oid columnarChunkOid = ColumnarChunkRelationId();
|
Oid columnarChunkOid = ColumnarChunkRelationId();
|
||||||
Relation columnarChunk = table_open(columnarChunkOid, AccessShareLock);
|
Relation columnarChunk = table_open(columnarChunkOid, AccessShareLock);
|
||||||
|
|
@ -1255,9 +1256,10 @@ InsertEmptyStripeMetadataRow(uint64 storageId, uint64 stripeId, uint32 columnCou
|
||||||
* of the given relfilenode.
|
* of the given relfilenode.
|
||||||
*/
|
*/
|
||||||
List *
|
List *
|
||||||
StripesForRelfilelocator(RelFileLocator relfilelocator)
|
StripesForRelfilelocator(Relation rel)
|
||||||
{
|
{
|
||||||
uint64 storageId = LookupStorageId(relfilelocator);
|
uint64 storageId = LookupStorageId(RelationPrecomputeOid(rel),
|
||||||
|
RelationPhysicalIdentifier_compat(rel));
|
||||||
|
|
||||||
return ReadDataFileStripeList(storageId, GetTransactionSnapshot());
|
return ReadDataFileStripeList(storageId, GetTransactionSnapshot());
|
||||||
}
|
}
|
||||||
|
|
@ -1272,9 +1274,10 @@ StripesForRelfilelocator(RelFileLocator relfilelocator)
|
||||||
* returns 0.
|
* returns 0.
|
||||||
*/
|
*/
|
||||||
uint64
|
uint64
|
||||||
GetHighestUsedAddress(RelFileLocator relfilelocator)
|
GetHighestUsedAddress(Relation rel)
|
||||||
{
|
{
|
||||||
uint64 storageId = LookupStorageId(relfilelocator);
|
uint64 storageId = LookupStorageId(RelationPrecomputeOid(rel),
|
||||||
|
RelationPhysicalIdentifier_compat(rel));
|
||||||
|
|
||||||
uint64 highestUsedAddress = 0;
|
uint64 highestUsedAddress = 0;
|
||||||
uint64 highestUsedId = 0;
|
uint64 highestUsedId = 0;
|
||||||
|
|
@ -1284,6 +1287,24 @@ GetHighestUsedAddress(RelFileLocator relfilelocator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* In case if relid hasn't been defined yet, we should use RelidByRelfilenumber
|
||||||
|
* to get correct relid value.
|
||||||
|
*
|
||||||
|
* Now it is basically used for temp rels, because since PG18(it was backpatched
|
||||||
|
* through PG13) RelidByRelfilenumber skip temp relations and we should use
|
||||||
|
* alternative ways to get relid value in case of temp objects.
|
||||||
|
*/
|
||||||
|
Oid
|
||||||
|
ColumnarRelationId(Oid relid, RelFileLocator relfilelocator)
|
||||||
|
{
|
||||||
|
return OidIsValid(relid) ? relid : RelidByRelfilenumber(RelationTablespace_compat(
|
||||||
|
relfilelocator),
|
||||||
|
RelationPhysicalIdentifierNumber_compat(
|
||||||
|
relfilelocator));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GetHighestUsedAddressAndId returns the highest used address and id for
|
* GetHighestUsedAddressAndId returns the highest used address and id for
|
||||||
* the given relfilenode across all active and inactive transactions.
|
* the given relfilenode across all active and inactive transactions.
|
||||||
|
|
@ -1555,7 +1576,7 @@ BuildStripeMetadata(Relation columnarStripes, HeapTuple heapTuple)
|
||||||
* metadata tables.
|
* metadata tables.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
DeleteMetadataRows(RelFileLocator relfilelocator)
|
DeleteMetadataRows(Relation rel)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* During a restore for binary upgrade, metadata tables and indexes may or
|
* During a restore for binary upgrade, metadata tables and indexes may or
|
||||||
|
|
@ -1566,7 +1587,8 @@ DeleteMetadataRows(RelFileLocator relfilelocator)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 storageId = LookupStorageId(relfilelocator);
|
uint64 storageId = LookupStorageId(RelationPrecomputeOid(rel),
|
||||||
|
RelationPhysicalIdentifier_compat(rel));
|
||||||
|
|
||||||
DeleteStorageFromColumnarMetadataTable(ColumnarStripeRelationId(),
|
DeleteStorageFromColumnarMetadataTable(ColumnarStripeRelationId(),
|
||||||
Anum_columnar_stripe_storageid,
|
Anum_columnar_stripe_storageid,
|
||||||
|
|
@ -1940,13 +1962,11 @@ ColumnarNamespaceId(void)
|
||||||
* false if the relation doesn't have a meta page yet.
|
* false if the relation doesn't have a meta page yet.
|
||||||
*/
|
*/
|
||||||
static uint64
|
static uint64
|
||||||
LookupStorageId(RelFileLocator relfilelocator)
|
LookupStorageId(Oid relid, RelFileLocator relfilelocator)
|
||||||
{
|
{
|
||||||
Oid relationId = RelidByRelfilenumber(RelationTablespace_compat(relfilelocator),
|
relid = ColumnarRelationId(relid, relfilelocator);
|
||||||
RelationPhysicalIdentifierNumber_compat(
|
|
||||||
relfilelocator));
|
|
||||||
|
|
||||||
Relation relation = relation_open(relationId, AccessShareLock);
|
Relation relation = relation_open(relid, AccessShareLock);
|
||||||
uint64 storageId = ColumnarStorageGetStorageId(relation, false);
|
uint64 storageId = ColumnarStorageGetStorageId(relation, false);
|
||||||
table_close(relation, AccessShareLock);
|
table_close(relation, AccessShareLock);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -986,8 +986,7 @@ ColumnarTableRowCount(Relation relation)
|
||||||
{
|
{
|
||||||
ListCell *stripeMetadataCell = NULL;
|
ListCell *stripeMetadataCell = NULL;
|
||||||
uint64 totalRowCount = 0;
|
uint64 totalRowCount = 0;
|
||||||
List *stripeList = StripesForRelfilelocator(RelationPhysicalIdentifier_compat(
|
List *stripeList = StripesForRelfilelocator(relation);
|
||||||
relation));
|
|
||||||
|
|
||||||
foreach(stripeMetadataCell, stripeList)
|
foreach(stripeMetadataCell, stripeList)
|
||||||
{
|
{
|
||||||
|
|
@ -1015,8 +1014,7 @@ LoadFilteredStripeBuffers(Relation relation, StripeMetadata *stripeMetadata,
|
||||||
|
|
||||||
bool *projectedColumnMask = ProjectedColumnMask(columnCount, projectedColumnList);
|
bool *projectedColumnMask = ProjectedColumnMask(columnCount, projectedColumnList);
|
||||||
|
|
||||||
StripeSkipList *stripeSkipList = ReadStripeSkipList(RelationPhysicalIdentifier_compat(
|
StripeSkipList *stripeSkipList = ReadStripeSkipList(relation,
|
||||||
relation),
|
|
||||||
stripeMetadata->id,
|
stripeMetadata->id,
|
||||||
tupleDescriptor,
|
tupleDescriptor,
|
||||||
stripeMetadata->chunkCount,
|
stripeMetadata->chunkCount,
|
||||||
|
|
|
||||||
|
|
@ -872,7 +872,7 @@ columnar_relation_set_new_filelocator(Relation rel,
|
||||||
RelationPhysicalIdentifier_compat(rel)),
|
RelationPhysicalIdentifier_compat(rel)),
|
||||||
GetCurrentSubTransactionId());
|
GetCurrentSubTransactionId());
|
||||||
|
|
||||||
DeleteMetadataRows(RelationPhysicalIdentifier_compat(rel));
|
DeleteMetadataRows(rel);
|
||||||
}
|
}
|
||||||
|
|
||||||
*freezeXid = RecentXmin;
|
*freezeXid = RecentXmin;
|
||||||
|
|
@ -897,7 +897,7 @@ columnar_relation_nontransactional_truncate(Relation rel)
|
||||||
NonTransactionDropWriteState(RelationPhysicalIdentifierNumber_compat(relfilelocator));
|
NonTransactionDropWriteState(RelationPhysicalIdentifierNumber_compat(relfilelocator));
|
||||||
|
|
||||||
/* Delete old relfilenode metadata */
|
/* Delete old relfilenode metadata */
|
||||||
DeleteMetadataRows(relfilelocator);
|
DeleteMetadataRows(rel);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* No need to set new relfilenode, since the table was created in this
|
* No need to set new relfilenode, since the table was created in this
|
||||||
|
|
@ -960,8 +960,7 @@ columnar_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
|
||||||
ColumnarOptions columnarOptions = { 0 };
|
ColumnarOptions columnarOptions = { 0 };
|
||||||
ReadColumnarOptions(OldHeap->rd_id, &columnarOptions);
|
ReadColumnarOptions(OldHeap->rd_id, &columnarOptions);
|
||||||
|
|
||||||
ColumnarWriteState *writeState = ColumnarBeginWrite(RelationPhysicalIdentifier_compat(
|
ColumnarWriteState *writeState = ColumnarBeginWrite(NewHeap,
|
||||||
NewHeap),
|
|
||||||
columnarOptions,
|
columnarOptions,
|
||||||
targetDesc);
|
targetDesc);
|
||||||
|
|
||||||
|
|
@ -1036,8 +1035,7 @@ NeededColumnsList(TupleDesc tupdesc, Bitmapset *attr_needed)
|
||||||
static uint64
|
static uint64
|
||||||
ColumnarTableTupleCount(Relation relation)
|
ColumnarTableTupleCount(Relation relation)
|
||||||
{
|
{
|
||||||
List *stripeList = StripesForRelfilelocator(RelationPhysicalIdentifier_compat(
|
List *stripeList = StripesForRelfilelocator(relation);
|
||||||
relation));
|
|
||||||
uint64 tupleCount = 0;
|
uint64 tupleCount = 0;
|
||||||
|
|
||||||
ListCell *lc = NULL;
|
ListCell *lc = NULL;
|
||||||
|
|
@ -1202,7 +1200,6 @@ static void
|
||||||
LogRelationStats(Relation rel, int elevel)
|
LogRelationStats(Relation rel, int elevel)
|
||||||
{
|
{
|
||||||
ListCell *stripeMetadataCell = NULL;
|
ListCell *stripeMetadataCell = NULL;
|
||||||
RelFileLocator relfilelocator = RelationPhysicalIdentifier_compat(rel);
|
|
||||||
StringInfo infoBuf = makeStringInfo();
|
StringInfo infoBuf = makeStringInfo();
|
||||||
|
|
||||||
int compressionStats[COMPRESSION_COUNT] = { 0 };
|
int compressionStats[COMPRESSION_COUNT] = { 0 };
|
||||||
|
|
@ -1213,13 +1210,13 @@ LogRelationStats(Relation rel, int elevel)
|
||||||
uint64 droppedChunksWithData = 0;
|
uint64 droppedChunksWithData = 0;
|
||||||
uint64 totalDecompressedLength = 0;
|
uint64 totalDecompressedLength = 0;
|
||||||
|
|
||||||
List *stripeList = StripesForRelfilelocator(relfilelocator);
|
List *stripeList = StripesForRelfilelocator(rel);
|
||||||
int stripeCount = list_length(stripeList);
|
int stripeCount = list_length(stripeList);
|
||||||
|
|
||||||
foreach(stripeMetadataCell, stripeList)
|
foreach(stripeMetadataCell, stripeList)
|
||||||
{
|
{
|
||||||
StripeMetadata *stripe = lfirst(stripeMetadataCell);
|
StripeMetadata *stripe = lfirst(stripeMetadataCell);
|
||||||
StripeSkipList *skiplist = ReadStripeSkipList(relfilelocator, stripe->id,
|
StripeSkipList *skiplist = ReadStripeSkipList(rel, stripe->id,
|
||||||
RelationGetDescr(rel),
|
RelationGetDescr(rel),
|
||||||
stripe->chunkCount,
|
stripe->chunkCount,
|
||||||
GetTransactionSnapshot());
|
GetTransactionSnapshot());
|
||||||
|
|
@ -1355,8 +1352,7 @@ TruncateColumnar(Relation rel, int elevel)
|
||||||
* new stripes be added beyond highestPhysicalAddress while
|
* new stripes be added beyond highestPhysicalAddress while
|
||||||
* we're truncating.
|
* we're truncating.
|
||||||
*/
|
*/
|
||||||
uint64 newDataReservation = Max(GetHighestUsedAddress(
|
uint64 newDataReservation = Max(GetHighestUsedAddress(rel) + 1,
|
||||||
RelationPhysicalIdentifier_compat(rel)) + 1,
|
|
||||||
ColumnarFirstLogicalOffset);
|
ColumnarFirstLogicalOffset);
|
||||||
|
|
||||||
BlockNumber old_rel_pages = smgrnblocks(RelationGetSmgr(rel), MAIN_FORKNUM);
|
BlockNumber old_rel_pages = smgrnblocks(RelationGetSmgr(rel), MAIN_FORKNUM);
|
||||||
|
|
@ -2107,7 +2103,7 @@ ColumnarTableDropHook(Oid relid)
|
||||||
Relation rel = table_open(relid, AccessExclusiveLock);
|
Relation rel = table_open(relid, AccessExclusiveLock);
|
||||||
RelFileLocator relfilelocator = RelationPhysicalIdentifier_compat(rel);
|
RelFileLocator relfilelocator = RelationPhysicalIdentifier_compat(rel);
|
||||||
|
|
||||||
DeleteMetadataRows(relfilelocator);
|
DeleteMetadataRows(rel);
|
||||||
DeleteColumnarTableOptions(rel->rd_id, true);
|
DeleteColumnarTableOptions(rel->rd_id, true);
|
||||||
|
|
||||||
MarkRelfilenumberDropped(RelationPhysicalIdentifierNumber_compat(relfilelocator),
|
MarkRelfilenumberDropped(RelationPhysicalIdentifierNumber_compat(relfilelocator),
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,12 @@ struct ColumnarWriteState
|
||||||
FmgrInfo **comparisonFunctionArray;
|
FmgrInfo **comparisonFunctionArray;
|
||||||
RelFileLocator relfilelocator;
|
RelFileLocator relfilelocator;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We can't rely on RelidByRelfilenumber for temp tables since
|
||||||
|
* PG18(it was backpatched through PG13).
|
||||||
|
*/
|
||||||
|
Oid temp_relid;
|
||||||
|
|
||||||
MemoryContext stripeWriteContext;
|
MemoryContext stripeWriteContext;
|
||||||
MemoryContext perTupleContext;
|
MemoryContext perTupleContext;
|
||||||
StripeBuffers *stripeBuffers;
|
StripeBuffers *stripeBuffers;
|
||||||
|
|
@ -91,10 +97,12 @@ static StringInfo CopyStringInfo(StringInfo sourceString);
|
||||||
* data load operation.
|
* data load operation.
|
||||||
*/
|
*/
|
||||||
ColumnarWriteState *
|
ColumnarWriteState *
|
||||||
ColumnarBeginWrite(RelFileLocator relfilelocator,
|
ColumnarBeginWrite(Relation rel,
|
||||||
ColumnarOptions options,
|
ColumnarOptions options,
|
||||||
TupleDesc tupleDescriptor)
|
TupleDesc tupleDescriptor)
|
||||||
{
|
{
|
||||||
|
RelFileLocator relfilelocator = RelationPhysicalIdentifier_compat(rel);
|
||||||
|
|
||||||
/* get comparison function pointers for each of the columns */
|
/* get comparison function pointers for each of the columns */
|
||||||
uint32 columnCount = tupleDescriptor->natts;
|
uint32 columnCount = tupleDescriptor->natts;
|
||||||
FmgrInfo **comparisonFunctionArray = palloc0(columnCount * sizeof(FmgrInfo *));
|
FmgrInfo **comparisonFunctionArray = palloc0(columnCount * sizeof(FmgrInfo *));
|
||||||
|
|
@ -132,6 +140,7 @@ ColumnarBeginWrite(RelFileLocator relfilelocator,
|
||||||
|
|
||||||
ColumnarWriteState *writeState = palloc0(sizeof(ColumnarWriteState));
|
ColumnarWriteState *writeState = palloc0(sizeof(ColumnarWriteState));
|
||||||
writeState->relfilelocator = relfilelocator;
|
writeState->relfilelocator = relfilelocator;
|
||||||
|
writeState->temp_relid = RelationPrecomputeOid(rel);
|
||||||
writeState->options = options;
|
writeState->options = options;
|
||||||
writeState->tupleDescriptor = CreateTupleDescCopy(tupleDescriptor);
|
writeState->tupleDescriptor = CreateTupleDescCopy(tupleDescriptor);
|
||||||
writeState->comparisonFunctionArray = comparisonFunctionArray;
|
writeState->comparisonFunctionArray = comparisonFunctionArray;
|
||||||
|
|
@ -181,10 +190,9 @@ ColumnarWriteRow(ColumnarWriteState *writeState, Datum *columnValues, bool *colu
|
||||||
writeState->stripeSkipList = stripeSkipList;
|
writeState->stripeSkipList = stripeSkipList;
|
||||||
writeState->compressionBuffer = makeStringInfo();
|
writeState->compressionBuffer = makeStringInfo();
|
||||||
|
|
||||||
Oid relationId = RelidByRelfilenumber(RelationTablespace_compat(
|
Oid relationId = ColumnarRelationId(writeState->temp_relid,
|
||||||
writeState->relfilelocator),
|
writeState->relfilelocator);
|
||||||
RelationPhysicalIdentifierNumber_compat(
|
|
||||||
writeState->relfilelocator));
|
|
||||||
Relation relation = relation_open(relationId, NoLock);
|
Relation relation = relation_open(relationId, NoLock);
|
||||||
writeState->emptyStripeReservation =
|
writeState->emptyStripeReservation =
|
||||||
ReserveEmptyStripe(relation, columnCount, chunkRowCount,
|
ReserveEmptyStripe(relation, columnCount, chunkRowCount,
|
||||||
|
|
@ -402,10 +410,9 @@ FlushStripe(ColumnarWriteState *writeState)
|
||||||
|
|
||||||
elog(DEBUG1, "Flushing Stripe of size %d", stripeBuffers->rowCount);
|
elog(DEBUG1, "Flushing Stripe of size %d", stripeBuffers->rowCount);
|
||||||
|
|
||||||
Oid relationId = RelidByRelfilenumber(RelationTablespace_compat(
|
Oid relationId = ColumnarRelationId(writeState->temp_relid,
|
||||||
writeState->relfilelocator),
|
writeState->relfilelocator);
|
||||||
RelationPhysicalIdentifierNumber_compat(
|
|
||||||
writeState->relfilelocator));
|
|
||||||
Relation relation = relation_open(relationId, NoLock);
|
Relation relation = relation_open(relationId, NoLock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -497,10 +504,12 @@ FlushStripe(ColumnarWriteState *writeState)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveChunkGroups(writeState->relfilelocator,
|
SaveChunkGroups(writeState->temp_relid,
|
||||||
|
writeState->relfilelocator,
|
||||||
stripeMetadata->id,
|
stripeMetadata->id,
|
||||||
writeState->chunkGroupRowCounts);
|
writeState->chunkGroupRowCounts);
|
||||||
SaveStripeSkipList(writeState->relfilelocator,
|
SaveStripeSkipList(writeState->temp_relid,
|
||||||
|
writeState->relfilelocator,
|
||||||
stripeMetadata->id,
|
stripeMetadata->id,
|
||||||
stripeSkipList, tupleDescriptor);
|
stripeSkipList, tupleDescriptor);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -191,8 +191,7 @@ columnar_init_write_state(Relation relation, TupleDesc tupdesc,
|
||||||
ReadColumnarOptions(tupSlotRelationId, &columnarOptions);
|
ReadColumnarOptions(tupSlotRelationId, &columnarOptions);
|
||||||
|
|
||||||
SubXidWriteState *stackEntry = palloc0(sizeof(SubXidWriteState));
|
SubXidWriteState *stackEntry = palloc0(sizeof(SubXidWriteState));
|
||||||
stackEntry->writeState = ColumnarBeginWrite(RelationPhysicalIdentifier_compat(
|
stackEntry->writeState = ColumnarBeginWrite(relation,
|
||||||
relation),
|
|
||||||
columnarOptions,
|
columnarOptions,
|
||||||
tupdesc);
|
tupdesc);
|
||||||
stackEntry->subXid = currentSubXid;
|
stackEntry->subXid = currentSubXid;
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,14 @@
|
||||||
/*global variables for citus_columnar fake version Y */
|
/*global variables for citus_columnar fake version Y */
|
||||||
#define CITUS_COLUMNAR_INTERNAL_VERSION "11.1-0"
|
#define CITUS_COLUMNAR_INTERNAL_VERSION "11.1-0"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We can't rely on RelidByRelfilenumber for temp tables since PG18(it was backpatched
|
||||||
|
* through PG13), so we can use this macro to define relid within relation in case of
|
||||||
|
* temp relations. Otherwise RelidByRelfilenumber should be used.
|
||||||
|
*/
|
||||||
|
#define RelationPrecomputeOid(a) (RelationUsesLocalBuffers(a) ? RelationGetRelid(a) : \
|
||||||
|
InvalidOid)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ColumnarOptions holds the option values to be used when reading or writing
|
* ColumnarOptions holds the option values to be used when reading or writing
|
||||||
* a columnar table. To resolve these values, we first check foreign table's options,
|
* a columnar table. To resolve these values, we first check foreign table's options,
|
||||||
|
|
@ -231,7 +239,7 @@ extern void columnar_init_gucs(void);
|
||||||
extern CompressionType ParseCompressionType(const char *compressionTypeString);
|
extern CompressionType ParseCompressionType(const char *compressionTypeString);
|
||||||
|
|
||||||
/* Function declarations for writing to a columnar table */
|
/* Function declarations for writing to a columnar table */
|
||||||
extern ColumnarWriteState * ColumnarBeginWrite(RelFileLocator relfilelocator,
|
extern ColumnarWriteState * ColumnarBeginWrite(Relation rel,
|
||||||
ColumnarOptions options,
|
ColumnarOptions options,
|
||||||
TupleDesc tupleDescriptor);
|
TupleDesc tupleDescriptor);
|
||||||
extern uint64 ColumnarWriteRow(ColumnarWriteState *state, Datum *columnValues,
|
extern uint64 ColumnarWriteRow(ColumnarWriteState *state, Datum *columnValues,
|
||||||
|
|
@ -286,21 +294,21 @@ extern PGDLLEXPORT bool ReadColumnarOptions(Oid regclass, ColumnarOptions *optio
|
||||||
extern PGDLLEXPORT bool IsColumnarTableAmTable(Oid relationId);
|
extern PGDLLEXPORT bool IsColumnarTableAmTable(Oid relationId);
|
||||||
|
|
||||||
/* columnar_metadata_tables.c */
|
/* columnar_metadata_tables.c */
|
||||||
extern void DeleteMetadataRows(RelFileLocator relfilelocator);
|
extern void DeleteMetadataRows(Relation rel);
|
||||||
extern uint64 ColumnarMetadataNewStorageId(void);
|
extern uint64 ColumnarMetadataNewStorageId(void);
|
||||||
extern uint64 GetHighestUsedAddress(RelFileLocator relfilelocator);
|
extern uint64 GetHighestUsedAddress(Relation rel);
|
||||||
extern EmptyStripeReservation * ReserveEmptyStripe(Relation rel, uint64 columnCount,
|
extern EmptyStripeReservation * ReserveEmptyStripe(Relation rel, uint64 columnCount,
|
||||||
uint64 chunkGroupRowCount,
|
uint64 chunkGroupRowCount,
|
||||||
uint64 stripeRowCount);
|
uint64 stripeRowCount);
|
||||||
extern StripeMetadata * CompleteStripeReservation(Relation rel, uint64 stripeId,
|
extern StripeMetadata * CompleteStripeReservation(Relation rel, uint64 stripeId,
|
||||||
uint64 sizeBytes, uint64 rowCount,
|
uint64 sizeBytes, uint64 rowCount,
|
||||||
uint64 chunkCount);
|
uint64 chunkCount);
|
||||||
extern void SaveStripeSkipList(RelFileLocator relfilelocator, uint64 stripe,
|
extern void SaveStripeSkipList(Oid relid, RelFileLocator relfilelocator, uint64 stripe,
|
||||||
StripeSkipList *stripeSkipList,
|
StripeSkipList *stripeSkipList,
|
||||||
TupleDesc tupleDescriptor);
|
TupleDesc tupleDescriptor);
|
||||||
extern void SaveChunkGroups(RelFileLocator relfilelocator, uint64 stripe,
|
extern void SaveChunkGroups(Oid relid, RelFileLocator relfilelocator, uint64 stripe,
|
||||||
List *chunkGroupRowCounts);
|
List *chunkGroupRowCounts);
|
||||||
extern StripeSkipList * ReadStripeSkipList(RelFileLocator relfilelocator, uint64 stripe,
|
extern StripeSkipList * ReadStripeSkipList(Relation rel, uint64 stripe,
|
||||||
TupleDesc tupleDescriptor,
|
TupleDesc tupleDescriptor,
|
||||||
uint32 chunkCount,
|
uint32 chunkCount,
|
||||||
Snapshot snapshot);
|
Snapshot snapshot);
|
||||||
|
|
@ -316,6 +324,7 @@ extern uint64 StripeGetHighestRowNumber(StripeMetadata *stripeMetadata);
|
||||||
extern StripeMetadata * FindStripeWithHighestRowNumber(Relation relation,
|
extern StripeMetadata * FindStripeWithHighestRowNumber(Relation relation,
|
||||||
Snapshot snapshot);
|
Snapshot snapshot);
|
||||||
extern Datum columnar_relation_storageid(PG_FUNCTION_ARGS);
|
extern Datum columnar_relation_storageid(PG_FUNCTION_ARGS);
|
||||||
|
extern Oid ColumnarRelationId(Oid relid, RelFileLocator relfilelocator);
|
||||||
|
|
||||||
|
|
||||||
/* write_state_management.c */
|
/* write_state_management.c */
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ typedef struct EmptyStripeReservation
|
||||||
uint64 stripeFirstRowNumber;
|
uint64 stripeFirstRowNumber;
|
||||||
} EmptyStripeReservation;
|
} EmptyStripeReservation;
|
||||||
|
|
||||||
extern List * StripesForRelfilelocator(RelFileLocator relfilelocator);
|
extern List * StripesForRelfilelocator(Relation rel);
|
||||||
extern void ColumnarStorageUpdateIfNeeded(Relation rel, bool isUpgrade);
|
extern void ColumnarStorageUpdateIfNeeded(Relation rel, bool isUpgrade);
|
||||||
extern List * ExtractColumnarRelOptions(List *inOptions, List **outColumnarOptions);
|
extern List * ExtractColumnarRelOptions(List *inOptions, List **outColumnarOptions);
|
||||||
extern void SetColumnarRelOptions(RangeVar *rv, List *reloptions);
|
extern void SetColumnarRelOptions(RangeVar *rv, List *reloptions);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue