@@ -2711,8 +2711,7 @@ MergeAttributes(List *columns, const List *supers, char relpersistence,
2711
2711
RelationGetRelationName(relation))));
2712
2712
2713
2713
/* If existing rel is temp, it must belong to this session */
2714
- if (relation->rd_rel->relpersistence == RELPERSISTENCE_TEMP &&
2715
- !relation->rd_islocaltemp)
2714
+ if (RELATION_IS_OTHER_TEMP(relation))
2716
2715
ereport(ERROR,
2717
2716
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
2718
2717
errmsg(!is_partition
@@ -17230,15 +17229,13 @@ ATExecAddInherit(Relation child_rel, RangeVar *parent, LOCKMODE lockmode)
17230
17229
RelationGetRelationName(parent_rel))));
17231
17230
17232
17231
/* If parent rel is temp, it must belong to this session */
17233
- if (parent_rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP &&
17234
- !parent_rel->rd_islocaltemp)
17232
+ if (RELATION_IS_OTHER_TEMP(parent_rel))
17235
17233
ereport(ERROR,
17236
17234
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
17237
17235
errmsg("cannot inherit from temporary relation of another session")));
17238
17236
17239
17237
/* Ditto for the child */
17240
- if (child_rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP &&
17241
- !child_rel->rd_islocaltemp)
17238
+ if (RELATION_IS_OTHER_TEMP(child_rel))
17242
17239
ereport(ERROR,
17243
17240
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
17244
17241
errmsg("cannot inherit to temporary relation of another session")));
@@ -20309,15 +20306,13 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd,
20309
20306
RelationGetRelationName(rel))));
20310
20307
20311
20308
/* If the parent is temp, it must belong to this session */
20312
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP &&
20313
- !rel->rd_islocaltemp)
20309
+ if (RELATION_IS_OTHER_TEMP(rel))
20314
20310
ereport(ERROR,
20315
20311
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
20316
20312
errmsg("cannot attach as partition of temporary relation of another session")));
20317
20313
20318
20314
/* Ditto for the partition */
20319
- if (attachrel->rd_rel->relpersistence == RELPERSISTENCE_TEMP &&
20320
- !attachrel->rd_islocaltemp)
20315
+ if (RELATION_IS_OTHER_TEMP(attachrel))
20321
20316
ereport(ERROR,
20322
20317
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
20323
20318
errmsg("cannot attach temporary relation of another session as partition")));
0 commit comments