pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste
9+ messages / 3 participants
[nested] [flat]

* pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste
@ 2024-09-06 03:07 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 9+ messages in thread

From: Amit Langote @ 2024-09-06 03:07 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY steps

When the ON ERROR / ON EMPTY behavior is to return NULL, returning
NULL directly from ExecEvalJsonExprPath() suffices. Therefore, there's
no need to create separate steps to check the error/empty flag or
those to evaluate the the constant NULL expression.  This speeds up
common cases because the default ON ERROR / ON EMPTY behavior for
JSON_QUERY() and JSON_VALUE() is to return NULL.  However, these steps
are necessary if the RETURNING type is a domain, as constraints on the
domain may need to be checked.

Reported-by: Jian He <jian.universality@gmail.com>
Author: Jian He <jian.universality@gmail.com>
Author: Amit Langote <amitlangote09@gmail.com>
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com
Backpatch-through: 17

Branch
------
REL_17_STABLE

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

Modified Files
--------------
src/backend/executor/execExpr.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)



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

* pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste
@ 2024-09-06 03:07 Amit Langote <amitlan@postgresql.org>
  2024-09-06 03:44 ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlangote09@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Amit Langote @ 2024-09-06 03:07 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY steps

When the ON ERROR / ON EMPTY behavior is to return NULL, returning
NULL directly from ExecEvalJsonExprPath() suffices. Therefore, there's
no need to create separate steps to check the error/empty flag or
those to evaluate the the constant NULL expression.  This speeds up
common cases because the default ON ERROR / ON EMPTY behavior for
JSON_QUERY() and JSON_VALUE() is to return NULL.  However, these steps
are necessary if the RETURNING type is a domain, as constraints on the
domain may need to be checked.

Reported-by: Jian He <jian.universality@gmail.com>
Author: Jian He <jian.universality@gmail.com>
Author: Amit Langote <amitlangote09@gmail.com>
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com
Backpatch-through: 17

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3a97460970f344660971ee75d7f5a181bf87f633

Modified Files
--------------
src/backend/executor/execExpr.c | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)



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

* Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste
  2024-09-06 03:07 pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlan@postgresql.org>
@ 2024-09-06 03:44 ` Amit Langote <amitlangote09@gmail.com>
  2024-09-06 04:09   ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 9+ messages in thread

From: Amit Langote @ 2024-09-06 03:44 UTC (permalink / raw)
  To: Amit Langote <amitlan@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org

On Fri, Sep 6, 2024 at 12:07 PM Amit Langote <amitlan@postgresql.org> wrote:
> SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY steps
>
> When the ON ERROR / ON EMPTY behavior is to return NULL, returning
> NULL directly from ExecEvalJsonExprPath() suffices. Therefore, there's
> no need to create separate steps to check the error/empty flag or
> those to evaluate the the constant NULL expression.  This speeds up
> common cases because the default ON ERROR / ON EMPTY behavior for
> JSON_QUERY() and JSON_VALUE() is to return NULL.  However, these steps
> are necessary if the RETURNING type is a domain, as constraints on the
> domain may need to be checked.
>
> Reported-by: Jian He <jian.universality@gmail.com>
> Author: Jian He <jian.universality@gmail.com>
> Author: Amit Langote <amitlangote09@gmail.com>
> Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com
> Backpatch-through: 17
>
> Branch
> ------
> master
>
> Details
> -------
> https://git.postgresql.org/pg/commitdiff/3a97460970f344660971ee75d7f5a181bf87f633
>
> Modified Files
> --------------
> src/backend/executor/execExpr.c | 30 ++++++++++++++++++++++--------
> 1 file changed, 22 insertions(+), 8 deletions(-)

This or one of the other of my recent commits have broken some BF
animals, so reverting for now.

-- 
Thanks, Amit Langote





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

* Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste
  2024-09-06 03:07 pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlan@postgresql.org>
  2024-09-06 03:44 ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlangote09@gmail.com>
@ 2024-09-06 04:09   ` Tom Lane <tgl@sss.pgh.pa.us>
  2024-09-06 04:18     ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlangote09@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Tom Lane @ 2024-09-06 04:09 UTC (permalink / raw)
  To: Amit Langote <amitlangote09@gmail.com>; +Cc: Amit Langote <amitlan@postgresql.org>; pgsql-committers@lists.postgresql.org

Amit Langote <amitlangote09@gmail.com> writes:
> This or one of the other of my recent commits have broken some BF
> animals, so reverting for now.

Unfiltered EXPLAIN VERBOSE output in a regression test is a
guaranteed fail.

			regards, tom lane





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

* Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste
  2024-09-06 03:07 pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlan@postgresql.org>
  2024-09-06 03:44 ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlangote09@gmail.com>
  2024-09-06 04:09   ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Tom Lane <tgl@sss.pgh.pa.us>
@ 2024-09-06 04:18     ` Amit Langote <amitlangote09@gmail.com>
  2024-09-06 04:19       ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 9+ messages in thread

From: Amit Langote @ 2024-09-06 04:18 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Amit Langote <amitlan@postgresql.org>; pgsql-committers@lists.postgresql.org

On Fri, Sep 6, 2024 at 1:09 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Amit Langote <amitlangote09@gmail.com> writes:
> > This or one of the other of my recent commits have broken some BF
> > animals, so reverting for now.
>
> Unfiltered EXPLAIN VERBOSE output in a regression test is a
> guaranteed fail.

Yes, thanks for the note.  Will change the test case to test what are
deparsing related changes in some other manner.

-- 
Thanks, Amit Langote





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

* Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste
  2024-09-06 03:07 pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlan@postgresql.org>
  2024-09-06 03:44 ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlangote09@gmail.com>
  2024-09-06 04:09   ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Tom Lane <tgl@sss.pgh.pa.us>
  2024-09-06 04:18     ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlangote09@gmail.com>
@ 2024-09-06 04:19       ` Tom Lane <tgl@sss.pgh.pa.us>
  2024-09-06 04:29         ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlangote09@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Tom Lane @ 2024-09-06 04:19 UTC (permalink / raw)
  To: Amit Langote <amitlangote09@gmail.com>; +Cc: pgsql-committers@lists.postgresql.org

Amit Langote <amitlangote09@gmail.com> writes:
> Yes, thanks for the note.  Will change the test case to test what are
> deparsing related changes in some other manner.

I usually prefer to test ruleutils.c by deparsing a suitable view.

			regards, tom lane





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

* Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste
  2024-09-06 03:07 pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlan@postgresql.org>
  2024-09-06 03:44 ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlangote09@gmail.com>
  2024-09-06 04:09   ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Tom Lane <tgl@sss.pgh.pa.us>
  2024-09-06 04:18     ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlangote09@gmail.com>
  2024-09-06 04:19       ` Re: pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Tom Lane <tgl@sss.pgh.pa.us>
@ 2024-09-06 04:29         ` Amit Langote <amitlangote09@gmail.com>
  0 siblings, 0 replies; 9+ messages in thread

From: Amit Langote @ 2024-09-06 04:29 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers@lists.postgresql.org

On Fri, Sep 6, 2024 at 1:19 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Amit Langote <amitlangote09@gmail.com> writes:
> > Yes, thanks for the note.  Will change the test case to test what are
> > deparsing related changes in some other manner.
>
> I usually prefer to test ruleutils.c by deparsing a suitable view.

Yeah, other tests in that file use that method too, so going with
that.  Actually, a few other tests in that file do use VERBOSE, but
with COSTS OFF, so unbitten so far by JIT summary accidentally being
printed out.

-- 
Thanks, Amit Langote





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

* pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste
@ 2024-09-09 04:47 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 9+ messages in thread

From: Amit Langote @ 2024-09-09 04:47 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY steps

When the ON ERROR / ON EMPTY behavior is to return NULL, returning
NULL directly from ExecEvalJsonExprPath() suffices. Therefore, there's
no need to create separate steps to check the error/empty flag or
those to evaluate the the constant NULL expression.  This speeds up
common cases because the default ON ERROR / ON EMPTY behavior for
JSON_QUERY() and JSON_VALUE() is to return NULL.  However, these steps
are necessary if the RETURNING type is a domain, as constraints on the
domain may need to be checked.

Reported-by: Jian He <jian.universality@gmail.com>
Author: Jian He <jian.universality@gmail.com>
Author: Amit Langote <amitlangote09@gmail.com>
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com
Backpatch-through: 17

Branch
------
master

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

Modified Files
--------------
src/backend/executor/execExpr.c       | 32 ++++++++++++++++++++++++++------
src/backend/executor/execExprInterp.c | 14 ++++++++------
2 files changed, 34 insertions(+), 12 deletions(-)



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

* pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste
@ 2024-09-09 06:59 Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 9+ messages in thread

From: Amit Langote @ 2024-09-09 06:59 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY steps

When the ON ERROR / ON EMPTY behavior is to return NULL, returning
NULL directly from ExecEvalJsonExprPath() suffices. Therefore, there's
no need to create separate steps to check the error/empty flag or
those to evaluate the the constant NULL expression.  This speeds up
common cases because the default ON ERROR / ON EMPTY behavior for
JSON_QUERY() and JSON_VALUE() is to return NULL.  However, these steps
are necessary if the RETURNING type is a domain, as constraints on the
domain may need to be checked.

Reported-by: Jian He <jian.universality@gmail.com>
Author: Jian He <jian.universality@gmail.com>
Author: Amit Langote <amitlangote09@gmail.com>
Discussion: https://postgr.es/m/CACJufxEo4sUjKCYtda0_qt9tazqqKPmF1cqhW9KBOUeJFqQd2g@mail.gmail.com
Backpatch-through: 17

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/77aebe9a8d3cccd4c54b43be87a38f2bae614c76

Modified Files
--------------
src/backend/executor/execExpr.c       | 32 ++++++++++++++++++++++++++------
src/backend/executor/execExprInterp.c | 14 ++++++++------
2 files changed, 34 insertions(+), 12 deletions(-)



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


end of thread, other threads:[~2024-09-09 06:59 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-09-06 03:07 pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlan@postgresql.org>
2024-09-06 03:07 pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlan@postgresql.org>
2024-09-06 03:44 ` Amit Langote <amitlangote09@gmail.com>
2024-09-06 04:09   ` Tom Lane <tgl@sss.pgh.pa.us>
2024-09-06 04:18     ` Amit Langote <amitlangote09@gmail.com>
2024-09-06 04:19       ` Tom Lane <tgl@sss.pgh.pa.us>
2024-09-06 04:29         ` Amit Langote <amitlangote09@gmail.com>
2024-09-09 04:47 pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste Amit Langote <amitlan@postgresql.org>
2024-09-09 06:59 pgsql: SQL/JSON: Avoid initializing unnecessary ON ERROR / ON EMPTY ste 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