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 665d1fad9). 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
This commit is contained in:
parent
eeee62d805
commit
9286ef8e91
@ -494,7 +494,7 @@ RemovePublicationRelById(Oid proid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open relations based on provided by RangeVar list.
|
* Open relations specified by a RangeVar list.
|
||||||
* The returned tables are locked in ShareUpdateExclusiveLock mode.
|
* The returned tables are locked in ShareUpdateExclusiveLock mode.
|
||||||
*/
|
*/
|
||||||
static List *
|
static List *
|
||||||
@ -509,11 +509,12 @@ OpenTableList(List *tables)
|
|||||||
*/
|
*/
|
||||||
foreach(lc, tables)
|
foreach(lc, tables)
|
||||||
{
|
{
|
||||||
RangeVar *rv = lfirst(lc);
|
RangeVar *rv = castNode(RangeVar, lfirst(lc));
|
||||||
Relation rel;
|
|
||||||
bool recurse = rv->inh;
|
bool recurse = rv->inh;
|
||||||
|
Relation rel;
|
||||||
Oid myrelid;
|
Oid myrelid;
|
||||||
|
|
||||||
|
/* Allow query cancel in case this takes a long time */
|
||||||
CHECK_FOR_INTERRUPTS();
|
CHECK_FOR_INTERRUPTS();
|
||||||
|
|
||||||
rel = heap_openrv(rv, ShareUpdateExclusiveLock);
|
rel = heap_openrv(rv, ShareUpdateExclusiveLock);
|
||||||
@ -531,13 +532,15 @@ OpenTableList(List *tables)
|
|||||||
heap_close(rel, ShareUpdateExclusiveLock);
|
heap_close(rel, ShareUpdateExclusiveLock);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
rels = lappend(rels, rel);
|
rels = lappend(rels, rel);
|
||||||
relids = lappend_oid(relids, myrelid);
|
relids = lappend_oid(relids, myrelid);
|
||||||
|
|
||||||
|
/* Add children of this rel, if requested */
|
||||||
if (recurse)
|
if (recurse)
|
||||||
{
|
{
|
||||||
ListCell *child;
|
|
||||||
List *children;
|
List *children;
|
||||||
|
ListCell *child;
|
||||||
|
|
||||||
children = find_all_inheritors(myrelid, ShareUpdateExclusiveLock,
|
children = find_all_inheritors(myrelid, ShareUpdateExclusiveLock,
|
||||||
NULL);
|
NULL);
|
||||||
@ -546,18 +549,15 @@ OpenTableList(List *tables)
|
|||||||
{
|
{
|
||||||
Oid childrelid = lfirst_oid(child);
|
Oid childrelid = lfirst_oid(child);
|
||||||
|
|
||||||
if (list_member_oid(relids, childrelid))
|
/* Allow query cancel in case this takes a long time */
|
||||||
continue;
|
CHECK_FOR_INTERRUPTS();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Skip duplicates if user specified both parent and child
|
* Skip duplicates if user specified both parent and child
|
||||||
* tables.
|
* tables.
|
||||||
*/
|
*/
|
||||||
if (list_member_oid(relids, childrelid))
|
if (list_member_oid(relids, childrelid))
|
||||||
{
|
|
||||||
heap_close(rel, ShareUpdateExclusiveLock);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
/* find_all_inheritors already got lock */
|
/* find_all_inheritors already got lock */
|
||||||
rel = heap_open(childrelid, NoLock);
|
rel = heap_open(childrelid, NoLock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user