agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Disallow set-returning functions within window OVER clauses.
Date: Tue, 30 Jun 2026 21:21:34 +0000
Message-ID: <E1wefte-000p3r-1D@gemulon.postgresql.org> (raw)

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.farkas@datoris.com>
Reported-by: Qifan Liu <imchifan@163.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/17502-281a7aaacfaa872a@postgresql.org
Discussion: https://postgr.es/m/19535-376081d7cc07c86d@postgresql.org
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0c15b715c6517af7b1046b45f868425930eaee6f

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(-)



view thread (2+ messages)

Message-ID: <E1wefte-000p3r-1D@gemulon.postgresql.org>
Permalink:  ../E1wefte-000p3r-1D@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wefte-000p3r-1D@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Disallow set-returning functions within window OVER clauses.
  In-Reply-To: <E1wefte-000p3r-1D@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox