From: | vignesh C <vignesh21(at)gmail(dot)com> |
---|---|
To: | "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com> |
Cc: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Smith <smithpb2250(at)gmail(dot)com>, "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>, Greg Nancarrow <gregn4422(at)gmail(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>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Subject: | Re: Added schema level support for publication. |
Date: | 2021-09-17 11:57:31 |
Message-ID: | CALDaNm2Wk_6+XbO4mbnm1piC-5CTsK4ROrk1c+om0Bm4OnDr5g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Sep 16, 2021 at 8:59 AM houzj(dot)fnst(at)fujitsu(dot)com
<houzj(dot)fnst(at)fujitsu(dot)com> wrote:
>
> On Tuesday, September 14, 2021 4:39 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
> >
> > I have handled this in the patch attached.
>
> Thanks for updating the patch.
> Here are some comments.
>
> 1)
> +static void
> +AlterPublicationSchemas(AlterPublicationStmt *stmt, Relation rel,
> ...
> + /*
> + * If the table option was not specified remove the existing tables
> + * from the publication.
> + */
> + if (!tables)
> + {
> + rels = GetPublicationRelations(pubform->oid, PUBLICATION_PART_ROOT);
> + PublicationDropTables(pubform->oid, rels, false, true);
> + }
>
>
> It seems not natural to drop tables in AlterPublication*Schemas*,
> I think we'd better do it in AlterPublicationTables.
I felt keeping the current way keeps it better to avoid additional
checks. Thoughts?
> 2)
> static void
> AlterPublicationTables(AlterPublicationStmt *stmt, Relation rel,
> ...
> + /*
> + * If ALL TABLES IN SCHEMA option was not specified remove the
> + * existing schemas from the publication.
> + */
> + List *pubschemas = GetPublicationSchemas(pubid);
> + PublicationDropSchemas(pubform->oid, pubschemas, false);
>
> Same as 1), Is it better to modify the schema list in AlterPublicationSchemas ?
This is similar to above.
> 3)
> static void
> AlterPublicationTables(AlterPublicationStmt *stmt, Relation rel,
> ...
> /* check if the relation is member of the schema list specified */
> RelSchemaIsMemberOfSchemaList(rels, schemaidlist, false);
>
> IIRC, The check here is to check the specified tables and schemas in the
> command. Personally, this seems a common operation which can be placed in
> function AlterPublication(). If we move this check to AlterPublication() and if
> comment 1) and 2) makes sense to you, then we don't need the new function
> parameters in AlterPublicationTables() and AlterPublicationSchemas().
I felt we can keep the checks as is currently, else we will have to
extra checks outside and addition calls for conversion from oid to
Relation like:
if (stmt->options)
AlterPublicationOptions(pstate, stmt, rel, tup);
else
{
if (relations)
{
if (stmt->action != DEFELEM_DROP)
{
List *rels = OpenTableList(relations);
/* check if relation is member of the schema list specified */
RelSchemaIsMemberOfSchemaList(rels, schemaidlist, false);
CloseTableList(rels);
}
AlterPublicationTables(stmt, rel, tup, relations,
list_length(schemaidlist));
}
if (schemaidlist)
AlterPublicationSchemas(stmt, rel, tup, schemaidlist,
list_length(relations));
}
Thoughts?
Regards,
Vignesh
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2021-09-17 11:59:13 | Re: proposal: possibility to read dumped table's name from file |
Previous Message | Daniel Gustafsson | 2021-09-17 11:56:46 | Re: proposal: possibility to read dumped table's name from file |