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

Go to the source code of this file.

Functions

void extract_restriction_or_clauses (PlannerInfo *root)
 

Function Documentation

◆ extract_restriction_or_clauses()

void extract_restriction_or_clauses ( PlannerInfo root)

Definition at line 75 of file orclauses.c.

76 {
77  Index rti;
78 
79  /* Examine each baserel for potential join OR clauses */
80  for (rti = 1; rti < root->simple_rel_array_size; rti++)
81  {
82  RelOptInfo *rel = root->simple_rel_array[rti];
83  ListCell *lc;
84 
85  /* there may be empty slots corresponding to non-baserel RTEs */
86  if (rel == NULL)
87  continue;
88 
89  Assert(rel->relid == rti); /* sanity check on array */
90 
91  /* ignore RTEs that are "other rels" */
92  if (rel->reloptkind != RELOPT_BASEREL)
93  continue;
94 
95  /*
96  * Find potentially interesting OR joinclauses. We can use any
97  * joinclause that is considered safe to move to this rel by the
98  * parameterized-path machinery, even though what we are going to do
99  * with it is not exactly a parameterized path.
100  */
101  foreach(lc, rel->joininfo)
102  {
103  RestrictInfo *rinfo = (RestrictInfo *) lfirst(lc);
104 
105  if (restriction_is_or_clause(rinfo) &&
106  join_clause_is_movable_to(rinfo, rel))
107  {
108  /* Try to extract a qual for this rel only */
109  Expr *orclause = extract_or_clause(rinfo, rel);
110 
111  /*
112  * If successful, decide whether we want to use the clause,
113  * and insert it into the rel's restrictinfo list if so.
114  */
115  if (orclause)
116  consider_new_or_clause(root, rel, orclause, rinfo);
117  }
118  }
119  }
120 }
#define Assert(condition)
Definition: c.h:858
unsigned int Index
Definition: c.h:614
static void consider_new_or_clause(PlannerInfo *root, RelOptInfo *rel, Expr *orclause, RestrictInfo *join_or_rinfo)
Definition: orclauses.c:254
static Expr * extract_or_clause(RestrictInfo *or_rinfo, RelOptInfo *rel)
Definition: orclauses.c:156
@ RELOPT_BASEREL
Definition: pathnodes.h:817
#define lfirst(lc)
Definition: pg_list.h:172
tree ctl root
Definition: radixtree.h:1880
bool restriction_is_or_clause(RestrictInfo *restrictinfo)
Definition: restrictinfo.c:416
bool join_clause_is_movable_to(RestrictInfo *rinfo, RelOptInfo *baserel)
Definition: restrictinfo.c:584
List * joininfo
Definition: pathnodes.h:981
Index relid
Definition: pathnodes.h:908
RelOptKind reloptkind
Definition: pathnodes.h:855

References Assert, consider_new_or_clause(), extract_or_clause(), join_clause_is_movable_to(), RelOptInfo::joininfo, lfirst, RelOptInfo::relid, RELOPT_BASEREL, RelOptInfo::reloptkind, restriction_is_or_clause(), and root.

Referenced by query_planner().