Two issues with version checks in CREATE SUBSCRIPTION
Fujii Masao <masao.fujii@gmail.com>
From: Fujii Masao <masao.fujii@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-22T17:26:42Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix CREATE SUBSCRIPTION failure when the publisher runs on pre-PG19.
- d1b35952da0f 19 (unreleased) landed
-
Fix version check for retain_dead_tuples subscription option.
- 5e813edb55ed 19 (unreleased) landed
Attachments
- v1-0001-Fix-version-check-for-retain_dead_tuples-subscrip.patch (application/octet-stream) patch v1-0001
- v1-0002-Avoid-calling-pg_get_publication_sequences-on-pre.patch (application/octet-stream) patch v1-0002
Hi,
While looking at subscription-related code, I noticed two issues related to
version checks.
if (walrcv_server_version(wrconn) < 19000)
ereport(ERROR,
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("cannot enable retain_dead_tuples if the
publisher is running a version earlier than PostgreSQL 19"));
First, in subscriptioncmds.c this check rejects enabling retain_dead_tuples
when the publisher is running an older version. However, the comparison uses
19000 as v19 value. Since server versions are encoded as 190000 for v19,
this appears to be a typo and allows the option to be enabled unexpectedly
on pre-v19 publishers. The attached 0001 patch fixes this by correcting
the version constant.
Second, CREATE SUBSCRIPTION with copy_data=true and origin='none' currently
fails when the publisher is running a version earlier than v19, although
this combination should be supported. The failure occurs because the command
issues a query calling pg_get_publication_sequences on the publisher,
which does not exist before v19. The attached 0002 patch fixes this
by skipping that query when the publisher runs an older version.
Thoughts?
Regards,
--
Fujii Masao