Re: Move replication slot structures/enums/macros to a new header file for better usability by external tools/modules

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Move replication slot structures/enums/macros to a new header file for better usability by external tools/modules
Date: 2022-02-10 04:21:29
Message-ID: CALj2ACXZ8L_n-Kn-GvN0wFV_ZMwB4cTKuZtONd3BZz2qtuNRiA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Feb 9, 2022 at 2:16 AM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>
> On Mon, Feb 7, 2022 at 4:22 PM Bharath Rupireddy
> <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
> >
> > Hi,
> >
> > While working on pg_replslotdata tool [1], it was observed that some
> > of the replication slot structures/enums/macros such as
> > ReplicationSlotPersistentData, ReplicationSlotPersistency,
> > ReplicationSlotOnDisk, ReplicationSlotOnDiskXXXX etc. are currently in
> > replication/slot.h and replication/slot.c. This makes the replication
> > slot on disk data structures unusable by the external tools/modules.
> > How about moving these structures to a new header file called
> > slot_common.h as attached in the patch here?
> >
> > Thoughts?
> >
> > PS: I'm planning to have the tool separately, as it was rejected to be in core.
> >
> > [1] https://www.postgresql.org/message-id/CALj2ACW0rV5gWK8A3m6_X62qH%2BVfaq5hznC%3Di0R5Wojt5%2Byhyw%40mail.gmail.com
>
> Recently I was also looking to add some new enums but I found it
> was difficult to find any good place to put them where they could be
> shared by the replication code and the pg_recvlogical tool.
>
> So +1 to your suggestion to have a common header, but I wonder can it
> have a more generic name (e.g. repl_common.h? ...) since the
> stuff I wanted to put there was not really "slot" related.

Thanks. repl_common.h sounds cool and generic IMO too, so I changed
it. Another important note here is to let this file have only
replication data structures and functions that are meant/supposed to
be usable across entire postgres modules - core, tools, contrib
modules, the internal data structures can be added elsewhere.

Attaching v2 patch.

I will add a CF entry a day or two later.

Regards,
Bharath Rupireddy.

Attachment Content-Type Size
v2-0001-Add-new-header-file-for-replication-slot-common-d.patch application/x-patch 9.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2022-02-10 04:53:19 Use return value of XLogRecGetBlockTag instead of explicit block ref checks and also use XLogRecHasBlockRef/Image macros instead of explicit checks
Previous Message houzj.fnst@fujitsu.com 2022-02-10 03:59:16 RE: row filtering for logical replication