Re: PublicationActions - use bit flags.

From: Peter Smith <smithpb2250(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Nancarrow <gregn4422(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: PublicationActions - use bit flags.
Date: 2021-12-29 04:21:36
Message-ID: CAHut+Ptv-gA7=zvc0xmS+7iejRrk0aRj+Rar69Zh1Qm1KqvsGA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Dec 21, 2021 at 11:56 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Greg Nancarrow <gregn4422(at)gmail(dot)com> writes:
> > I've attached a patch which addresses that and replaces a couple of
> > memcpy()s with struct assignment, as suggested.
>
> Removing this is not good:
>
> if (relation->rd_pubactions)
> - {
> pfree(relation->rd_pubactions);
> - relation->rd_pubactions = NULL;
> - }
>
> If the subsequent palloc fails, you've created a problem where
> there was none before.
>
> I do wonder why we have to palloc a constant-size substructure in
> the first place, especially one that is likely smaller than the
> pointer that points to it. Maybe the struct definition should be
> moved so that we can just declare it in-line in the relcache entry?
>

At the risk of flogging a dead horse, here is v2 of my original
bit-flag replacement for the PublicationActions struct.

This version introduces one more bit flag for the relcache status, and
by doing so means all that code for Relation cache PublicationActions
pointers and pallocs and context switches can just disappear...

------
Kind Regards,
Peter Smith.
Fujitsu Australia

Attachment Content-Type Size
v2-0001-PublicationActions-use-bit-flags.patch application/octet-stream 15.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2021-12-29 04:29:52 Re: WIP: WAL prefetch (another approach)
Previous Message Thomas Munro 2021-12-29 03:29:54 Re: Documenting when to retry on serialization failure