Make more use of RELATION_IS_OTHER_TEMP(). · postgres/postgres@bb10938 · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Commit bb10938

Browse files
Make more use of RELATION_IS_OTHER_TEMP().
A few places were open-coding it instead of using this handy macro. Author: Junwang Zhao <zhjwpku@gmail.com> Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> Discussion: https://postgr.es/m/CAEG8a3LjTGJcOcxQx-SUOGoxstG4XuCWLH0ATJKKt_aBTE5K8w%40mail.gmail.com
1 parent fe07100 commit bb10938

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/backend/commands/tablecmds.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.