From d40b463def29cdded18579d6e584cb9f5f4764d6 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 25 Mar 2021 12:00:35 +0100 Subject: [PATCH 3/6] fixup! Row filter for logical replication Use more idiomatic style for checking for empty or nonempty lists. --- src/backend/replication/logical/tablesync.c | 4 ++-- src/backend/replication/pgoutput/pgoutput.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c index 246510c82e..c3d6847b35 100644 --- a/src/backend/replication/logical/tablesync.c +++ b/src/backend/replication/logical/tablesync.c @@ -881,7 +881,7 @@ copy_table(Relation rel) initStringInfo(&cmd); /* Regular table with no row filter */ - if (lrel.relkind == RELKIND_RELATION && list_length(qual) == 0) + if (lrel.relkind == RELKIND_RELATION && qual == NIL) appendStringInfo(&cmd, "COPY %s TO STDOUT", quote_qualified_identifier(lrel.nspname, lrel.relname)); else @@ -902,7 +902,7 @@ copy_table(Relation rel) appendStringInfo(&cmd, " FROM %s", quote_qualified_identifier(lrel.nspname, lrel.relname)); /* list of AND'ed filters */ - if (list_length(qual) > 0) + if (qual != NIL) { ListCell *lc; bool first = true; diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index 6151f34925..593a8c96c8 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -568,7 +568,7 @@ pgoutput_row_filter(Relation relation, HeapTuple oldtuple, HeapTuple newtuple, L bool result = true; /* Bail out if there is no row filter */ - if (list_length(rowfilter) == 0) + if (rowfilter == NIL) return true; elog(DEBUG3, "table \"%s.%s\" has row filter", @@ -1372,7 +1372,7 @@ rel_sync_cache_publication_cb(Datum arg, int cacheid, uint32 hashvalue) entry->pubactions.pubdelete = false; entry->pubactions.pubtruncate = false; - if (list_length(entry->qual) > 0) + if (entry->qual != NIL) list_free_deep(entry->qual); entry->qual = NIL; } -- 2.30.2