postgres_fdw: IMPORT FOREIGN SCHEMA ... LIMIT TO (partition) - Mailing list pgsql-hackers

From Matthias van de Meent
Subject postgres_fdw: IMPORT FOREIGN SCHEMA ... LIMIT TO (partition)
Date
Msg-id CAEze2Whwg4i=mzApMe+PXxCEfgoZmHGqdqQFW7J4bmj_5p6t1A@mail.gmail.com
Whole thread Raw
Responses Re: postgres_fdw: IMPORT FOREIGN SCHEMA ... LIMIT TO (partition)  (Bernd Helmle <mailings@oopsware.de>)
List pgsql-hackers
Hi,

Recently I was trying to copy some of the data of one database to
another through postgres_fdw, and found that it wouldn't import that
partition through IMPORT FOREIGN SCHEMA, even when I explicitly
specified the name of the table that contained the data in the LIMIT
TO clause.

I realised the reason is that currently, postgres_fdw explicitly
disallows importing foreign partitions. This is a reasonable default
when importing a whole schema, but if I wanted to explicitly import
one of a partitioned tables' partitions, that would now require me to
manually copy the foreign table's definitions through the use of
CREATE FOREIGN TABLE, which is a hassle and prone to mistakes.

As such, I propose the attached patch, in which the 'no
partitions'-restriction of postgres_fdw is lifted for the LIMIT TO
clause. This has several benefits, including not holding locks on the
foreign root partition during queries, and less suprising behaviour
for LIMIT TO ("table that happens to be a partition").

Regards,

Matthias van de Meent

Attachment

pgsql-hackers by date:

Previous
From: Amul Sul
Date:
Subject: Re: [Patch] ALTER SYSTEM READ ONLY
Next
From: Denis Laxalde
Date:
Subject: [PATCH] Disable bgworkers during servers start in pg_upgrade