RE: Added schema level support for publication.
Zhijie Hou (Fujitsu) <houzj.fnst@fujitsu.com>
From: "houzj.fnst@fujitsu.com" <houzj.fnst@fujitsu.com>
To: vignesh C <vignesh21@gmail.com>
Cc: Greg Nancarrow <gregn4422@gmail.com>, Ajin Cherian <itsajin@gmail.com>, Rahila Syed <rahilasyed90@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>, "tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com>
Date: 2021-07-30T06:42:43Z
Lists: pgsql-hackers
On July 28, 2021 6:44 PM vignesh C <vignesh21@gmail.com> wrote:
> Thanks for the patch, I have merged the changes. Attached v16 patch has the
> fixes for the same.
Thanks for the new version patches.
Here are a few comments:
1)
+ /* Identify which schemas should be dropped */
+ foreach(oldlc, oldschemaids)
+ {
+ Oid oldschemaid = lfirst_oid(oldlc);
+
+ if (!list_member_oid(schemaoidlist, oldschemaid))
+ delschemas = lappend_oid(delschemas, oldschemaid);
+ }
+
We can use list_difference here to simplify the code.
2)
+
+ /* Filter out duplicates if user specifies "sch1, sch1" */
+ if (list_member_oid(schemaoidlist, schemaoid))
+ continue;
+
+ schemaoidlist = lappend_oid(schemaoidlist, schemaoid);
It might be more concise to use list_append_unique_oid() here.
3)
+ <para>
+ Create a publication that publishes all changes for all the tables present in
+the schema "production":
+<programlisting>
The second line seems not aligned.
After:
+ <para>
+ Create a publication that publishes all changes for all the tables present in
+ the schema "production":
+<programlisting>
4)
+ resetPQExpBuffer(query);
+
+ /* Get the publication membership for the schema */
+ appendPQExpBuffer(query,
+ "SELECT ps.psnspcid, ps.oid, p.pubname, p.oid AS pubid "
+ "FROM pg_publication_schema ps, pg_publication p "
+ "WHERE ps.psnspcid = '%u' "
+ "AND p.oid = ps.pspubid",
+ nsinfo->dobj.catId.oid);
It seems we can use printfPQExpBuffer() here which is a convenience routine
that does the same thing as resetPQExpBuffer() followed by appendPQExpBuffer().
Best regards,
Houzj
Commits
-
Include schema/table publications even with exclude options in dump.
- 4aa6fa3cd0a2 18.0 landed
-
Rename some enums to use TABLE instead of REL.
- b3812d0b9bcf 15.0 landed
-
Add tap tests for the schema publications.
- 6b0f6f79eef2 15.0 landed
-
Allow publishing the tables of schema.
- 5a2832465fd8 15.0 landed
-
In pg_dump, use simplehash.h to look up dumpable objects by OID.
- 92316a4582a5 15.0 cited