From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
---|---|
To: | John Naylor <john(dot)naylor(at)enterprisedb(dot)com> |
Cc: | Junwang Zhao <zhjwpku(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Should we use MemSet or {0} for struct initialization? |
Date: | 2023-09-01 03:03:43 |
Message-ID: | CAMbWs4_jAOeTTecM9nVsEpWT7Cghe-T2NVfzeYiV1xhrfVFVgw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Aug 31, 2023 at 7:07 PM John Naylor <john(dot)naylor(at)enterprisedb(dot)com>
wrote:
> > On Thu, Aug 31, 2023 at 5:34 PM Richard Guo <guofenglinux(at)gmail(dot)com>
> wrote:
> > >
> > > While working on a bug in expandRecordVariable() I noticed that in the
> > > switch statement for case RTE_SUBQUERY we initialize struct ParseState
> > > with {0} while for case RTE_CTE we do that with MemSet. I understand
> > > that there is nothing wrong with this, just cannot get away with the
> > > inconsistency inside the same function (sorry for the nitpicking).
> > >
> > > Do we have a preference for how to initialize structures? From
> 9fd45870
> > > it seems that we prefer to {0}. So here is a trivial patch doing that.
>
> It seems to have been deliberately left that way in the wake of that
> commit, see:
>
>
> https://www.postgresql.org/message-id/87d2e5f8-3c37-d185-4bbc-1de163ac4b10%40enterprisedb.com
>
> (If so, it deserves a comment to keep people from trying to change it...)
>
Thanks for pointing this out. Yeah, struct initialization does not work
for some cases with padding bits, such as for a hash key we need to
clear the padding too.
The case in expandRecordVariable() mentioned here should be safe though,
maybe this is an omission from 9fd45870?
Thanks
Richard
From | Date | Subject | |
---|---|---|---|
Next Message | Andy Fan | 2023-09-01 03:09:22 | Re: Extract numeric filed in JSONB more effectively |
Previous Message | Nathan Bossart | 2023-09-01 02:17:27 | Re: should frontend tools use syncfs() ? |