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 76 of file orclauses.c.

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

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 PlannerInfo::simple_rel_array_size.

Referenced by query_planner().