pgsql: SQL/JSON: Fix coercion of constructor outputs to types with typm

From: Amit Langote <amitlan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: SQL/JSON: Fix coercion of constructor outputs to types with typm
Date: 2024-06-28 13:03:35
Message-ID: E1sNBGI-003Mpl-VF@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

SQL/JSON: Fix coercion of constructor outputs to types with typmod

Ensure SQL/JSON constructor functions that allow specifying the
target type using the RETURNING clause perform implicit cast to
that type. This ensures that output values that exceed the specified
length produce an error rather than being silently truncated. This
behavior conforms to the SQL standard.

Reported-by: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Reviewed-by: Jian He <jian(dot)universality(at)gmail(dot)com>
Discussion: https://postgr.es/m/202405271326.5a5rprki64aw%40alvherre.pgsql

Branch
------
master

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

Modified Files
--------------
src/backend/parser/parse_expr.c | 24 +++++++++++++++++++++++-
src/test/regress/expected/sqljson.out | 17 +++++++++++++++++
src/test/regress/sql/sqljson.sql | 12 ++++++++++++
3 files changed, 52 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2024-06-28 14:54:03 pgsql: pgindent, because I forgot to do that.
Previous Message Robert Haas 2024-06-28 12:45:51 pgsql: Prevent summarizer hang when summarize_wal turned off and back o