Re: [HACKERS] Constifying numeric.c's local vars

2018-02-21 Thread Tom Lane
Mark Dilger writes: >> This means that the const variable 'const_zero' contains a pointer that is >> non-const, pointing at something that is static const, stored in read only >> memory. Yikes. > I still believe this is unsafe. I'm with Andres: I don't see the problem.

Re: [HACKERS] Constifying numeric.c's local vars

2018-02-21 Thread Mark Dilger
> This patch got committed as c1898c3e1e235ae35b4759d233253eff221b976a > on Sun Sep 10 16:20:41 2017 -0700, but I've only just gotten around to > reviewing it. > > I believe this is wrong and should be reverted, at least in part. > > The NumericVar struct has the field 'digits' as non-const: >

Re: [HACKERS] Constifying numeric.c's local vars

2018-02-21 Thread Andres Freund
On February 21, 2018 8:49:51 AM PST, Mark Dilger wrote: > >The idea that set_var_from_var might be called on const_zero (or >const_one, >etc.) is not hypothetical. It is being done in numeric.c. > >If this is safe, somebody needs to be a lot clearer about why that is

Re: [HACKERS] Constifying numeric.c's local vars

2018-02-21 Thread Mark Dilger
> On Sep 11, 2017, at 5:10 AM, Tom Lane wrote: > > Andres Freund writes: >> One large user of unnecessary non-constant static variables is >> numeric.c. More out of curiosity - numeric is slow enough in itself to >> make inlining not a huge win - I