v19-0001-PS-tmp-OpenTableList-IsA-logic.patch

application/octet-stream

Filename: v19-0001-PS-tmp-OpenTableList-IsA-logic.patch
Type: application/octet-stream
Part: 0
Message: Re: row filtering for logical replication

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v19-0001
Subject: PS - tmp - OpenTableList IsA logic
File+
src/backend/commands/publicationcmds.c 10 10
From 5b3c45f8e7c32d3bf3e53b9874d0c12a4fdc9ac2 Mon Sep 17 00:00:00 2001
From: Peter Smith <peter.b.smith@fujitsu.com>
Date: Fri, 16 Jul 2021 12:23:39 +1000
Subject: [PATCH v19] PS - tmp - OpenTableList IsA logic

Since all elements of the list must be same kind only really need to
check the initial element kind, not every element.
---
 src/backend/commands/publicationcmds.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c
index 659f448..c323490 100644
--- a/src/backend/commands/publicationcmds.c
+++ b/src/backend/commands/publicationcmds.c
@@ -504,6 +504,14 @@ OpenTableList(List *tables)
 	List	   *rels = NIL;
 	ListCell   *lc;
 	PublicationRelationInfo *pri;
+	bool		whereclause;
+
+	/*
+	 * ALTER PUBLICATION ... ADD TABLE provides a PublicationTable List
+	 * (Relation, Where clause). ALTER PUBLICATION ... DROP TABLE provides
+	 * a Relation List. Check the List element to be used.
+	 */
+	whereclause = IsA(linitial(tables), PublicationTable);
 
 	/*
 	 * Open, share-lock, and check all the explicitly-specified relations
@@ -515,17 +523,9 @@ OpenTableList(List *tables)
 		bool		recurse;
 		Relation	rel;
 		Oid			myrelid;
-		bool		whereclause;
 
-		/*
-		 * ALTER PUBLICATION ... ADD TABLE provides a PublicationTable List
-		 * (Relation, Where clause). ALTER PUBLICATION ... DROP TABLE provides
-		 * a Relation List. Check the List element to be used.
-		 */
-		if (IsA(lfirst(lc), PublicationTable))
-			whereclause = true;
-		else
-			whereclause = false;
+		/* Assert all list elements must be of same kind. */
+		Assert(whereclause == IsA(lfirst(lc), PublicationTable));
 
 		if (whereclause)
 		{
-- 
1.8.3.1