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 clause_is_check)
 
bool predicate_refuted_by (List *predicate_list, List *clause_list, bool clause_is_check)
 

Function Documentation

◆ predicate_implied_by()

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

Definition at line 135 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(), and PartConstraintImpliedByRelConstraint().

137 {
138  Node *p,
139  *r;
140 
141  if (predicate_list == NIL)
142  return true; /* no predicate: implication is vacuous */
143  if (clause_list == NIL)
144  return false; /* no restriction: implication must fail */
145 
146  /*
147  * If either input is a single-element list, replace it with its lone
148  * member; this avoids one useless level of AND-recursion. We only need
149  * to worry about this at top level, since eval_const_expressions should
150  * have gotten rid of any trivial ANDs or ORs below that.
151  */
152  if (list_length(predicate_list) == 1)
153  p = (Node *) linitial(predicate_list);
154  else
155  p = (Node *) predicate_list;
156  if (list_length(clause_list) == 1)
157  r = (Node *) linitial(clause_list);
158  else
159  r = (Node *) clause_list;
160 
161  /* And away we go ... */
162  return predicate_implied_by_recurse(r, p, clause_is_check);
163 }
#define NIL
Definition: pg_list.h:69
Definition: nodes.h:512
#define linitial(l)
Definition: pg_list.h:111
static int list_length(const List *l)
Definition: pg_list.h:89
static bool predicate_implied_by_recurse(Node *clause, Node *predicate, bool clause_is_check)
Definition: predtest.c:263

◆ predicate_refuted_by()

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

Definition at line 197 of file predtest.c.

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

Referenced by relation_excluded_by_constraints().

199 {
200  Node *p,
201  *r;
202 
203  if (predicate_list == NIL)
204  return false; /* no predicate: no refutation is possible */
205  if (clause_list == NIL)
206  return false; /* no restriction: refutation must fail */
207 
208  /*
209  * If either input is a single-element list, replace it with its lone
210  * member; this avoids one useless level of AND-recursion. We only need
211  * to worry about this at top level, since eval_const_expressions should
212  * have gotten rid of any trivial ANDs or ORs below that.
213  */
214  if (list_length(predicate_list) == 1)
215  p = (Node *) linitial(predicate_list);
216  else
217  p = (Node *) predicate_list;
218  if (list_length(clause_list) == 1)
219  r = (Node *) linitial(clause_list);
220  else
221  r = (Node *) clause_list;
222 
223  /* And away we go ... */
224  return predicate_refuted_by_recurse(r, p, clause_is_check);
225 }
#define NIL
Definition: pg_list.h:69
Definition: nodes.h:512
#define linitial(l)
Definition: pg_list.h:111
static bool predicate_refuted_by_recurse(Node *clause, Node *predicate, bool clause_is_check)
Definition: predtest.c:503
static int list_length(const List *l)
Definition: pg_list.h:89