public inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Tatsuo Ishii <ishii@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix IGNORE NULLS nullness cache for volatile window arguments.
Date: Mon, 18 May 2026 03:44:20 +0000
Message-ID: <E1wOotw-0005uD-26@gemulon.postgresql.org> (raw)
Fix IGNORE NULLS nullness cache for volatile window arguments.
The IGNORE NULLS implementation caches whether a window function argument
evaluated to NULL or NOT NULL for a given partition row. That is safe for
ordinary expressions, but not for volatile expressions, where evaluating the
same argument on the same row can produce a different NULL/NOT NULL result
later.
This could produce wrong results in two ways. A row previously cached as
NULL could be skipped even though a later evaluation would return NOT NULL.
Conversely, a row cached as NOT NULL could be chosen as the target row, then
re-evaluated to fetch the actual value and return NULL.
Make the nullness cache conditional per argument. Do not use it for
arguments containing volatile functions or subplans, following the same
conservative approach used for moving window aggregates. Also avoid
re-evaluating non-cacheable partition arguments after the scan has already
found the target row.
Add regression tests covering volatile arguments and subplan arguments with
IGNORE NULLS.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Tatsuo Ishii <ishii@postgresql.org>
Discussion: https://postgr.es/m/42B42506-6972-4266-8422-FB73E61D9DA7@gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/26269fe3c83beed1601e3bd156a98cf7696e9e08
Modified Files
--------------
src/backend/executor/nodeWindowAgg.c | 44 +++++++++++++++++++-----
src/test/regress/expected/window.out | 66 ++++++++++++++++++++++++++++++++++++
src/test/regress/sql/window.sql | 28 +++++++++++++++
3 files changed, 130 insertions(+), 8 deletions(-)
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: ishii@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix IGNORE NULLS nullness cache for volatile window arguments.
In-Reply-To: <E1wOotw-0005uD-26@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