From d1b35952da0fa94329b66f8a7768c61a416c6271 Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Wed, 24 Dec 2025 23:43:30 +0900 Subject: [PATCH] Fix CREATE SUBSCRIPTION failure when the publisher runs on pre-PG19. CREATE SUBSCRIPTION with copy_data=true and origin='none' previously failed when the publisher was running a version earlier than PostgreSQL 19, even though this combination should be supported. The failure occurred because the command issued a query calling pg_get_publication_sequences function on the publisher. That function does not exist before PG19 and the query is only needed for logical replication sequence synchronization, which is supported starting in PG19. This commit fixes this issue by skipping that query when the publisher runs a version earlier than PG19. Author: Fujii Masao Reviewed-by: Amit Kapila Reviewed-by: Hayato Kuroda Reviewed-by: Shlok Kyal Discussion: https://postgr.es/m/CAHGQGwEx4twHtJdiPWTyAXJhcBPLaH467SH2ajGSe-41m65giA@mail.gmail.com --- src/backend/commands/subscriptioncmds.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 7b118a5020..4efd4685ab 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -2649,9 +2649,11 @@ check_publications_origin_sequences(WalReceiverConn *wrconn, List *publications, /* * Enable sequence synchronization checks only when origin is 'none' , to * ensure that sequence data from other origins is not inadvertently - * copied. + * copied. This check is necessary if the publisher is running PG19 or + * later, where logical replication sequence synchronization is supported. */ - if (!copydata || pg_strcasecmp(origin, LOGICALREP_ORIGIN_NONE) != 0) + if (!copydata || pg_strcasecmp(origin, LOGICALREP_ORIGIN_NONE) != 0 || + walrcv_server_version(wrconn) < 190000) return; initStringInfo(&cmd);