mirror of https://github.com/citusdata/citus.git
we should check if relation is valid after fetching a relation
parent
ac6ccab739
commit
da089d72c5
|
@ -277,6 +277,11 @@ ColumnarSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti,
|
|||
* into the scan of the table to minimize the data read.
|
||||
*/
|
||||
Relation relation = RelationIdGetRelation(rte->relid);
|
||||
if (!RelationIsValid(relation))
|
||||
{
|
||||
ereport(ERROR, (errmsg("could not open relation with OID %u", rte->relid)));
|
||||
}
|
||||
|
||||
if (relation->rd_tableam == GetColumnarTableAmRoutine())
|
||||
{
|
||||
if (rte->tablesample != NULL)
|
||||
|
@ -501,6 +506,11 @@ ColumnarIndexScanAdditionalCost(PlannerInfo *root, RelOptInfo *rel,
|
|||
&indexCorrelation, &fakeIndexPages);
|
||||
|
||||
Relation relation = RelationIdGetRelation(relationId);
|
||||
if (!RelationIsValid(relation))
|
||||
{
|
||||
ereport(ERROR, (errmsg("could not open relation with OID %u", relationId)));
|
||||
}
|
||||
|
||||
uint64 rowCount = ColumnarTableRowCount(relation);
|
||||
RelationClose(relation);
|
||||
double estimatedRows = rowCount * indexSelectivity;
|
||||
|
@ -596,6 +606,11 @@ static int
|
|||
RelationIdGetNumberOfAttributes(Oid relationId)
|
||||
{
|
||||
Relation relation = RelationIdGetRelation(relationId);
|
||||
if (!RelationIsValid(relation))
|
||||
{
|
||||
ereport(ERROR, (errmsg("could not open relation with OID %u", relationId)));
|
||||
}
|
||||
|
||||
int nattrs = relation->rd_att->natts;
|
||||
RelationClose(relation);
|
||||
return nattrs;
|
||||
|
@ -1399,6 +1414,11 @@ static Cost
|
|||
ColumnarPerStripeScanCost(RelOptInfo *rel, Oid relationId, int numberOfColumnsRead)
|
||||
{
|
||||
Relation relation = RelationIdGetRelation(relationId);
|
||||
if (!RelationIsValid(relation))
|
||||
{
|
||||
ereport(ERROR, (errmsg("could not open relation with OID %u", relationId)));
|
||||
}
|
||||
|
||||
List *stripeList = StripesForRelfilenode(relation->rd_node);
|
||||
RelationClose(relation);
|
||||
|
||||
|
@ -1451,6 +1471,11 @@ static uint64
|
|||
ColumnarTableStripeCount(Oid relationId)
|
||||
{
|
||||
Relation relation = RelationIdGetRelation(relationId);
|
||||
if (!RelationIsValid(relation))
|
||||
{
|
||||
ereport(ERROR, (errmsg("could not open relation with OID %u", relationId)));
|
||||
}
|
||||
|
||||
List *stripeList = StripesForRelfilenode(relation->rd_node);
|
||||
int stripeCount = list_length(stripeList);
|
||||
RelationClose(relation);
|
||||
|
|
|
@ -857,6 +857,11 @@ static void
|
|||
DropIndexesNotSupportedByColumnar(Oid relationId, bool suppressNoticeMessages)
|
||||
{
|
||||
Relation columnarRelation = RelationIdGetRelation(relationId);
|
||||
if (!RelationIsValid(columnarRelation))
|
||||
{
|
||||
ereport(ERROR, (errmsg("could not open relation with OID %u", relationId)));
|
||||
}
|
||||
|
||||
List *indexIdList = RelationGetIndexList(columnarRelation);
|
||||
|
||||
/*
|
||||
|
|
|
@ -891,6 +891,11 @@ static void
|
|||
RenameShardRelationStatistics(Oid shardRelationId, uint64 shardId)
|
||||
{
|
||||
Relation shardRelation = RelationIdGetRelation(shardRelationId);
|
||||
if (!RelationIsValid(shardRelation))
|
||||
{
|
||||
ereport(ERROR, (errmsg("could not open relation with OID %u", shardRelationId)));
|
||||
}
|
||||
|
||||
List *statsOidList = RelationGetStatExtList(shardRelation);
|
||||
RelationClose(shardRelation);
|
||||
|
||||
|
|
|
@ -321,6 +321,11 @@ ExecuteFunctionOnEachTableIndex(Oid relationId, PGIndexProcessor pgIndexProcesso
|
|||
List *result = NIL;
|
||||
|
||||
Relation relation = RelationIdGetRelation(relationId);
|
||||
if (!RelationIsValid(relation))
|
||||
{
|
||||
ereport(ERROR, (errmsg("could not open relation with OID %u", relationId)));
|
||||
}
|
||||
|
||||
List *indexIdList = RelationGetIndexList(relation);
|
||||
Oid indexId = InvalidOid;
|
||||
foreach_oid(indexId, indexIdList)
|
||||
|
|
|
@ -469,6 +469,11 @@ GetExplicitStatisticsCommandList(Oid relationId)
|
|||
List *explicitStatisticsCommandList = NIL;
|
||||
|
||||
Relation relation = RelationIdGetRelation(relationId);
|
||||
if (!RelationIsValid(relation))
|
||||
{
|
||||
ereport(ERROR, (errmsg("could not open relation with OID %u", relationId)));
|
||||
}
|
||||
|
||||
List *statisticsIdList = RelationGetStatExtList(relation);
|
||||
RelationClose(relation);
|
||||
|
||||
|
@ -540,6 +545,11 @@ GetExplicitStatisticsSchemaIdList(Oid relationId)
|
|||
List *schemaIdList = NIL;
|
||||
|
||||
Relation relation = RelationIdGetRelation(relationId);
|
||||
if (!RelationIsValid(relation))
|
||||
{
|
||||
ereport(ERROR, (errmsg("could not open relation with OID %u", relationId)));
|
||||
}
|
||||
|
||||
List *statsIdList = RelationGetStatExtList(relation);
|
||||
RelationClose(relation);
|
||||
|
||||
|
|
|
@ -506,6 +506,11 @@ CreateFixPartitionShardIndexNamesTaskList(Oid parentRelationId, Oid partitionRel
|
|||
}
|
||||
|
||||
Relation parentRelation = RelationIdGetRelation(parentRelationId);
|
||||
if (!RelationIsValid(parentRelation))
|
||||
{
|
||||
ereport(ERROR, (errmsg("could not open relation with OID %u", parentRelationId)));
|
||||
}
|
||||
|
||||
List *parentIndexIdList = NIL;
|
||||
|
||||
if (parentIndexOid != InvalidOid)
|
||||
|
|
Loading…
Reference in New Issue