* 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
| 153 | * Immutability of functions in the clause_list is checked here, if necessary. |
| 154 | */ |
| 155 | bool |
| 156 | predicate_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 |
no test coverage detected