pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: SQL/JSON: Some fixes to JsonBehavior expression casting
2+ messages / 1 participants
[nested] [flat]

* pgsql: SQL/JSON: Some fixes to JsonBehavior expression casting
@ 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: Some fixes to JsonBehavior expression casting

1. Remove the special case handling when casting the JsonBehavior
   expressions to types with typmod, like 86d33987 did for the casting
   of SQL/JSON constructor functions.

2. Fix casting for fixed-length character and bit string types by
   using assignment-level casts.  This is again similar to what
   86d33987 did, but for ON ERROR / EMPTY expressions.

3. Use runtime coercion for the boolean ON ERROR constants so that
   using fixed-length character string types, for example, for an
   EXISTS column doesn't cause a "value too long for type
   character(n)" when the parser tries to coerce the default ON ERROR
   value "false" to that type, that is, even when clause is not
   specified.

4. Simplify the conditions of when to use runtime coercion vs
   creating the cast expression in the parser itself.  jsonb-valued
   expressions are now always coerced at runtime and boolean
   expressions too if the target type is a string type for the
   reasons mentioned above.

New tests are from a patch that Jian He posted.  Outputs of some
existing tests change because the coercion now happens at runtime
instead of at parse time.

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/847ee701bd3a6d222ab8f67923e308ee1a70a2f8

Modified Files
--------------
src/backend/parser/parse_expr.c                  | 100 ++++++++++++++++-------
src/test/regress/expected/sqljson_jsontable.out  |  29 +++++--
src/test/regress/expected/sqljson_queryfuncs.out |  66 +++++++++++----
src/test/regress/sql/sqljson_jsontable.sql       |   5 +-
src/test/regress/sql/sqljson_queryfuncs.sql      |  16 +++-
5 files changed, 164 insertions(+), 52 deletions(-)



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

* pgsql: SQL/JSON: Some fixes to JsonBehavior expression casting
@ 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: Some fixes to JsonBehavior expression casting

1. Remove the special case handling when casting the JsonBehavior
   expressions to types with typmod, like 86d33987 did for the casting
   of SQL/JSON constructor functions.

2. Fix casting for fixed-length character and bit string types by
   using assignment-level casts.  This is again similar to what
   86d33987 did, but for ON ERROR / EMPTY expressions.

3. Use runtime coercion for the boolean ON ERROR constants so that
   using fixed-length character string types, for example, for an
   EXISTS column doesn't cause a "value too long for type
   character(n)" when the parser tries to coerce the default ON ERROR
   value "false" to that type, that is, even when clause is not
   specified.

4. Simplify the conditions of when to use runtime coercion vs
   creating the cast expression in the parser itself.  jsonb-valued
   expressions are now always coerced at runtime and boolean
   expressions too if the target type is a string type for the
   reasons mentioned above.

Tests are taken from a patch that Jian He posted.

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/74c96699be3f53c058c8794c07952221b9625b4f

Modified Files
--------------
src/backend/parser/parse_expr.c                  | 100 ++++++++++++++++-------
src/test/regress/expected/sqljson_jsontable.out  |  29 +++++--
src/test/regress/expected/sqljson_queryfuncs.out |  66 +++++++++++----
src/test/regress/sql/sqljson_jsontable.sql       |   5 +-
src/test/regress/sql/sqljson_queryfuncs.sql      |  16 +++-
5 files changed, 164 insertions(+), 52 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: Some fixes to JsonBehavior expression casting Amit Langote <amitlan@postgresql.org>
2024-07-30 02:00 pgsql: SQL/JSON: Some fixes to JsonBehavior expression casting 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