Skip to content

Commit aaf7b3b

Browse files
committed
Clean up sloppy coding in publicationcmds.c's OpenTableList().
Remove dead code (which would be incorrect if it weren't dead), per report from Pan Bian. Add a CHECK_FOR_INTERRUPTS in the inner loop over child relations, because there's little point in having one in the outer loop if there's not one here too. Minor stylistic adjustments and comment improvements. Seems to be aboriginal to this code (cf commit 665d1fa). Back-patch to v10 where that came in, not because any of this is significant, but just to keep the branches looking similar. Discussion: https://postgr.es/m/15539-06d00ef6b1e2e1bb@postgresql.org
1 parent 6dc46f8 commit aaf7b3b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/backend/commands/publicationcmds.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ RemovePublicationRelById(Oid proid)
470470
}
471471

472472
/*
473-
* Open relations based on provided by RangeVar list.
473+
* Open relations specified by a RangeVar list.
474474
* The returned tables are locked in ShareUpdateExclusiveLock mode.
475475
*/
476476
static List *
@@ -485,11 +485,12 @@ OpenTableList(List *tables)
485485
*/
486486
foreach(lc, tables)
487487
{
488-
RangeVar *rv = lfirst(lc);
489-
Relation rel;
488+
RangeVar *rv = castNode(RangeVar, lfirst(lc));
490489
bool recurse = rv->inh;
490+
Relation rel;
491491
Oid myrelid;
492492

493+
/* Allow query cancel in case this takes a long time */
493494
CHECK_FOR_INTERRUPTS();
494495

495496
rel = heap_openrv(rv, ShareUpdateExclusiveLock);
@@ -507,13 +508,15 @@ OpenTableList(List *tables)
507508
heap_close(rel, ShareUpdateExclusiveLock);
508509
continue;
509510
}
511+
510512
rels = lappend(rels, rel);
511513
relids = lappend_oid(relids, myrelid);
512514

515+
/* Add children of this rel, if requested */
513516
if (recurse)
514517
{
515-
ListCell *child;
516518
List *children;
519+
ListCell *child;
517520

518521
children = find_all_inheritors(myrelid, ShareUpdateExclusiveLock,
519522
NULL);
@@ -522,18 +525,15 @@ OpenTableList(List *tables)
522525
{
523526
Oid childrelid = lfirst_oid(child);
524527

525-
if (list_member_oid(relids, childrelid))
526-
continue;
528+
/* Allow query cancel in case this takes a long time */
529+
CHECK_FOR_INTERRUPTS();
527530

528531
/*
529532
* Skip duplicates if user specified both parent and child
530533
* tables.
531534
*/
532535
if (list_member_oid(relids, childrelid))
533-
{
534-
heap_close(rel, ShareUpdateExclusiveLock);
535536
continue;
536-
}
537537

538538
/* find_all_inheritors already got lock */
539539
rel = heap_open(childrelid, NoLock);

0 commit comments

Comments
 (0)