Re: Allow GUC settings in CREATE SUBSCRIPTION CONNECTION to take effect

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Allow GUC settings in CREATE SUBSCRIPTION CONNECTION to take effect
Date: 2025-12-19 07:55:19
Message-ID: CAHGQGwEs08VO8SFFbp+4d=ktqh0K66rXWmqL4ea59iSn24ykLg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Dec 3, 2025 at 2:45 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> On Tue, Dec 2, 2025 at 8:30 PM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> >
> > On Tue, Dec 2, 2025 at 9:08 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> > > Is it possible that we append the predefined options to the options
> > > given by the user to avoid extra round-trip?
> >
> > One idea is to add a function, similar to libpqrcv_get_dbname_from_conninfo()
> > in libpqwalreceiver.c, that extracts the options string from the conninfo,
> > to append the required fixed settings, and then to use the combined string as
> > the value of the options parameter.
> >
>
> Yes, but libpqrcv_get_dbname_from_conninfo() is an exposed function,
> we can implement something internal for libpqwalreceiver.c like
> conninfo_add_defaults() present in fe-connect.c.
>
> > Do you think implementing this is worthwhile
> > to avoid the extra round trip?
> >
>
> I think so. Today, we have three variables, tomorrow there could be
> more such variables as well and apart from avoiding extra round trips,
> the idea to append options to provided options (if any) sounds more
> logical to me.

OK, I've implemented the idea discussed upthread. The patch updates
libpqrcv_connect() so that, for logical replication, it extracts the options
string from the conninfo, appends the required fixed settings, and passes
the combined string as the options parameter to libpq.

For example, if the conninfo specifies -c wal_sender_timeout=10s,
the resulting options value becomes:

-c wal_sender_timeout=10s -c datestyle=ISO -c
intervalstyle=postgres -c extra_float_digits=3.

Patch attached.

Regards,

--
Fujii Masao

Attachment Content-Type Size
v5-0001-PG15-PG16-Honor-GUC-settings-specified-in-CREATE-SUBSCRIPTI.txt text/plain 5.6 KB
v5-0002-Add-TAP-test-for-GUC-settings-passed-via-CONNECTI.patch application/octet-stream 3.1 KB
v5-0001-Honor-GUC-settings-specified-in-CREATE-SUBSCRIPTI.patch application/octet-stream 5.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2025-12-19 08:08:39 Re: Improve logical replication usability when tables lack primary keys
Previous Message Bertrand Drouvot 2025-12-19 07:51:06 Re: Report bytes and transactions actually sent downtream