Re: [Patch] add new parameter to pg_replication_origin_session_setup

Amit Kapila <amit.kapila16@gmail.com>

From: Amit Kapila <amit.kapila16@gmail.com>
To: Heikki Linnakangas <hlinnaka@iki.fi>
Cc: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>, shveta malik <shveta.malik@gmail.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>, "Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>, Doruk Yilmaz <doruk@mixrank.com>
Date: 2026-02-16T08:52:57Z
Lists: pgsql-hackers
On Wed, Feb 11, 2026 at 10:53 AM Amit Kapila <amit.kapila16@gmail.com> wrote:
>
> On Wed, Feb 4, 2026 at 12:38 AM Heikki Linnakangas <hlinnaka@iki.fi> wrote:
> >
> > The new error message is not great:
> >
> > postgres=# select pg_replication_origin_session_setup('myorigin', 12345678);
> > ERROR:  could not find replication state slot for replication origin
> > with OID 1 which was acquired by 12345678
> >
> > Firstly, replication origin is not an OID. Secondly, it's a little
> > confusing because the "replication state slot" is in fact present.
> > However, it's currently inactive, i.e. not "acquired" by the given PID.
> >
> > I propose to change that to:
> >
> > postgres=# select pg_replication_origin_session_setup('myorigin', 12345678);
> > ERROR:  replication origin with ID 1 is not active for PID 12345678
> >
> > That's more in line with this neighboring message:
> >
> > ERROR:  replication origin with ID 1 is already active for PID 701228
> >
>
> +1 for the new message.
>

Heikki, would you like to take care of improvements proposed by you?
Otherwise, I am happy to take care of them.

-- 
With Regards,
Amit Kapila.



Commits

  1. Refactor replorigin_session_setup() for better readability.

  2. Prevent unintended dropping of active replication origins.

  3. Add optional pid parameter to pg_replication_origin_session_setup().