pgsql: Disallow set-returning functions within window OVER clauses.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Disallow set-returning functions within window OVER clauses.
Date: 2026-06-30 21:21:34
Message-ID: E1wefte-000p3p-15@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Disallow set-returning functions within window OVER clauses.

We previously allowed this, but it leads to odd behaviors, basically
because putting a SRF there is inconsistent with the principle that a
window function doesn't change the number of rows in the query result.
There doesn't seem to be a strong reason to try to make such cases
behave consistently. Users should put their SRFs in lateral FROM
clauses instead.

This issue has been sitting on the back burner for multiple years
now, partially because it didn't seem wise to back-patch such a
change. Let's squeeze it into v19 before it's too late.

Bug: #17502
Bug: #19535
Reported-by: Daniel Farkaš <daniel(dot)farkas(at)datoris(dot)com>
Reported-by: Qifan Liu <imchifan(at)163(dot)com>
Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Reviewed-by: David Rowley <dgrowleyml(at)gmail(dot)com>
Discussion: https://postgr.es/m/17502-281a7aaacfaa872a@postgresql.org
Discussion: https://postgr.es/m/19535-376081d7cc07c86d@postgresql.org
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1de468099d27f44c1998c9c2251cd2aefcfab524

Modified Files
--------------
src/backend/parser/parse_func.c | 3 ---
src/test/regress/expected/tsrf.out | 25 +++++++++++++++----------
src/test/regress/sql/tsrf.sql | 10 +++++++---
3 files changed, 22 insertions(+), 16 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Thomas Munro 2026-06-30 23:47:30 pgsql: Remove radius from initdb authentication methods.
Previous Message Alexander Korotkov 2026-06-30 19:36:18 pgsql: doc: clarify MERGE PARTITIONS adjacency requirement