Fix CREATE SUBSCRIPTION failure when the publisher runs on pre-PG19. master github/master
authorFujii Masao <[email protected]>
Wed, 24 Dec 2025 14:43:30 +0000 (23:43 +0900)
committerFujii Masao <[email protected]>
Wed, 24 Dec 2025 14:45:19 +0000 (23:45 +0900)
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 <[email protected]>
Reviewed-by: Amit Kapila <[email protected]>
Reviewed-by: Hayato Kuroda <[email protected]>
Reviewed-by: Shlok Kyal <[email protected]>
Discussion: https://postgr.es/m/CAHGQGwEx4twHtJdiPWTyAXJhcBPLaH467SH2ajGSe-41m65giA@mail.gmail.com

src/backend/commands/subscriptioncmds.c

index 7b118a502006d27a8b32101d26c2ad57a9b2db9e..4efd4685abcab5756c27a237762fe5d1544a3721 100644 (file)
@@ -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);