Re: Added schema level support for publication.

From: vignesh C <vignesh21(at)gmail(dot)com>
To: Artur Zakirov <zaartur(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>, "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>, Rahila Syed <rahilasyed90(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Subject: Re: Added schema level support for publication.
Date: 2024-12-17 09:43:08
Message-ID: CALDaNm1ZHfZ9ET9fJxhLWCcSr0-hhi3R_sEupoLPzAWRLngujw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 16 Dec 2024 at 17:21, Artur Zakirov <zaartur(at)gmail(dot)com> wrote:
>
> On Mon, 16 Dec 2024 at 12:05, vignesh C <vignesh21(at)gmail(dot)com> wrote:
> > I prefer the other approach to remove both the checks in
> > getPublicationTables() and getPublicationNamespaces() which also makes
> > it consistent with the other case that Amit mentioned at [1].
>
> If I understand your suggestion correctly I think this will break the
> "--exclude-schema" option of pg_dump. That change will dump all
> mappings between publications and schemas for publications which are
> dumped.
>
> That solves the issue with special schemas, but restore will fail if
> some schemas were explicitly excluded. pg_dump will include in the
> dump ALTER PUBLICATION <pub> ADD TABLES IN SCHEMA <schema> even for
> those schemas which are not created during restore.

This is already the case in the existing implementation, so users
should not be surprised by the proposed change.
This can be reproduced with the following steps:
-- Create schema and user defined function in schema sch2
create schema sch2;
CREATE FUNCTION sch2.add1(integer, integer)
RETURNS integer
LANGUAGE sql IMMUTABLE STRICT
AS $_$select $1 + $2;$_$;

-- Create a view which references user defined function of a different schema
create schema sch1;
CREATE TABLE sch1.t1 (c1 integer, c2 integer);
CREATE VIEW sch1.v1 AS SELECT c1 FROM sch1.t1 WHERE (sch2.add1(c1, c2) >= 10);

-- Exclude schema sch2 which has the user defined function while dumping
./pg_dump -d postgres -N sch2

You will notice that the schema sch2 and the user defined function in
schema sch2 will not be dumped.

Regards,
Vignesh

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2024-12-17 10:04:47 Re: UUID v7
Previous Message Bertrand Drouvot 2024-12-17 09:35:37 Re: per backend I/O statistics