1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-19 17:02:53 +03:00

Revert: Remove useless self-joins

This commit reverts d3d55ce571 and subsequent fixes 2b26a69455, 93c85db3b5,
b44a1708ab, b7f315c9d7, 8a8ed916f7, b5fb6736ed, 0a93f803f4, e0477837ce,
a7928a57b9, 5ef34a8fc3, 30b4955a46, 8c441c0827, 028b15405b, fe093994db,
489072ab7a, and 466979ef03.

We are quite late in the release cycle and new bugs continue to appear.  Even
though we have fixes for all known bugs, there is a risk of throwing many
bugs to end users.

The plan for self-join elimination would be to do more review and testing,
then re-commit in the early v18 cycle.

Reported-by: Tom Lane
Discussion: https://postgr.es/m/2422119.1714691974%40sss.pgh.pa.us
This commit is contained in:
Alexander Korotkov
2024-05-06 14:35:58 +03:00
parent 81b2252e60
commit d1d286d83c
14 changed files with 69 additions and 2883 deletions

View File

@@ -724,7 +724,7 @@ typedef struct PartitionSchemeData *PartitionScheme;
* populate these fields, for base rels; but someday they might be used for
* join rels too:
*
* unique_for_rels - list of UniqueRelInfo, each one being a set of other
* unique_for_rels - list of Relid sets, each one being a set of other
* rels for which this one has been proven unique
* non_unique_for_rels - list of Relid sets, each one being a set of
* other rels for which we have tried and failed to prove
@@ -963,7 +963,7 @@ typedef struct RelOptInfo
/*
* cache space for remembering if we have proven this relation unique
*/
/* known unique for these other relid set(s) given in UniqueRelInfo(s) */
/* known unique for these other relid set(s) */
List *unique_for_rels;
/* known not unique for these set(s) */
List *non_unique_for_rels;
@@ -3421,35 +3421,4 @@ typedef struct AggTransInfo
bool initValueIsNull;
} AggTransInfo;
/*
* UniqueRelInfo caches a fact that a relation is unique when being joined
* to other relation(s).
*/
typedef struct UniqueRelInfo
{
pg_node_attr(no_copy_equal, no_read, no_query_jumble)
NodeTag type;
/*
* The relation in consideration is unique when being joined with this set
* of other relation(s).
*/
Relids outerrelids;
/*
* The relation in consideration is unique when considering only clauses
* suitable for self-join (passed split_selfjoin_quals()).
*/
bool self_join;
/*
* Additional clauses from a baserestrictinfo list that were used to prove
* the uniqueness. We cache it for the self-join checking procedure: a
* self-join can be removed if the outer relation contains strictly the
* same set of clauses.
*/
List *extra_clauses;
} UniqueRelInfo;
#endif /* PATHNODES_H */