Columnar temp tables cannot be accessed(#8235).

Fix PR comments.
pull/8309/head
Maksim Melnikov 2025-11-06 15:49:25 +03:00
parent d3578205ef
commit e7f7677e64
4 changed files with 22 additions and 7 deletions

View File

@ -729,7 +729,7 @@ ReadStripeSkipList(Relation rel, uint64 stripe,
uint32 columnCount = tupleDescriptor->natts;
ScanKeyData scanKey[2];
uint64 storageId = LookupStorageId(RelationPrecomputeOid_compat(rel),
uint64 storageId = LookupStorageId(RelationPrecomputeOid(rel),
RelationPhysicalIdentifier_compat(rel));
Oid columnarChunkOid = ColumnarChunkRelationId();
@ -1276,7 +1276,7 @@ InsertEmptyStripeMetadataRow(uint64 storageId, uint64 stripeId, uint32 columnCou
List *
StripesForRelfilelocator(Relation rel)
{
uint64 storageId = LookupStorageId(RelationPrecomputeOid_compat(rel),
uint64 storageId = LookupStorageId(RelationPrecomputeOid(rel),
RelationPhysicalIdentifier_compat(rel));
/*
@ -1308,7 +1308,7 @@ StripesForRelfilelocator(Relation rel)
uint64
GetHighestUsedAddress(Relation rel)
{
uint64 storageId = LookupStorageId(RelationPrecomputeOid_compat(rel),
uint64 storageId = LookupStorageId(RelationPrecomputeOid(rel),
RelationPhysicalIdentifier_compat(rel));
uint64 highestUsedAddress = 0;
@ -1319,6 +1319,14 @@ GetHighestUsedAddress(Relation rel)
}
/*
* 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 PGXX 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)
{
@ -1615,7 +1623,7 @@ DeleteMetadataRows(Relation rel)
return;
}
uint64 storageId = LookupStorageId(RelationPrecomputeOid_compat(rel),
uint64 storageId = LookupStorageId(RelationPrecomputeOid(rel),
RelationPhysicalIdentifier_compat(rel));
DeleteStorageFromColumnarMetadataTable(ColumnarStripeRelationId(),

View File

@ -137,7 +137,7 @@ ColumnarBeginWrite(Relation rel,
ColumnarWriteState *writeState = palloc0(sizeof(ColumnarWriteState));
writeState->relfilelocator = relfilelocator;
writeState->temp_relid = RelationPrecomputeOid_compat(rel);
writeState->temp_relid = RelationPrecomputeOid(rel);
writeState->options = options;
writeState->tupleDescriptor = CreateTupleDescCopy(tupleDescriptor);
writeState->comparisonFunctionArray = comparisonFunctionArray;

View File

@ -64,6 +64,14 @@
/*global variables for citus_columnar fake version Y */
#define CITUS_COLUMNAR_INTERNAL_VERSION "11.1-0"
/*
* We can't rely on RelidByRelfilenumber for temp tables since PGXX, 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
* a columnar table. To resolve these values, we first check foreign table's options,

View File

@ -469,8 +469,6 @@ getStxstattarget_compat(HeapTuple tup)
#define RelationPhysicalIdentifier_compat(a) ((a)->rd_locator)
#define RelationTablespace_compat(a) (a.spcOid)
#define RelationPrecomputeOid_compat(a) (RelationUsesLocalBuffers(a) ? RelationGetRelid( \
a) : InvalidOid)
#define RelationPhysicalIdentifierNumber_compat(a) (a.relNumber)
#define RelationPhysicalIdentifierNumberPtr_compat(a) (a->relNumber)
#define RelationPhysicalIdentifierBackend_compat(a) (a->smgr_rlocator.locator)
@ -523,6 +521,7 @@ get_guc_variables_compat(int *gucCount)
#define RelationPhysicalIdentifierBackend_compat(a) (a->smgr_rnode.node)
typedef RelFileNode RelFileLocator;
typedef Oid RelFileNumber;
#define RelidByRelfilenumber(a, b) RelidByRelfilenode(a, b)
#define float_abs(a) Abs(a)