Re: [19] CREATE SUBSCRIPTION ... SERVER

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Joe Conway <mail(at)joeconway(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [19] CREATE SUBSCRIPTION ... SERVER
Date: 2026-03-14 22:55:29
Message-ID: 7eb0c03b4312b32cb76d340023b39a751745a1f9.camel@j-davis.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 2026-03-06 at 21:49 +0530, Ashutosh Bapat wrote:

> I don't think we need a separate ForeignServerName function. In
> AlterSubscription() we already have ForeignSever object which has
> server name in it. Other two callers invoke
> ForeignServerConnectionString() which in turn fetches ForeignServer
> object. Those callers instead may fetch ForeignServer object
> themselves and pass it to ForeignServerConnectionString() and use it
> in the error message.

Done.

> The patch has changes to pg_dump.c but there is no corresponding
> test.
> But I don't think we need a separate test. If the objects created in
> regress/*.sql tests are not dropped, 002_pg_upgrade.pl would test
> dump/restore of subscriptions with server.

It seems that foreign_data.sql expects there to be zero FDWs, servers,
and user mappings, so it's not quite that simple. I'm not entirely sure
why that is, but I suppose it's meant to be tested in 002_pg_dump.pl
instead.

I wrote the tests there (attached), which revealed that CREATE FOREIGN
DATA WRAPPER ... CONNECTION wasn't being dumped properly. I attached a
separate fix for that.

Unfortunately I don't think we can rely on regress.so being available
when 002_pg_dump.pl runs. Do you have an idea how I can effectively
test the FDW (which is needed to test the server and subscription)? I
suppose I could make it a built-in function, and that wouldn't be so
bad, but not ideal. Right now this test is failing for CI on debian
autoconf.

> I think we need tests for testing changes in connection when ALTER
> SUBSCRIPTION ... SERVER is executed and also those for switching
> between SERVER and CONNECTION.

Done.

Attached series including patches to address Andres's and Amit's
comments, too.

Thank you!

Regards,
Jeff Davis

Attachment Content-Type Size
v22-0001-Clean-up-postgres_fdw-t-010_subscription.pl.patch text/x-patch 3.0 KB
v22-0002-ALTER-SUBSCRIPTION-.-SERVER-test.patch text/x-patch 2.9 KB
v22-0003-Temp-context-for-maybe_reread_subscription.patch text/x-patch 6.9 KB
v22-0004-Refactor-to-remove-ForeignServerName.patch text/x-patch 7.3 KB
v22-0005-Fix-pg_dump-for-CREATE-FOREIGN-DATA-WRAPPER-.-CO.patch text/x-patch 2.9 KB
v22-0006-Add-pg_dump-tests-related-to-CREATE-SUBSCRIPTION.patch text/x-patch 3.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2026-03-14 22:57:50 Re: [19] CREATE SUBSCRIPTION ... SERVER
Previous Message KAZAR Ayoub 2026-03-14 22:43:38 Re: Speed up COPY TO text/CSV parsing using SIMD