pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: SQL/JSON: Fix casting for integer EXISTS columns in JSON_TABLE
2+ messages / 1 participants
[nested] [flat]

* pgsql: SQL/JSON: Fix casting for integer EXISTS columns in JSON_TABLE
@ 2024-07-30 02:00  Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Amit Langote @ 2024-07-30 02:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

SQL/JSON: Fix casting for integer EXISTS columns in JSON_TABLE

The current method of coercing the boolean result value of
JsonPathExists() to the target type specified for an EXISTS column,
which is to call the type's input function via json_populate_type(),
leads to an error when the target type is integer, because the
integer input function doesn't recognize boolean literal values as
valid.

Instead use the boolean-to-integer cast function for coercion in that
case so that using integer or domains thereof as type for EXISTS
columns works. Note that coercion for ON ERROR values TRUE and FALSE
already works like that because the parser creates a cast expression
including the cast function, but the coercion of the actual result
value is not handled by the parser.

Tests by Jian He.

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/f95c5090d975c3f552823f1f6895193d5da19825

Modified Files
--------------
src/backend/executor/execExpr.c                 | 19 +++++++---
src/backend/executor/execExprInterp.c           | 46 ++++++++++++++++++++-----
src/include/executor/execExpr.h                 |  6 +++-
src/test/regress/expected/sqljson_jsontable.out | 34 ++++++++++++++++--
src/test/regress/sql/sqljson_jsontable.sql      | 13 ++++++-
5 files changed, 102 insertions(+), 16 deletions(-)



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

* pgsql: SQL/JSON: Fix casting for integer EXISTS columns in JSON_TABLE
@ 2024-07-30 02:00  Amit Langote <amitlan@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Amit Langote @ 2024-07-30 02:00 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

SQL/JSON: Fix casting for integer EXISTS columns in JSON_TABLE

The current method of coercing the boolean result value of
JsonPathExists() to the target type specified for an EXISTS column,
which is to call the type's input function via json_populate_type(),
leads to an error when the target type is integer, because the
integer input function doesn't recognize boolean literal values as
valid.

Instead use the boolean-to-integer cast function for coercion in that
case so that using integer or domains thereof as type for EXISTS
columns works. Note that coercion for ON ERROR values TRUE and FALSE
already works like that because the parser creates a cast expression
including the cast function, but the coercion of the actual result
value is not handled by the parser.

Tests by Jian He.

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/7f56eaff2fb0f3541c5c6ef8c1099e7f0618b461

Modified Files
--------------
src/backend/executor/execExpr.c                 | 19 +++++++---
src/backend/executor/execExprInterp.c           | 46 ++++++++++++++++++++-----
src/include/executor/execExpr.h                 |  6 +++-
src/test/regress/expected/sqljson_jsontable.out | 34 ++++++++++++++++--
src/test/regress/sql/sqljson_jsontable.sql      | 13 ++++++-
5 files changed, 102 insertions(+), 16 deletions(-)



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


end of thread, other threads:[~2024-07-30 02:00 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-07-30 02:00 pgsql: SQL/JSON: Fix casting for integer EXISTS columns in JSON_TABLE Amit Langote <amitlan@postgresql.org>
2024-07-30 02:00 pgsql: SQL/JSON: Fix casting for integer EXISTS columns in JSON_TABLE 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