Re: pgsql: CREATE SUBSCRIPTION ... SERVER. - Mailing list pgsql-committers

From Jeff Davis
Subject Re: pgsql: CREATE SUBSCRIPTION ... SERVER.
Date
Msg-id 03d52b80fd264bb683fb2c46ad7a2934cb656f1a.camel@j-davis.com
Whole thread Raw
In response to Re: pgsql: CREATE SUBSCRIPTION ... SERVER.  (Andres Freund <andres@anarazel.de>)
Responses Re: pgsql: CREATE SUBSCRIPTION ... SERVER.
Re: pgsql: CREATE SUBSCRIPTION ... SERVER.
List pgsql-committers
On Wed, 2026-03-11 at 17:49 -0400, Andres Freund wrote:
> The only reason connection_text needs to be volatile is because it's
> modified
> in PG_TRY and then accessed in PG_FINALLY.  But what's the point of
> the
> latter? If an error was thrown, why would we want to construct the
> 'result'
> string, as the error isn't caught, there's no PG_CATCH.  So now the
> function
> builds the result string in case of an error, just to throw it away.

I believe it would be correct if the variable was not volatile at all,
because it's only set in the last statement of PG_TRY(), so the
PG_FINALLY() will never need to read the modified variable on the error
path. I added the volatile to follow the expected pattern, in case the
code is adjusted later.

That leaves some awkwardness, but I don't immediately see a cleaner way
to do it. Suggestions welcome.

> I'm also rather unconvinced by ForeignServerConnectionString()
> creating a
> temporary memory context. When would you ever use the function in a
> long lived
> memory context?

It's called by GetSubscription(), and the context is ApplyContext.

Regards,
    Jeff Davis




pgsql-committers by date:

Previous
From: Richard Guo
Date:
Subject: pgsql: Convert NOT IN sublinks to anti-joins when safe
Next
From: Michael Paquier
Date:
Subject: pgsql: Use streaming read for VACUUM cleanup of GIN