fetch_relation_list.diffs
application/octet-stream
Filename: fetch_relation_list.diffs
Type: application/octet-stream
Part: 0
Message:
RE: Logical Replication of sequences
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index ec5268954f0..e71c0c62b5f 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -2596,25 +2596,8 @@ fetch_relation_list(WalReceiverConn *wrconn, List *publications)
/* Build the pub_names comma-separated string. */
GetPublicationsStr(publications, pub_names, true);
- /* Get the list of tables and sequences from the publisher. */
- if (server_version >= 190000)
- {
- tableRow[2] = INT2VECTOROID;
-
- appendStringInfo(&cmd, "SELECT DISTINCT n.nspname, c.relname, gpt.attrs\n"
- " FROM pg_class c\n"
- " JOIN pg_namespace n ON n.oid = c.relnamespace\n"
- " JOIN ( SELECT (pg_get_publication_tables(VARIADIC array_agg(pubname::text))).*\n"
- " FROM pg_publication\n"
- " WHERE pubname IN (%s)) AS gpt\n"
- " ON gpt.relid = c.oid\n"
- " UNION ALL\n"
- " SELECT DISTINCT s.schemaname, s.sequencename, NULL::int2vector AS attrs\n"
- " FROM pg_catalog.pg_publication_sequences s\n"
- " WHERE s.pubname IN (%s)",
- pub_names->data, pub_names->data);
- }
- else if (server_version >= 160000)
+ /* Get the list of relations from the publisher */
+ if (server_version >= 160000)
{
tableRow[2] = INT2VECTOROID;
@@ -2639,6 +2622,19 @@ fetch_relation_list(WalReceiverConn *wrconn, List *publications)
" WHERE pubname IN ( %s )) AS gpt\n"
" ON gpt.relid = c.oid\n",
pub_names->data);
+
+ if (server_version >= 190000)
+ {
+ /*
+ * From version 19, we allowed to include sequences in the target.
+ */
+ appendStringInfo(&cmd,
+ "UNION ALL\n"
+ " SELECT DISTINCT s.schemaname, s.sequencename, NULL::int2vector AS attrs\n"
+ " FROM pg_catalog.pg_publication_sequences s\n"
+ " WHERE s.pubname IN (%s)",
+ pub_names->data);
+ }
}
else
{