Re: Avoid calling SetMatViewPopulatedState if possible - Mailing list pgsql-hackers

From Fujii Masao
Subject Re: Avoid calling SetMatViewPopulatedState if possible
Date
Msg-id CAHGQGwEpFT=hiqC_jxWEsnoOVLz=wsfVXGLVL0Tnkpmf2=6ACA@mail.gmail.com
Whole thread
In response to Avoid calling SetMatViewPopulatedState if possible  ("cca5507" <cca5507@qq.com>)
List pgsql-hackers
On Thu, Jun 18, 2026 at 6:28 PM cca5507 <cca5507@qq.com> wrote:
> > 5. A small suggestion
> > After further consideration, I suggest using the condition:
> >     if (RelationIsPopulated(matviewRel) != !skipData)
> > This is much more readable and intuitive compared to the original:
> >     if (RelationIsPopulated(matviewRel) == skipData)
> > Especially when paired with the original call:
> >     SetMatViewPopulatedState(matviewRel, !skipData);
>
> Both are ok for me.

Thanks for the patch! I went with the following form:

    if (RelationIsPopulated(matviewRel) != !skipData)
            SetMatViewPopulatedState(matviewRel, !skipData);

Attached is an updated patch. I also adjusted the nearby comment and
expanded the commit message to explain the unnecessary pg_class update
and resulting dead tuple generation.

Barring any objections, I'm thinking to commit this.

Regards,

--
Fujii Masao

Attachment

pgsql-hackers by date:

Previous
From: Ashutosh Sharma
Date:
Subject: Re: [PATCH] Release replication slot on error in SQL-callable slot functions
Next
From: Chao Li
Date:
Subject: Re: Fix detection of truncated zstd-compressed backups