PostgreSQL Source Code  git master
predtest.h File Reference
#include "nodes/primnodes.h"
Include dependency graph for predtest.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool predicate_implied_by (List *predicate_list, List *clause_list, bool weak)
 
bool predicate_refuted_by (List *predicate_list, List *clause_list, bool weak)
 

Function Documentation

◆ predicate_implied_by()

bool predicate_implied_by ( List predicate_list,
List clause_list,
bool  weak 
)

Definition at line 149 of file predtest.c.

References linitial, list_length(), NIL, and predicate_implied_by_recurse().

Referenced by add_predicate_to_quals(), build_paths_for_OR(), check_index_predicates(), choose_bitmap_and(), create_bitmap_scan_plan(), create_bitmap_subplan(), create_indexscan_plan(), gincostestimate(), infer_arbiter_indexes(), PartConstraintImpliedByRelConstraint(), and test_predtest().

151 {
152  Node *p,
153  *c;
154 
155  if (predicate_list == NIL)
156  return true; /* no predicate: implication is vacuous */
157  if (clause_list == NIL)
158  return false; /* no restriction: implication must fail */
159 
160  /*
161  * If either input is a single-element list, replace it with its lone
162  * member; this avoids one useless level of AND-recursion. We only need
163  * to worry about this at top level, since eval_const_expressions should
164  * have gotten rid of any trivial ANDs or ORs below that.
165  */
166  if (list_length(predicate_list) == 1)
167  p = (Node *) linitial(predicate_list);
168  else
169  p = (Node *) predicate_list;
170  if (list_length(clause_list) == 1)
171  c = (Node *) linitial(clause_list);
172  else
173  c = (Node *) clause_list;
174 
175  /* And away we go ... */
176  return predicate_implied_by_recurse(c, p, weak);
177 }
#define NIL
Definition: pg_list.h:69
Definition: nodes.h:517
#define linitial(l)
Definition: pg_list.h:111
char * c
static int list_length(const List *l)
Definition: pg_list.h:89
static bool predicate_implied_by_recurse(Node *clause, Node *predicate, bool weak)
Definition: predtest.c:287

◆ predicate_refuted_by()

bool predicate_refuted_by ( List predicate_list,
List clause_list,
bool  weak 
)

Definition at line 219 of file predtest.c.

References linitial, list_length(), NIL, and predicate_refuted_by_recurse().

Referenced by gen_partprune_steps_internal(), relation_excluded_by_constraints(), and test_predtest().

221 {
222  Node *p,
223  *c;
224 
225  if (predicate_list == NIL)
226  return false; /* no predicate: no refutation is possible */
227  if (clause_list == NIL)
228  return false; /* no restriction: refutation must fail */
229 
230  /*
231  * If either input is a single-element list, replace it with its lone
232  * member; this avoids one useless level of AND-recursion. We only need
233  * to worry about this at top level, since eval_const_expressions should
234  * have gotten rid of any trivial ANDs or ORs below that.
235  */
236  if (list_length(predicate_list) == 1)
237  p = (Node *) linitial(predicate_list);
238  else
239  p = (Node *) predicate_list;
240  if (list_length(clause_list) == 1)
241  c = (Node *) linitial(clause_list);
242  else
243  c = (Node *) clause_list;
244 
245  /* And away we go ... */
246  return predicate_refuted_by_recurse(c, p, weak);
247 }
#define NIL
Definition: pg_list.h:69
Definition: nodes.h:517
#define linitial(l)
Definition: pg_list.h:111
char * c
static bool predicate_refuted_by_recurse(Node *clause, Node *predicate, bool weak)
Definition: predtest.c:528
static int list_length(const List *l)
Definition: pg_list.h:89