From 2a277a9fe8b2031f66fdb4fd8c2e37a2ed525d32 Mon Sep 17 00:00:00 2001 From: "yizhi.fzh" Date: Tue, 2 Apr 2024 09:58:18 +0800 Subject: [PATCH v20240617 07/56] Remove SpecialJoinInfo *sjinfo argument It was passed down to statext_is_supported_join_clause where it is used for checking if it is NULL. However it has been checked before in statext_try_join_estimates. --- src/backend/optimizer/path/clausesel.c | 3 ++- src/backend/statistics/extended_stats.c | 16 ++++++---------- src/include/statistics/statistics.h | 3 +-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/backend/optimizer/path/clausesel.c b/src/backend/optimizer/path/clausesel.c index ec7121be3d1..500a8858162 100644 --- a/src/backend/optimizer/path/clausesel.c +++ b/src/backend/optimizer/path/clausesel.c @@ -225,8 +225,9 @@ clauselist_selectivity_ext(PlannerInfo *root, statext_try_join_estimates(root, clauses, varRelid, jointype, sjinfo)) { Assert(varRelid == 0); + Assert(sjinfo != NULL); s1 *= statext_clauselist_join_selectivity(root, clauses, - jointype, sjinfo, + jointype, &estimatedclauses); } diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index 69a638a18b7..c38ad6d17c5 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -2829,7 +2829,7 @@ statext_determine_join_restrictions(PlannerInfo *root, RelOptInfo *rel, * on the conditions, to make sure it can be estimated using extended stats. */ static bool -statext_is_supported_join_clause(PlannerInfo *root, Node *clause, SpecialJoinInfo *sjinfo) +statext_is_supported_join_clause(PlannerInfo *root, Node *clause) { Oid oprsel; RestrictInfo *rinfo; @@ -2844,10 +2844,6 @@ statext_is_supported_join_clause(PlannerInfo *root, Node *clause, SpecialJoinInf * XXX See treat_as_join_clause. */ - /* duplicated with statext_try_join_estimates */ - if (sjinfo == NULL) - return false; - /* XXX Can we rely on always getting RestrictInfo here? */ if (!IsA(clause, RestrictInfo)) return false; @@ -2974,7 +2970,7 @@ statext_try_join_estimates(PlannerInfo *root, List *clauses, int varRelid, * Skip clauses that are not join clauses or that we don't know how to * handle estimate using extended statistics. */ - if (!statext_is_supported_join_clause(root, clause, sjinfo)) + if (!statext_is_supported_join_clause(root, clause)) continue; /* @@ -3047,7 +3043,7 @@ typedef struct JoinPairInfo */ static JoinPairInfo * statext_build_join_pairs(PlannerInfo *root, List *clauses, - JoinType jointype, SpecialJoinInfo *sjinfo, + JoinType jointype, Bitmapset *estimatedclauses, int *npairs) { int cnt; @@ -3082,7 +3078,7 @@ statext_build_join_pairs(PlannerInfo *root, List *clauses, * moment we support just (Expr op Expr) clauses with each side * referencing just a single relation). */ - if (!statext_is_supported_join_clause(root, clause, sjinfo)) + if (!statext_is_supported_join_clause(root, clause)) continue; /* statext_is_supported_join_clause guarantees RestrictInfo */ @@ -3281,7 +3277,7 @@ get_expression_for_rel(PlannerInfo *root, RelOptInfo *rel, Node *clause) */ Selectivity statext_clauselist_join_selectivity(PlannerInfo *root, List *clauses, - JoinType jointype, SpecialJoinInfo *sjinfo, + JoinType jointype, Bitmapset **estimatedclauses) { int i; @@ -3295,7 +3291,7 @@ statext_clauselist_join_selectivity(PlannerInfo *root, List *clauses, return 1.0; /* extract pairs of joined relations from the list of clauses */ - info = statext_build_join_pairs(root, clauses, jointype, sjinfo, + info = statext_build_join_pairs(root, clauses, jointype, *estimatedclauses, &ninfo); /* no useful join pairs */ diff --git a/src/include/statistics/statistics.h b/src/include/statistics/statistics.h index 4bd3104a2b7..c682a6fb0e8 100644 --- a/src/include/statistics/statistics.h +++ b/src/include/statistics/statistics.h @@ -134,7 +134,6 @@ extern bool statext_try_join_estimates(PlannerInfo *root, List *clauses, int var JoinType jointype, SpecialJoinInfo *sjinfo); extern Selectivity statext_clauselist_join_selectivity(PlannerInfo *root, List *clauses, - JoinType jointype, SpecialJoinInfo *sjinfo, - Bitmapset **estimatedclauses); + JoinType jointype, Bitmapset **estimatedclauses); #endif /* STATISTICS_H */ -- 2.45.2