mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Revert: Remove useless self-joins
This commit revertsd3d55ce571
and subsequent fixes2b26a69455
,93c85db3b5
,b44a1708ab
,b7f315c9d7
,8a8ed916f7
,b5fb6736ed
,0a93f803f4
,e0477837ce
,a7928a57b9
,5ef34a8fc3
,30b4955a46
,8c441c0827
,028b15405b
,fe093994db
,489072ab7a
, and466979ef03
. 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:
@ -3440,22 +3440,6 @@ bool
|
||||
relation_has_unique_index_for(PlannerInfo *root, RelOptInfo *rel,
|
||||
List *restrictlist,
|
||||
List *exprlist, List *oprlist)
|
||||
{
|
||||
return relation_has_unique_index_ext(root, rel, restrictlist,
|
||||
exprlist, oprlist, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* relation_has_unique_index_ext
|
||||
* Same as relation_has_unique_index_for(), but supports extra_clauses
|
||||
* parameter. If extra_clauses isn't NULL, return baserestrictinfo clauses
|
||||
* which were used to derive uniqueness.
|
||||
*/
|
||||
bool
|
||||
relation_has_unique_index_ext(PlannerInfo *root, RelOptInfo *rel,
|
||||
List *restrictlist,
|
||||
List *exprlist, List *oprlist,
|
||||
List **extra_clauses)
|
||||
{
|
||||
ListCell *ic;
|
||||
|
||||
@ -3511,7 +3495,6 @@ relation_has_unique_index_ext(PlannerInfo *root, RelOptInfo *rel,
|
||||
{
|
||||
IndexOptInfo *ind = (IndexOptInfo *) lfirst(ic);
|
||||
int c;
|
||||
List *exprs = NIL;
|
||||
|
||||
/*
|
||||
* If the index is not unique, or not immediately enforced, or if it's
|
||||
@ -3563,24 +3546,6 @@ relation_has_unique_index_ext(PlannerInfo *root, RelOptInfo *rel,
|
||||
if (match_index_to_operand(rexpr, c, ind))
|
||||
{
|
||||
matched = true; /* column is unique */
|
||||
|
||||
if (bms_membership(rinfo->clause_relids) == BMS_SINGLETON)
|
||||
{
|
||||
MemoryContext oldMemCtx =
|
||||
MemoryContextSwitchTo(root->planner_cxt);
|
||||
|
||||
/*
|
||||
* Add filter clause into a list allowing caller to
|
||||
* know if uniqueness have made not only by join
|
||||
* clauses.
|
||||
*/
|
||||
Assert(bms_is_empty(rinfo->left_relids) ||
|
||||
bms_is_empty(rinfo->right_relids));
|
||||
if (extra_clauses)
|
||||
exprs = lappend(exprs, rinfo);
|
||||
MemoryContextSwitchTo(oldMemCtx);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -3623,11 +3588,7 @@ relation_has_unique_index_ext(PlannerInfo *root, RelOptInfo *rel,
|
||||
|
||||
/* Matched all key columns of this index? */
|
||||
if (c == ind->nkeycolumns)
|
||||
{
|
||||
if (extra_clauses)
|
||||
*extra_clauses = exprs;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -230,11 +230,6 @@ query_planner(PlannerInfo *root,
|
||||
*/
|
||||
reduce_unique_semijoins(root);
|
||||
|
||||
/*
|
||||
* Remove self joins on a unique column.
|
||||
*/
|
||||
joinlist = remove_useless_self_joins(root, joinlist);
|
||||
|
||||
/*
|
||||
* Now distribute "placeholders" to base rels as needed. This has to be
|
||||
* done after join removal because removal could change whether a
|
||||
|
Reference in New Issue
Block a user