Re: plan shape work - Mailing list pgsql-hackers

From Tom Lane
Subject Re: plan shape work
Date
Msg-id 2805458.1759979077@sss.pgh.pa.us
Whole thread Raw
In response to Re: plan shape work  (Richard Guo <guofenglinux@gmail.com>)
Responses Re: plan shape work
List pgsql-hackers
Richard Guo <guofenglinux@gmail.com> writes:
> Does it make sense to explicitly initialize glob->subplanNames in
> standard_planner()?  I understand this might seem pointless since
> makeNode() zeroes all fields by default, but subplanNames is currently
> the only field in PlannerGlobal that isn't explicitly initialized.  I
> previously committed a patch (2c0ed86d3) to ensure all PlannerGlobal
> fields are explicitly initialized, and I'd prefer to maintain that
> consistency.

We don't really have consensus on that point, I fear.  I like the
initialize-em-all-explicitly approach, but some other senior hackers
think it's useless verbiage.

My argument for doing it explicitly is that when adding a new field
to a struct, one frequently searches for existing references to a
nearby field.  Without initialize-em-all, this risks missing places
where you need to initialize your new field.  If you'd only set it
to zero, then fine ... but what if that particular place needs some
other initial value?  So I think omitting initializations-to-zero
risks future bugs of omission.  Some other folk don't find that
argument very compelling, though.

            regards, tom lane



pgsql-hackers by date:

Previous
From: "suyu.cmj"
Date:
Subject: Re: Question about InvalidatePossiblyObsoleteSlot()
Next
From: Chao Li
Date:
Subject: Re: doc: Improve description of io_combine_limit and io_max_combine_limit GUCs