Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6bc8193

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 4c6d6ac commit 6bc8193

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
@@ -484,7 +484,7 @@ RemovePublicationRelById(Oid proid)
484484
}
485485

486486
/*
487-
* Open relations based on provided by RangeVar list.
487+
* Open relations specified by a RangeVar list.
488488
* The returned tables are locked in ShareUpdateExclusiveLock mode.
489489
*/
490490
static List *
@@ -499,11 +499,12 @@ OpenTableList(List *tables)
499499
*/
500500
foreach(lc, tables)
501501
{
502-
RangeVar *rv = lfirst(lc);
503-
Relation rel;
502+
RangeVar *rv = castNode(RangeVar, lfirst(lc));
504503
bool recurse = rv->inh;
504+
Relation rel;
505505
Oid myrelid;
506506

507+
/* Allow query cancel in case this takes a long time */
507508
CHECK_FOR_INTERRUPTS();
508509

509510
rel = heap_openrv(rv, ShareUpdateExclusiveLock);
@@ -521,13 +522,15 @@ OpenTableList(List *tables)
521522
heap_close(rel, ShareUpdateExclusiveLock);
522523
continue;
523524
}
525+
524526
rels = lappend(rels, rel);
525527
relids = lappend_oid(relids, myrelid);
526528

529+
/* Add children of this rel, if requested */
527530
if (recurse)
528531
{
529-
ListCell *child;
530532
List *children;
533+
ListCell *child;
531534

532535
children = find_all_inheritors(myrelid, ShareUpdateExclusiveLock,
533536
NULL);
@@ -536,18 +539,15 @@ OpenTableList(List *tables)
536539
{
537540
Oid childrelid = lfirst_oid(child);
538541

539-
if (list_member_oid(relids, childrelid))
540-
continue;
542+
/* Allow query cancel in case this takes a long time */
543+
CHECK_FOR_INTERRUPTS();
541544

542545
/*
543546
* Skip duplicates if user specified both parent and child
544547
* tables.
545548
*/
546549
if (list_member_oid(relids, childrelid))
547-
{
548-
heap_close(rel, ShareUpdateExclusiveLock);
549550
continue;
550-
}
551551

552552
/* find_all_inheritors already got lock */
553553
rel = heap_open(childrelid, NoLock);

0 commit comments

Comments
 (0)