PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 *restrictinfo_list)
 
bool predicate_refuted_by (List *predicate_list, List *restrictinfo_list)
 

Function Documentation

bool predicate_implied_by ( List predicate_list,
List restrictinfo_list 
)

Definition at line 128 of file predtest.c.

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

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

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

Definition at line 186 of file predtest.c.

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

Referenced by relation_excluded_by_constraints().

187 {
188  Node *p,
189  *r;
190 
191  if (predicate_list == NIL)
192  return false; /* no predicate: no refutation is possible */
193  if (restrictinfo_list == NIL)
194  return false; /* no restriction: refutation must fail */
195 
196  /*
197  * If either input is a single-element list, replace it with its lone
198  * member; this avoids one useless level of AND-recursion. We only need
199  * to worry about this at top level, since eval_const_expressions should
200  * have gotten rid of any trivial ANDs or ORs below that.
201  */
202  if (list_length(predicate_list) == 1)
203  p = (Node *) linitial(predicate_list);
204  else
205  p = (Node *) predicate_list;
206  if (list_length(restrictinfo_list) == 1)
207  r = (Node *) linitial(restrictinfo_list);
208  else
209  r = (Node *) restrictinfo_list;
210 
211  /* And away we go ... */
212  return predicate_refuted_by_recurse(r, p);
213 }
#define NIL
Definition: pg_list.h:69
Definition: nodes.h:508
#define linitial(l)
Definition: pg_list.h:110
static bool predicate_refuted_by_recurse(Node *clause, Node *predicate)
Definition: predtest.c:481
static int list_length(const List *l)
Definition: pg_list.h:89