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