Refine error reporting for null treatment on non-window functions

Commit 4e5920e6de8 disallowed RESPECT NULLS/IGNORE NULLS on
non-window functions, but it also caused the parser to check for
that clause too early in some cases. As a result, calls such as a
nonexistent function with IGNORE NULLS no longer reported the more
helpful "function ... does not exist" error, and aggregate functions
used as window functions reported "only window functions accept ..."
instead of the more accurate aggregate-specific error.

This commit moves the RESPECT NULLS/IGNORE NULLS checks so that
helpful existing errors are preserved where appropriate. This restores
"function ... does not exist" for nonexistent functions, while still
reporting that plain functions are not window functions and that
aggregates do not accept null treatment.

Author: Fujii Masao <[email protected]>
Reviewed-by: Tatsuo Ishii <[email protected]>
Reviewed-by: Chao Li <[email protected]>
Reviewed-by: Álvaro Herrera <[email protected]>
Discussion: 
https://postgr.es/m/cahgqgwh7vy_0gkhycyyz4czkpgl0ugzdyoxk3uufosrr7wf...@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/419ce13b7019f906ebc010af3be09a9deffc2a47

Modified Files
--------------
src/backend/parser/parse_func.c      | 23 ++++++++++++++---------
src/test/regress/expected/window.out | 17 +++++++++++++++--
src/test/regress/sql/window.sql      |  3 +++
3 files changed, 32 insertions(+), 11 deletions(-)

Reply via email to