pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Don't include CaseTestExpr in JsonValueExpr.formatted_expr
4+ messages / 3 participants
[nested] [flat]

* pgsql: Don't include CaseTestExpr in JsonValueExpr.formatted_expr
@ 2023-07-13 03:33  Amit Langote <amitlan@postgresql.org>
  0 siblings, 1 reply; 4+ messages in thread

From: Amit Langote @ 2023-07-13 03:33 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't include CaseTestExpr in JsonValueExpr.formatted_expr

A CaseTestExpr is currently being put into
JsonValueExpr.formatted_expr as placeholder for the result of
evaluating JsonValueExpr.raw_expr, which in turn is evaluated
separately.  Though, there's no need for this indirection if
raw_expr itself can be embedded into formatted_expr and evaluated
as part of evaluating the latter, especially as there is no
special reason to evaluate it separately.  So this commit makes it
so.  As a result, JsonValueExpr.raw_expr no longer needs to be
evaluated in ExecInterpExpr(), eval_const_exprs_mutator() etc. and
is now only used for displaying the original "unformatted"
expression in ruleutils.c.

While at it, this also removes the function makeCaseTestExpr(),
because the code in makeJsonConstructorExpr() looks more readable
without it IMO and isn't used by anyone else either.

Finally, a note is added in the comment above CaseTestExpr's
definition that JsonConstructorExpr is also using it.

Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://postgr.es/m/CA+HiwqE4XTdfb1nW=Ojoy_tQSRhYt-q_kb6i5d4xcKyrLC1Nbg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b6e1157e7d339c4e20d68448125a4cef42b1ac9d

Modified Files
--------------
src/backend/executor/execExpr.c      | 17 ++------------
src/backend/nodes/makefuncs.c        |  4 ++++
src/backend/optimizer/util/clauses.c | 23 +++++--------------
src/backend/parser/parse_expr.c      | 43 ++++++++++++++++++------------------
src/include/nodes/primnodes.h        |  7 +++++-
5 files changed, 39 insertions(+), 55 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Don't include CaseTestExpr in JsonValueExpr.formatted_expr
@ 2023-07-13 08:11  Michael Paquier <michael@paquier.xyz>
  parent: Amit Langote <amitlan@postgresql.org>
  0 siblings, 1 reply; 4+ messages in thread

From: Michael Paquier @ 2023-07-13 08:11 UTC (permalink / raw)
  To: Amit Langote <amitlan@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org

Hi Amit,

On Thu, Jul 13, 2023 at 03:33:07AM +0000, Amit Langote wrote:
> Don't include CaseTestExpr in JsonValueExpr.formatted_expr
> 
> A CaseTestExpr is currently being put into
> JsonValueExpr.formatted_expr as placeholder for the result of
> evaluating JsonValueExpr.raw_expr, which in turn is evaluated
> separately.  Though, there's no need for this indirection if
> raw_expr itself can be embedded into formatted_expr and evaluated
> as part of evaluating the latter, especially as there is no
> special reason to evaluate it separately.  So this commit makes it
> so.  As a result, JsonValueExpr.raw_expr no longer needs to be
> evaluated in ExecInterpExpr(), eval_const_exprs_mutator() etc. and
> is now only used for displaying the original "unformatted"
> expression in ruleutils.c.

koel is unhappy after this commit:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=koel&dt=2023-07-13%2006%3A49%3A03
This code is not indented properly.
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Don't include CaseTestExpr in JsonValueExpr.formatted_expr
@ 2023-07-13 13:33  Amit Langote <amitlangote09@gmail.com>
  parent: Michael Paquier <michael@paquier.xyz>
  0 siblings, 0 replies; 4+ messages in thread

From: Amit Langote @ 2023-07-13 13:33 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: Amit Langote <amitlan@postgresql.org>; pgsql-committers@lists.postgresql.org

On Thu, Jul 13, 2023 at 5:12 PM Michael Paquier <michael@paquier.xyz> wrote:
>
> Hi Amit,
>
> On Thu, Jul 13, 2023 at 03:33:07AM +0000, Amit Langote wrote:
> > Don't include CaseTestExpr in JsonValueExpr.formatted_expr
> >
> > A CaseTestExpr is currently being put into
> > JsonValueExpr.formatted_expr as placeholder for the result of
> > evaluating JsonValueExpr.raw_expr, which in turn is evaluated
> > separately.  Though, there's no need for this indirection if
> > raw_expr itself can be embedded into formatted_expr and evaluated
> > as part of evaluating the latter, especially as there is no
> > special reason to evaluate it separately.  So this commit makes it
> > so.  As a result, JsonValueExpr.raw_expr no longer needs to be
> > evaluated in ExecInterpExpr(), eval_const_exprs_mutator() etc. and
> > is now only used for displaying the original "unformatted"
> > expression in ruleutils.c.
>
> koel is unhappy after this commit:
> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=koel&dt=2023-07-13%2006%3A49%3A03
> This code is not indented properly.

Andrew just mentioned that to me off-list too.  I've just pushed a fix.

-- 
Thanks, Amit Langote
EDB: http://www.enterprisedb.com





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: Don't include CaseTestExpr in JsonValueExpr.formatted_expr
@ 2023-07-21 10:29  Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Amit Langote @ 2023-07-21 10:29 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Don't include CaseTestExpr in JsonValueExpr.formatted_expr

A CaseTestExpr is currently being put into
JsonValueExpr.formatted_expr as placeholder for the result of
evaluating JsonValueExpr.raw_expr, which in turn is evaluated
separately.  Though, there's no need for this indirection if
raw_expr itself can be embedded into formatted_expr and evaluated
as part of evaluating the latter, especially as there is no
special reason to evaluate it separately.  So this commit makes it
so.  As a result, JsonValueExpr.raw_expr no longer needs to be
evaluated in ExecInterpExpr(), eval_const_exprs_mutator() etc. and
is now only used for displaying the original "unformatted"
expression in ruleutils.c.  Comments about and the code manipulating
formatted_expr is updated to mention that it is now always set and
is the expression that gives a JsonValueExpr its runtime value.

While at it, this also removes the function makeCaseTestExpr(),
because the code in makeJsonConstructorExpr() looks more readable
without it IMO and isn't used by anyone else either.

Finally, a note is added in the comment above CaseTestExpr's
definition that JsonConstructorExpr is also using it.

Backpatched to 16 from the development branch to keep the code in
sync across branches.

Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://postgr.es/m/CA+HiwqE4XTdfb1nW=Ojoy_tQSRhYt-q_kb6i5d4xcKyrLC1Nbg@mail.gmail.com

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/66a9003e2e3ec05e9b62d6bfb6797fa35fb01d15

Modified Files
--------------
src/backend/executor/execExpr.c      | 17 ++---------
src/backend/nodes/makefuncs.c        |  7 +++--
src/backend/nodes/nodeFuncs.c        |  4 +--
src/backend/optimizer/util/clauses.c | 23 ++++-----------
src/backend/parser/gram.y            |  4 ++-
src/backend/parser/parse_expr.c      | 57 ++++++++++++++++++++----------------
src/include/nodes/makefuncs.h        |  3 +-
src/include/nodes/primnodes.h        |  8 ++++-
8 files changed, 56 insertions(+), 67 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2023-07-21 10:29 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-07-13 03:33 pgsql: Don't include CaseTestExpr in JsonValueExpr.formatted_expr Amit Langote <amitlan@postgresql.org>
2023-07-13 08:11 ` Michael Paquier <michael@paquier.xyz>
2023-07-13 13:33   ` Amit Langote <amitlangote09@gmail.com>
2023-07-21 10:29 pgsql: Don't include CaseTestExpr in JsonValueExpr.formatted_expr Amit Langote <amitlan@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox