var_is_nonnullable() failed to consider varreturningtype, which meant it could incorrectly claim a Var is non-nullable based on a column's NOT NULL constraint even when the Var refers to a non-existent row. Specifically, OLD.col is NULL for INSERT (no old row exists) and NEW.col is NULL for DELETE (no new row exists), regardless of any NOT NULL constraint on the column. This caused the planner's constant folding in eval_const_expressions to incorrectly simplify IS NULL / IS NOT NULL tests on such Vars. For example, "old.a IS NULL" in an INSERT's RETURNING clause would be folded to false when column "a" has a NOT NULL constraint, even though the correct result is true. Fix by returning false from var_is_nonnullable() when varreturningtype is not VAR_RETURNING_DEFAULT, since such Vars can be NULL regardless of table constraints. Author: SATYANARAYANA NARLAPURAM <satyanarlapuram@gmail.com> Reviewed-by: Tender Wang <tndrwang@gmail.com> Reviewed-by: Richard Guo <guofenglinux@gmail.com> Discussion: https://postgr.es/m/CAHg+QDfaAipL6YzOq2H=gAhKBbcUTYmfbAv+W1zueOfRKH43FQ@mail.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/.