aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/commands/publicationcmds.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c
index b85c3d7c611..0b8798e931e 100644
--- a/src/backend/commands/publicationcmds.c
+++ b/src/backend/commands/publicationcmds.c
@@ -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.
*/
static List *
@@ -509,11 +509,12 @@ OpenTableList(List *tables)
*/
foreach(lc, tables)
{
- RangeVar *rv = lfirst(lc);
- Relation rel;
+ RangeVar *rv = castNode(RangeVar, lfirst(lc));
bool recurse = rv->inh;
+ Relation rel;
Oid myrelid;
+ /* Allow query cancel in case this takes a long time */
CHECK_FOR_INTERRUPTS();
rel = heap_openrv(rv, ShareUpdateExclusiveLock);
@@ -531,13 +532,15 @@ OpenTableList(List *tables)
heap_close(rel, ShareUpdateExclusiveLock);
continue;
}
+
rels = lappend(rels, rel);
relids = lappend_oid(relids, myrelid);
+ /* Add children of this rel, if requested */
if (recurse)
{
- ListCell *child;
List *children;
+ ListCell *child;
children = find_all_inheritors(myrelid, ShareUpdateExclusiveLock,
NULL);
@@ -546,18 +549,15 @@ OpenTableList(List *tables)
{
Oid childrelid = lfirst_oid(child);
- if (list_member_oid(relids, childrelid))
- continue;
+ /* Allow query cancel in case this takes a long time */
+ CHECK_FOR_INTERRUPTS();
/*
* Skip duplicates if user specified both parent and child
* tables.
*/
if (list_member_oid(relids, childrelid))
- {
- heap_close(rel, ShareUpdateExclusiveLock);
continue;
- }
/* find_all_inheritors already got lock */
rel = heap_open(childrelid, NoLock);