The self-join elimination (SJE) commit grafted self-join removal onto remove_rel_from_query(), which was originally written for left-join removal only. This resulted in several issues: - Comments throughout remove_rel_from_query() still assumed only left-join removal, making the code misleading. - ChangeVarNodesExtended was called on phv->phexpr with subst=-1 during left-join removal, which is pointless and confusing since any surviving PHV shouldn't reference the removed rel. - phinfo->ph_lateral was adjusted for left-join removal, which is unnecessary since the removed relid cannot appear in ph_lateral for outer joins. - The comment about attr_needed reconstruction was in remove_rel_from_query(), but the actual rebuild is performed by the callers. - EquivalenceClass processing in remove_rel_from_query() is redundant for self-join removal, since the caller (remove_self_join_rel) already handles ECs via update_eclasses(). - In remove_self_join_rel(), ChangeVarNodesExtended was called on root->processed_groupClause, which contains SortGroupClause nodes that have no Var nodes to rewrite. The accompanying comment incorrectly mentioned "HAVING clause". This patch fixes all these issues, clarifying the separation between left-join removal and self-join elimination code paths within remove_rel_from_query(). The resulting code is also better structured for adding new types of join removal (such as inner-join removal) in the future. Author: Richard Guo <guofenglinux@gmail.com> Reviewed-by: Tender Wang <tndrwang@gmail.com> Reviewed-by: Andrei Lepikhov <lepihov@gmail.com> Reviewed-by: wenhui qiu <qiuwenhuifx@gmail.com> Discussion: https://postgr.es/m/CAMbWs48JC4OVqE=3gMB6se2WmRNNfMyFyYxm-09vgpm+Vwe8Hg@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/.