MCPcopy Create free account
hub / github.com/apache/cloudberry / predicate_implied_by

Function predicate_implied_by

src/backend/optimizer/util/predtest.c:155–184  ·  view source on GitHub ↗

* predicate_implied_by * Recursively checks whether the clauses in clause_list imply that the * given predicate is true. * * We support two definitions of implication: * * "Strong" implication: A implies B means that truth of A implies truth of B. * We use this to prove that a row satisfying one WHERE clause or index * predicate must satisfy another one. * * "Weak" implication: A imp

Source from the content-addressed store, hash-verified

153 * Immutability of functions in the clause_list is checked here, if necessary.
154 */
155bool
156predicate_implied_by(List *predicate_list, List *clause_list,
157 bool weak)
158{
159 Node *p,
160 *c;
161
162 if (predicate_list == NIL)
163 return true; /* no predicate: implication is vacuous */
164 if (clause_list == NIL)
165 return false; /* no restriction: implication must fail */
166
167 /*
168 * If either input is a single-element list, replace it with its lone
169 * member; this avoids one useless level of AND-recursion. We only need
170 * to worry about this at top level, since eval_const_expressions should
171 * have gotten rid of any trivial ANDs or ORs below that.
172 */
173 if (list_length(predicate_list) == 1)
174 p = (Node *) linitial(predicate_list);
175 else
176 p = (Node *) predicate_list;
177 if (list_length(clause_list) == 1)
178 c = (Node *) linitial(clause_list);
179 else
180 c = (Node *) clause_list;
181
182 /* And away we go ... */
183 return predicate_implied_by_recurse(c, p, weak);
184}
185
186/*
187 * predicate_refuted_by

Callers 10

create_indexscan_planFunction · 0.85
create_bitmap_scan_planFunction · 0.85
create_bitmap_subplanFunction · 0.85
build_paths_for_ORFunction · 0.85
choose_bitmap_andFunction · 0.85
check_index_predicatesFunction · 0.85
infer_arbiter_indexesFunction · 0.85
test_predtestFunction · 0.85

Calls 2

list_lengthFunction · 0.85

Tested by

no test coverage detected