@@ -2711,8 +2711,7 @@ MergeAttributes(List *columns, const List *supers, char relpersistence,
27112711 RelationGetRelationName(relation))));
27122712
27132713 /* 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))
27162715 ereport(ERROR,
27172716 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
27182717 errmsg(!is_partition
@@ -17230,15 +17229,13 @@ ATExecAddInherit(Relation child_rel, RangeVar *parent, LOCKMODE lockmode)
1723017229 RelationGetRelationName(parent_rel))));
1723117230
1723217231 /* 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))
1723517233 ereport(ERROR,
1723617234 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
1723717235 errmsg("cannot inherit from temporary relation of another session")));
1723817236
1723917237 /* 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))
1724217239 ereport(ERROR,
1724317240 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
1724417241 errmsg("cannot inherit to temporary relation of another session")));
@@ -20309,15 +20306,13 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd,
2030920306 RelationGetRelationName(rel))));
2031020307
2031120308 /* 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))
2031420310 ereport(ERROR,
2031520311 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
2031620312 errmsg("cannot attach as partition of temporary relation of another session")));
2031720313
2031820314 /* Ditto for the partition */
20319- if (attachrel->rd_rel->relpersistence == RELPERSISTENCE_TEMP &&
20320- !attachrel->rd_islocaltemp)
20315+ if (RELATION_IS_OTHER_TEMP(attachrel))
2032120316 ereport(ERROR,
2032220317 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
2032320318 errmsg("cannot attach temporary relation of another session as partition")));
0 commit comments