Обсуждение: pgsql: Beautify initialization of JsonValueList andJsonLikeRegexContex
Beautify initialization of JsonValueList and JsonLikeRegexContext
Instead of tricky assignment to {0} introduce special macros, which
explicitly initialize every field.
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/4178d8b91cb943b422d1837b4b7798576d88995a
Modified Files
--------------
src/backend/utils/adt/jsonpath_exec.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
Re: pgsql: Beautify initialization of JsonValueList andJsonLikeRegexContex
От
Peter Eisentraut
Дата:
On 2019-03-17 10:59, Alexander Korotkov wrote:
> Beautify initialization of JsonValueList and JsonLikeRegexContext
>
> Instead of tricky assignment to {0} introduce special macros, which
> explicitly initialize every field.
To me, this patch is exactly the opposite of what I'd do to "beautify
initialization". It doesn't seem sustainable to me to create a special
macro for every structure in the code, not does it improve readability.
It is much clearer that {0} is uniformly the starting state.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Re: pgsql: Beautify initialization of JsonValueList and JsonLikeRegexContex
От
Alexander Korotkov
Дата:
On Sun, Mar 17, 2019 at 3:00 PM Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
> On 2019-03-17 10:59, Alexander Korotkov wrote:
> > Beautify initialization of JsonValueList and JsonLikeRegexContext
> >
> > Instead of tricky assignment to {0} introduce special macros, which
> > explicitly initialize every field.
>
> To me, this patch is exactly the opposite of what I'd do to "beautify
> initialization". It doesn't seem sustainable to me to create a special
> macro for every structure in the code, not does it improve readability.
> It is much clearer that {0} is uniformly the starting state.
I got two reasons in the mind while committing that:
1) We would probably like to make some values of empty state non-zero in future.
2) In general, it's better to not assume that NULL is binary zero.
However, we assume that a lot in other places. So, it probably
doesn't matter.
Anyway, I thought about this as about just beautification. If it's
bad idea, let's revert this.
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
On Sun, Mar 17, 2019 at 03:09:07PM +0300, Alexander Korotkov wrote:
> Anyway, I thought about this as about just beautification. If it's
> bad idea, let's revert this.
I agree with Peter's point here that having {0} as initial state is
cleaner instead of adding an extra level of abstraction.
--
Michael
Вложения
Re: pgsql: Beautify initialization of JsonValueList and JsonLikeRegexContex
От
Alexander Korotkov
Дата:
On Mon, Mar 18, 2019 at 7:12 AM Michael Paquier <michael@paquier.xyz> wrote:
>
> On Sun, Mar 17, 2019 at 03:09:07PM +0300, Alexander Korotkov wrote:
> > Anyway, I thought about this as about just beautification. If it's
> > bad idea, let's revert this.
>
> I agree with Peter's point here that having {0} as initial state is
> cleaner instead of adding an extra level of abstraction.
OK! So, reverted.
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company