Re: Support logical replication of DDLs

shveta malik <shveta.malik@gmail.com>

From: shveta malik <shveta.malik@gmail.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, "Wei Wang (Fujitsu)" <wangw.fnst@fujitsu.com>, "Yu Shi (Fujitsu)" <shiy.fnst@fujitsu.com>, vignesh C <vignesh21@gmail.com>, "Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>, Ajin Cherian <itsajin@gmail.com>, Runqi Tian <runqidev@gmail.com>, Peter Smith <smithpb2250@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, li jie <ggysxcq@gmail.com>, Dilip Kumar <dilipbalaut@gmail.com>, Alvaro Herrera <alvherre@alvh.no-ip.org>, Masahiko Sawada <sawada.mshk@gmail.com>, Japin Li <japinli@hotmail.com>, rajesh singarapu <rajesh.rs0541@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Zheng Li <zhengli10@gmail.com>, shveta malik <shveta.malik@gmail.com>
Date: 2023-06-30T07:06:07Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Add a run_as_owner option to subscriptions.

  2. Refactor pgoutput_change().

  3. Print the correct aliases for DML target tables in ruleutils.

  4. Fix object identity string for transforms

  5. Add grantable MAINTAIN privilege and pg_maintain role.

  6. Get rid of recursion-marker values in enum AlterTableType

  7. Release cache tuple when no longer needed

  8. Empty search_path in logical replication apply worker and walsender.

  9. Refactor format_type APIs to be more modular

  10. Use wrappers of PG_DETOAST_DATUM_PACKED() more.

Attachments

On Thu, Jun 22, 2023 at 9:39 AM shveta malik <shveta.malik@gmail.com> wrote:
>
> On Mon, Jun 19, 2023 at 3:04 PM Amit Kapila <amit.kapila16@gmail.com> wrote:
> >
> >
> > In insert_table_elements(), sometimes we access system twice for each
> > of the columns and this is to identify the above case where no
> > elements are present. Would it be better if simply for zero element
> > object array in this case and detect the same on the receiving side?
> > If this is feasible then we can simply name the function as
> > add_table_elems/add_table_elements. Also, in this context, can we
> > change the variable name telems to telems_present to make it bit easy
> > to follow.
>
> Modified telems to telems_present. I am reviewing the first part.
> Please allow some more time.
>

Fixed this. Now we always add table_elements array. If there are no
elements then it will be empty []. Regarding '()' around
table-elements, we take a call once we are done adding table-elements.
We peek into jsonb parse-state to figure out if we have actually added
anything and then decide what goes to "fmt" string. Different
scenarios are mentioned in code-comments in add_table_elems().

Apart from this, addressed below:

1) Fixed a bug where tables with serial columns (sequences) were not
replicated. Thanks Ajin for providing the fix.

2) Fixed a few more things:
a) Removed 'toJsonb' from all function names. Earlier it was this way
to distinguish from object-tree functions since we were maintaining
both the patches.
b) Renamed and moved a few helper functions which were not actually
for deparsing purposes to relevant files.
c) Removed role_to_jsonb_element(), 'myowner' can now be added like
any other key-value pair using new_jsonb_VA().
d) Optimized and refactored code at many places.
e) Improved/corrected comments.

The given patches do not include Vignesh's auto-generation work in
[1], but if there is interest from reviewers, we can rebase those as
well.

[1]: https://www.postgresql.org/message-id/CALDaNm0Rvv2EWOOQeGc_1j3b3ENceDRO8jd%2Bgbf0Y_J7d1FGGw%40mail.gmail.com

thanks
Shveta