pgsql: Resolve untyped parameters in FOR PORTION OF FROM/TO bounds

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Resolve untyped parameters in FOR PORTION OF FROM/TO bounds
Date: 2026-09-08 08:00:08
Message-ID: E1x3qkR-00000003xkL-1U2B@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Resolve untyped parameters in FOR PORTION OF FROM/TO bounds

FOR PORTION OF valid_at FROM $1 TO $2 fails with "could not determine data
type of parameter $1", so using PREPARE requires users to say $1::date
etc. But transformForPortionOfClause() already coerces the bounds, since
it builds a constructor for the targeted range. We just need to store the
coerced expressions in targetFrom and targetTo.

This also improves pg_get_ruledef(), which now renders an untyped NULL
bound as NULL::date instead of NULL::unknown.

Reported-by: Noah Misch <noah(at)leadboat(dot)com>
Author: Paul A. Jungwirth <pj(at)illuminatedcomputing(dot)com>
Discussion: https://www.postgresql.org/message-id/flat/CA%2BrenyW1uJp1dw%3DiK7MsWfbbZf-dKP_4JLoQ65wj%3Dfry35FjCw%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/438f027238c0582e89d4c81e3f88d9b1d6d810d0

Modified Files
--------------
src/backend/parser/analyze.c | 12 ++-
src/test/regress/expected/for_portion_of.out | 106 ++++++++++++++++++++++++++-
src/test/regress/sql/for_portion_of.sql | 71 ++++++++++++++++++
3 files changed, 185 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2026-09-08 08:34:01 pgsql: doc: Remove unnecessary CVE items from release notes
Previous Message Fujii Masao 2026-09-08 07:51:16 pgsql: Stabilize 026_overwrite_contrecord test