pgsql: Selectively include window frames in expression walks/mutates.

From: Andrew Gierth <rhodiumtoad(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Selectively include window frames in expression walks/mutates.
Date: 2019-10-03 10:52:52
Message-ID: E1iFyj6-0003O8-Pu@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Selectively include window frames in expression walks/mutates.

query_tree_walker and query_tree_mutator were skipping the
windowClause of the query, without regard for the fact that the
startOffset and endOffset in a WindowClause node are expression trees
that need to be processed. This was an oversight in commit ec4be2ee6
from 2010 which added the expression fields; the main symptom is that
function parameters in window frame clauses don't work in inlined
functions.

Fix (as conservatively as possible since this needs to not break
existing out-of-tree callers) and add tests.

Backpatch all the way, since this has been broken since 9.0.

Per report from Alastair McKinley; fix by me with kibitzing and review
from Tom Lane.

Discussion: https://postgr.es/m/DB6PR0202MB2904E7FDDA9D81504D1E8C68E3800@DB6PR0202MB2904.eurprd02.prod.outlook.com

Branch
------
REL9_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3473f81dd2a3491ad61be7d7f2917d2af70c423e

Modified Files
--------------
src/backend/catalog/dependency.c | 9 +--
src/backend/nodes/nodeFuncs.c | 105 +++++++++++++++++++++++++++++++++++
src/include/nodes/nodeFuncs.h | 1 +
src/test/regress/expected/window.out | 42 ++++++++++++++
src/test/regress/sql/window.sql | 19 +++++++
5 files changed, 169 insertions(+), 7 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2019-10-03 13:48:32 Re: pgsql: Implement jsonpath .datetime() method
Previous Message Amit Kapila 2019-10-03 09:38:17 Re: pgsql: pgbench: add --partitions and --partition-method options.