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 |
||
|---|---|---|
| .github | ||
| config | ||
| contrib | ||
| doc | ||
| src | ||
| .cirrus.star | ||
| .cirrus.tasks.yml | ||
| .cirrus.yml | ||
| .dir-locals.el | ||
| .editorconfig | ||
| .git-blame-ignore-revs | ||
| .gitattributes | ||
| .gitignore | ||
| .mailmap | ||
| aclocal.m4 | ||
| configure | ||
| configure.ac | ||
| COPYRIGHT | ||
| GNUmakefile.in | ||
| HISTORY | ||
| Makefile | ||
| meson.build | ||
| meson_options.txt | ||
| README.md | ||
PostgreSQL Database Management System
This directory contains the source code distribution of the PostgreSQL database management system.
PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.
Copyright and license information can be found in the file COPYRIGHT.
General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/devel/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/devel/installation.html.
The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.