* RelationGetPartitionKey -- get partition key, if relation is partitioned * * Note: partition keys are not allowed to change after the partitioned rel * is created. RelationClearRelation knows this and preserves rd_partkey * across relcache rebuilds, as long as the relation is open. Therefore, * even though we hand back a direct pointer into the relcache entry, it's * safe for callers to
| 51 | * the relation open. |
| 52 | */ |
| 53 | PartitionKey |
| 54 | RelationGetPartitionKey(Relation rel) |
| 55 | { |
| 56 | if (rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE) |
| 57 | return NULL; |
| 58 | |
| 59 | if (unlikely(rel->rd_partkey == NULL)) |
| 60 | RelationBuildPartitionKey(rel); |
| 61 | |
| 62 | return rel->rd_partkey; |
| 63 | } |
| 64 | |
| 65 | /* |
| 66 | * RelationBuildPartitionKey |
no test coverage detected