Re: Added schema level support for publication.

From: Rahila Syed <rahilasyed90(at)gmail(dot)com>
To: Greg Nancarrow <gregn4422(at)gmail(dot)com>
Cc: vignesh C <vignesh21(at)gmail(dot)com>, "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>, Ajin Cherian <itsajin(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: 2021-07-21 09:44:23
Message-ID: CAH2L28vxRLmiyZezO6DdNx-QQzGz-Ddq2=ZCYizE1y4jUkNhVA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 19, 2021 at 2:41 PM Greg Nancarrow <gregn4422(at)gmail(dot)com> wrote:

> On Fri, Jul 16, 2021 at 8:13 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
> >
> > Modified.
> >
> > Thanks for the comments, these issues are fixed as part of the v12 patch
> posted at [1].
> > [1] -
> https://www.postgresql.org/message-id/CALDaNm3V9ny5dJM8nofLGJ3zDuDG0gS2dX%2BAhDph--U5y%2B4VbQ%40mail.gmail.com
> >
>
> There seems to be a problem with ALTER PUBLICATION ... SET TABLE ...
> After that command, it still regards it as an empty (e) publication,
> so I can then ALTER PUBLICATION ... ADD SCHEMA ...
>
>
One issue here is that the code to update publication type is missing
in AlterPublicationTables for SET TABLE command.

More broadly, I am not clear about the behaviour of the patch when a
publication is created to publish only certain tables, and is later altered
to publish
a whole schema. I think such behaviour is legitimate. However,
AFAIU as per current code we can't update the publication type
from PUBTYPE_TABLE to PUBTYPE_SCHEMA.

I have some review comments as follows:
1.
In ConvertSchemaSpecListToOidList(List *schemas) function:
+ search_path = fetch_search_path(false);
+ nspname =
get_namespace_name(linitial_oid(search_path));
+ if (nspname == NULL) /*
recently-deleted namespace? */
+ ereport(ERROR,
+
errcode(ERRCODE_UNDEFINED_SCHEMA),
+ errmsg("no schema
has been selected"));
+
+ schemoid = get_namespace_oid(nspname,
false);
+ break;

The call get_namespace_oid() is perhaps not needed as fetch_search_path
already fetches oids and simply
doing Schema oid = liinital_oid(search_path)); should be enough.

2. In the same function should there be an if else condition block instead
of a switch case as
there are only two cases.

Thank you,
Rahila Syed

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-07-21 09:58:59 Re: Have I found an interval arithmetic bug?
Previous Message Richard Guo 2021-07-21 09:07:28 Re: Using each rel as both outer and inner for JOIN_ANTI