Re: Uninitialized scalar variable (UNINIT) (src/backend/statistics/extended_stats.c)

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers(at)postgresql(dot)org, Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
Subject: Re: Uninitialized scalar variable (UNINIT) (src/backend/statistics/extended_stats.c)
Date: 2021-04-12 17:05:53
Message-ID: 20210412170553.GG20530@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Apr 12, 2021 at 01:55:13PM -0300, Ranier Vilela wrote:
> Em seg., 12 de abr. de 2021 às 03:04, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> escreveu:
> > Michael Paquier <michael(at)paquier(dot)xyz> writes:
> > > On Sun, Apr 11, 2021 at 07:42:20PM -0300, Ranier Vilela wrote:
> > >> Em dom., 11 de abr. de 2021 às 16:25, Justin Pryzby <
> > pryzby(at)telsasoft(dot)com>
> > >>> I think it's cleanest to write:
> > >>> |HeapTupleData tmptup = {0};
> >
> > > I agree that this would be cleaner.
> >
> > It would be wrong, though, or at least not have the same effect.
> >
> I think that you speak about fill pointers with 0 is not the same as fill
> pointers with NULL.
>
>
> > ItemPointerSetInvalid does not set the target to all-zeroes.
> >
> ItemPointerSetInvalid set or not set the target to all-zeroes?

I think Tom means that it does:
BlockIdSet(&((pointer)->ip_blkid), InvalidBlockNumber),
(pointer)->ip_posid = InvalidOffsetNumber

but it's not zero, as I thought:

src/include/storage/block.h:#define InvalidBlockNumber ((BlockNumber) 0xFFFFFFFF)

> > (Regardless of that detail, it's generally best to accomplish
> > objective X in the same way that existing code does. Deciding
> > that you have a better way is often wrong, and even if you
> > are right, you should then submit a patch to change all the
> > existing cases.)

FYI, I'd gotten the idea from here:

$ git grep 'HeapTupleData.*='
src/backend/executor/execTuples.c: HeapTupleData tuple = {0};

--
Justin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nandni Mehla 2021-04-12 17:56:48 Proposal for working on open source with PostgreSQL
Previous Message Tom Lane 2021-04-12 17:04:24 Re: Uninitialized scalar variable (UNINIT) (src/backend/statistics/extended_stats.c)