PostgreSQL Source Code  git master
restrictinfo.c File Reference
#include "postgres.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/clauses.h"
#include "optimizer/optimizer.h"
#include "optimizer/restrictinfo.h"
Include dependency graph for restrictinfo.c:

Go to the source code of this file.

Functions

static RestrictInfomake_restrictinfo_internal (PlannerInfo *root, Expr *clause, Expr *orclause, bool is_pushed_down, bool outerjoin_delayed, bool pseudoconstant, Index security_level, Relids required_relids, Relids outer_relids, Relids nullable_relids)
 
static Exprmake_sub_restrictinfos (PlannerInfo *root, Expr *clause, bool is_pushed_down, bool outerjoin_delayed, bool pseudoconstant, Index security_level, Relids required_relids, Relids outer_relids, Relids nullable_relids)
 
RestrictInfomake_restrictinfo (PlannerInfo *root, Expr *clause, bool is_pushed_down, bool outerjoin_delayed, bool pseudoconstant, Index security_level, Relids required_relids, Relids outer_relids, Relids nullable_relids)
 
RestrictInfocommute_restrictinfo (RestrictInfo *rinfo, Oid comm_op)
 
bool restriction_is_or_clause (RestrictInfo *restrictinfo)
 
bool restriction_is_securely_promotable (RestrictInfo *restrictinfo, RelOptInfo *rel)
 
Listget_actual_clauses (List *restrictinfo_list)
 
Listextract_actual_clauses (List *restrictinfo_list, bool pseudoconstant)
 
void extract_actual_join_clauses (List *restrictinfo_list, Relids joinrelids, List **joinquals, List **otherquals)
 
bool join_clause_is_movable_to (RestrictInfo *rinfo, RelOptInfo *baserel)
 
bool join_clause_is_movable_into (RestrictInfo *rinfo, Relids currentrelids, Relids current_and_outer)
 

Function Documentation

◆ commute_restrictinfo()

RestrictInfo* commute_restrictinfo ( RestrictInfo rinfo,
Oid  comm_op 
)

Definition at line 317 of file restrictinfo.c.

References OpExpr::args, Assert, castNode, RestrictInfo::clause, RestrictInfo::hashjoinoperator, InvalidOid, RestrictInfo::left_bucketsize, RestrictInfo::left_ec, RestrictInfo::left_em, RestrictInfo::left_mcvfreq, RestrictInfo::left_relids, linitial, list_length(), list_make2, lsecond, makeNode, NIL, OpExpr::opfuncid, OpExpr::opno, RestrictInfo::orclause, RestrictInfo::right_bucketsize, RestrictInfo::right_ec, RestrictInfo::right_em, RestrictInfo::right_mcvfreq, RestrictInfo::right_relids, and RestrictInfo::scansel_cache.

Referenced by match_opclause_to_indexcol().

318 {
319  RestrictInfo *result;
320  OpExpr *newclause;
321  OpExpr *clause = castNode(OpExpr, rinfo->clause);
322 
323  Assert(list_length(clause->args) == 2);
324 
325  /* flat-copy all the fields of clause ... */
326  newclause = makeNode(OpExpr);
327  memcpy(newclause, clause, sizeof(OpExpr));
328 
329  /* ... and adjust those we need to change to commute it */
330  newclause->opno = comm_op;
331  newclause->opfuncid = InvalidOid;
332  newclause->args = list_make2(lsecond(clause->args),
333  linitial(clause->args));
334 
335  /* likewise, flat-copy all the fields of rinfo ... */
336  result = makeNode(RestrictInfo);
337  memcpy(result, rinfo, sizeof(RestrictInfo));
338 
339  /*
340  * ... and adjust those we need to change. Note in particular that we can
341  * preserve any cached selectivity or cost estimates, since those ought to
342  * be the same for the new clause. Likewise we can keep the source's
343  * parent_ec.
344  */
345  result->clause = (Expr *) newclause;
346  result->left_relids = rinfo->right_relids;
347  result->right_relids = rinfo->left_relids;
348  Assert(result->orclause == NULL);
349  result->left_ec = rinfo->right_ec;
350  result->right_ec = rinfo->left_ec;
351  result->left_em = rinfo->right_em;
352  result->right_em = rinfo->left_em;
353  result->scansel_cache = NIL; /* not worth updating this */
354  if (rinfo->hashjoinoperator == clause->opno)
355  result->hashjoinoperator = comm_op;
356  else
357  result->hashjoinoperator = InvalidOid;
358  result->left_bucketsize = rinfo->right_bucketsize;
359  result->right_bucketsize = rinfo->left_bucketsize;
360  result->left_mcvfreq = rinfo->right_mcvfreq;
361  result->right_mcvfreq = rinfo->left_mcvfreq;
362 
363  return result;
364 }
#define list_make2(x1, x2)
Definition: pg_list.h:208
#define NIL
Definition: pg_list.h:65
Selectivity right_mcvfreq
Definition: pathnodes.h:2058
#define castNode(_type_, nodeptr)
Definition: nodes.h:597
Expr * orclause
Definition: pathnodes.h:2025
Relids left_relids
Definition: pathnodes.h:2021
EquivalenceClass * right_ec
Definition: pathnodes.h:2043
#define lsecond(l)
Definition: pg_list.h:179
#define linitial(l)
Definition: pg_list.h:174
EquivalenceMember * left_em
Definition: pathnodes.h:2044
EquivalenceMember * right_em
Definition: pathnodes.h:2045
Expr * clause
Definition: pathnodes.h:1994
Oid opfuncid
Definition: primnodes.h:538
#define InvalidOid
Definition: postgres_ext.h:36
Selectivity left_bucketsize
Definition: pathnodes.h:2055
#define makeNode(_type_)
Definition: nodes.h:576
Relids right_relids
Definition: pathnodes.h:2022
#define Assert(condition)
Definition: c.h:792
Selectivity left_mcvfreq
Definition: pathnodes.h:2057
Oid hashjoinoperator
Definition: pathnodes.h:2052
static int list_length(const List *l)
Definition: pg_list.h:149
Selectivity right_bucketsize
Definition: pathnodes.h:2056
EquivalenceClass * left_ec
Definition: pathnodes.h:2042
Oid opno
Definition: primnodes.h:537
List * args
Definition: primnodes.h:543
List * scansel_cache
Definition: pathnodes.h:2046

◆ extract_actual_clauses()

List* extract_actual_clauses ( List restrictinfo_list,
bool  pseudoconstant 
)

◆ extract_actual_join_clauses()

void extract_actual_join_clauses ( List restrictinfo_list,
Relids  joinrelids,
List **  joinquals,
List **  otherquals 
)

Definition at line 460 of file restrictinfo.c.

References Assert, RestrictInfo::clause, lappend(), lfirst_node, NIL, RestrictInfo::pseudoconstant, and RINFO_IS_PUSHED_DOWN.

Referenced by create_hashjoin_plan(), create_mergejoin_plan(), and create_nestloop_plan().

464 {
465  ListCell *l;
466 
467  *joinquals = NIL;
468  *otherquals = NIL;
469 
470  foreach(l, restrictinfo_list)
471  {
473 
474  if (RINFO_IS_PUSHED_DOWN(rinfo, joinrelids))
475  {
476  if (!rinfo->pseudoconstant)
477  *otherquals = lappend(*otherquals, rinfo->clause);
478  }
479  else
480  {
481  /* joinquals shouldn't have been marked pseudoconstant */
482  Assert(!rinfo->pseudoconstant);
483  *joinquals = lappend(*joinquals, rinfo->clause);
484  }
485  }
486 }
#define NIL
Definition: pg_list.h:65
bool pseudoconstant
Definition: pathnodes.h:2002
#define lfirst_node(type, lc)
Definition: pg_list.h:172
List * lappend(List *list, void *datum)
Definition: list.c:336
Expr * clause
Definition: pathnodes.h:1994
#define RINFO_IS_PUSHED_DOWN(rinfo, joinrelids)
Definition: pathnodes.h:2071
#define Assert(condition)
Definition: c.h:792

◆ get_actual_clauses()

List* get_actual_clauses ( List restrictinfo_list)

Definition at line 410 of file restrictinfo.c.

References Assert, RestrictInfo::clause, lappend(), lfirst_node, NIL, and RestrictInfo::pseudoconstant.

Referenced by create_bitmap_subplan(), create_hashjoin_plan(), create_join_plan(), and create_mergejoin_plan().

411 {
412  List *result = NIL;
413  ListCell *l;
414 
415  foreach(l, restrictinfo_list)
416  {
418 
419  Assert(!rinfo->pseudoconstant);
420 
421  result = lappend(result, rinfo->clause);
422  }
423  return result;
424 }
#define NIL
Definition: pg_list.h:65
bool pseudoconstant
Definition: pathnodes.h:2002
#define lfirst_node(type, lc)
Definition: pg_list.h:172
List * lappend(List *list, void *datum)
Definition: list.c:336
Expr * clause
Definition: pathnodes.h:1994
#define Assert(condition)
Definition: c.h:792
Definition: pg_list.h:50

◆ join_clause_is_movable_into()

bool join_clause_is_movable_into ( RestrictInfo rinfo,
Relids  currentrelids,
Relids  current_and_outer 
)

Definition at line 588 of file restrictinfo.c.

References bms_is_subset(), bms_overlap(), RestrictInfo::clause_relids, RestrictInfo::nullable_relids, and RestrictInfo::outer_relids.

Referenced by create_nestloop_path(), get_baserel_parampathinfo(), get_joinrel_parampathinfo(), and has_indexed_join_quals().

591 {
592  /* Clause must be evaluable given available context */
593  if (!bms_is_subset(rinfo->clause_relids, current_and_outer))
594  return false;
595 
596  /* Clause must physically reference at least one target rel */
597  if (!bms_overlap(currentrelids, rinfo->clause_relids))
598  return false;
599 
600  /* Cannot move an outer-join clause into the join's outer side */
601  if (bms_overlap(currentrelids, rinfo->outer_relids))
602  return false;
603 
604  /*
605  * Target rel(s) must not be nullable below the clause. This is
606  * approximate, in the safe direction, because the current join might be
607  * above the join where the nulling would happen, in which case the clause
608  * would work correctly here. But we don't have enough info to be sure.
609  */
610  if (bms_overlap(currentrelids, rinfo->nullable_relids))
611  return false;
612 
613  return true;
614 }
Relids clause_relids
Definition: pathnodes.h:2009
Relids outer_relids
Definition: pathnodes.h:2015
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:315
Relids nullable_relids
Definition: pathnodes.h:2018
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:494

◆ join_clause_is_movable_to()

bool join_clause_is_movable_to ( RestrictInfo rinfo,
RelOptInfo baserel 
)

Definition at line 515 of file restrictinfo.c.

References bms_is_member(), bms_overlap(), RestrictInfo::clause_relids, RelOptInfo::lateral_referencers, RestrictInfo::nullable_relids, RestrictInfo::outer_relids, and RelOptInfo::relid.

Referenced by BuildParameterizedTidPaths(), check_index_predicates(), extract_restriction_or_clauses(), match_join_clauses_to_index(), and postgresGetForeignPaths().

516 {
517  /* Clause must physically reference target rel */
518  if (!bms_is_member(baserel->relid, rinfo->clause_relids))
519  return false;
520 
521  /* Cannot move an outer-join clause into the join's outer side */
522  if (bms_is_member(baserel->relid, rinfo->outer_relids))
523  return false;
524 
525  /* Target rel must not be nullable below the clause */
526  if (bms_is_member(baserel->relid, rinfo->nullable_relids))
527  return false;
528 
529  /* Clause must not use any rels with LATERAL references to this rel */
530  if (bms_overlap(baserel->lateral_referencers, rinfo->clause_relids))
531  return false;
532 
533  return true;
534 }
Relids clause_relids
Definition: pathnodes.h:2009
Relids outer_relids
Definition: pathnodes.h:2015
Index relid
Definition: pathnodes.h:694
Relids lateral_referencers
Definition: pathnodes.h:702
Relids nullable_relids
Definition: pathnodes.h:2018
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:494
bool bms_is_member(int x, const Bitmapset *a)
Definition: bitmapset.c:427

◆ make_restrictinfo()

RestrictInfo* make_restrictinfo ( PlannerInfo root,
Expr clause,
bool  is_pushed_down,
bool  outerjoin_delayed,
bool  pseudoconstant,
Index  security_level,
Relids  required_relids,
Relids  outer_relids,
Relids  nullable_relids 
)

Definition at line 61 of file restrictinfo.c.

References Assert, is_andclause(), is_orclause(), make_restrictinfo_internal(), and make_sub_restrictinfos().

Referenced by apply_child_basequals(), build_implied_join_equality(), consider_new_or_clause(), distribute_qual_to_rels(), foreign_grouping_ok(), process_equivalence(), and process_implied_equality().

70 {
71  /*
72  * If it's an OR clause, build a modified copy with RestrictInfos inserted
73  * above each subclause of the top-level AND/OR structure.
74  */
75  if (is_orclause(clause))
76  return (RestrictInfo *) make_sub_restrictinfos(root,
77  clause,
78  is_pushed_down,
79  outerjoin_delayed,
80  pseudoconstant,
81  security_level,
82  required_relids,
83  outer_relids,
84  nullable_relids);
85 
86  /* Shouldn't be an AND clause, else AND/OR flattening messed up */
87  Assert(!is_andclause(clause));
88 
89  return make_restrictinfo_internal(root,
90  clause,
91  NULL,
92  is_pushed_down,
93  outerjoin_delayed,
94  pseudoconstant,
95  security_level,
96  required_relids,
97  outer_relids,
98  nullable_relids);
99 }
static bool is_orclause(const void *clause)
Definition: nodeFuncs.h:106
static RestrictInfo * make_restrictinfo_internal(PlannerInfo *root, Expr *clause, Expr *orclause, bool is_pushed_down, bool outerjoin_delayed, bool pseudoconstant, Index security_level, Relids required_relids, Relids outer_relids, Relids nullable_relids)
Definition: restrictinfo.c:107
static bool is_andclause(const void *clause)
Definition: nodeFuncs.h:97
static Expr * make_sub_restrictinfos(PlannerInfo *root, Expr *clause, bool is_pushed_down, bool outerjoin_delayed, bool pseudoconstant, Index security_level, Relids required_relids, Relids outer_relids, Relids nullable_relids)
Definition: restrictinfo.c:234
#define Assert(condition)
Definition: c.h:792

◆ make_restrictinfo_internal()

static RestrictInfo * make_restrictinfo_internal ( PlannerInfo root,
Expr clause,
Expr orclause,
bool  is_pushed_down,
bool  outerjoin_delayed,
bool  pseudoconstant,
Index  security_level,
Relids  required_relids,
Relids  outer_relids,
Relids  nullable_relids 
)
static

Definition at line 107 of file restrictinfo.c.

References generate_unaccent_rules::args, Assert, bms_is_empty(), bms_overlap(), bms_union(), RestrictInfo::can_join, RestrictInfo::clause, RestrictInfo::clause_relids, contain_leaked_vars(), RestrictInfo::eval_cost, get_leftop(), get_rightop(), RestrictInfo::hashjoinoperator, InvalidOid, is_opclause(), RestrictInfo::is_pushed_down, RestrictInfo::leakproof, RestrictInfo::left_bucketsize, RestrictInfo::left_ec, RestrictInfo::left_em, RestrictInfo::left_mcvfreq, RestrictInfo::left_relids, list_length(), makeNode, RestrictInfo::mergeopfamilies, NIL, RestrictInfo::norm_selec, RestrictInfo::nullable_relids, RestrictInfo::orclause, RestrictInfo::outer_is_left, RestrictInfo::outer_relids, RestrictInfo::outer_selec, RestrictInfo::outerjoin_delayed, RestrictInfo::parent_ec, RestrictInfo::pseudoconstant, pull_varnos(), RestrictInfo::required_relids, RestrictInfo::right_bucketsize, RestrictInfo::right_ec, RestrictInfo::right_em, RestrictInfo::right_mcvfreq, RestrictInfo::right_relids, RestrictInfo::scansel_cache, RestrictInfo::security_level, and QualCost::startup.

Referenced by make_restrictinfo(), and make_sub_restrictinfos().

117 {
118  RestrictInfo *restrictinfo = makeNode(RestrictInfo);
119 
120  restrictinfo->clause = clause;
121  restrictinfo->orclause = orclause;
122  restrictinfo->is_pushed_down = is_pushed_down;
123  restrictinfo->outerjoin_delayed = outerjoin_delayed;
124  restrictinfo->pseudoconstant = pseudoconstant;
125  restrictinfo->can_join = false; /* may get set below */
126  restrictinfo->security_level = security_level;
127  restrictinfo->outer_relids = outer_relids;
128  restrictinfo->nullable_relids = nullable_relids;
129 
130  /*
131  * If it's potentially delayable by lower-level security quals, figure out
132  * whether it's leakproof. We can skip testing this for level-zero quals,
133  * since they would never get delayed on security grounds anyway.
134  */
135  if (security_level > 0)
136  restrictinfo->leakproof = !contain_leaked_vars((Node *) clause);
137  else
138  restrictinfo->leakproof = false; /* really, "don't know" */
139 
140  /*
141  * If it's a binary opclause, set up left/right relids info. In any case
142  * set up the total clause relids info.
143  */
144  if (is_opclause(clause) && list_length(((OpExpr *) clause)->args) == 2)
145  {
146  restrictinfo->left_relids = pull_varnos(root, get_leftop(clause));
147  restrictinfo->right_relids = pull_varnos(root, get_rightop(clause));
148 
149  restrictinfo->clause_relids = bms_union(restrictinfo->left_relids,
150  restrictinfo->right_relids);
151 
152  /*
153  * Does it look like a normal join clause, i.e., a binary operator
154  * relating expressions that come from distinct relations? If so we
155  * might be able to use it in a join algorithm. Note that this is a
156  * purely syntactic test that is made regardless of context.
157  */
158  if (!bms_is_empty(restrictinfo->left_relids) &&
159  !bms_is_empty(restrictinfo->right_relids) &&
160  !bms_overlap(restrictinfo->left_relids,
161  restrictinfo->right_relids))
162  {
163  restrictinfo->can_join = true;
164  /* pseudoconstant should certainly not be true */
165  Assert(!restrictinfo->pseudoconstant);
166  }
167  }
168  else
169  {
170  /* Not a binary opclause, so mark left/right relid sets as empty */
171  restrictinfo->left_relids = NULL;
172  restrictinfo->right_relids = NULL;
173  /* and get the total relid set the hard way */
174  restrictinfo->clause_relids = pull_varnos(root, (Node *) clause);
175  }
176 
177  /* required_relids defaults to clause_relids */
178  if (required_relids != NULL)
179  restrictinfo->required_relids = required_relids;
180  else
181  restrictinfo->required_relids = restrictinfo->clause_relids;
182 
183  /*
184  * Fill in all the cacheable fields with "not yet set" markers. None of
185  * these will be computed until/unless needed. Note in particular that we
186  * don't mark a binary opclause as mergejoinable or hashjoinable here;
187  * that happens only if it appears in the right context (top level of a
188  * joinclause list).
189  */
190  restrictinfo->parent_ec = NULL;
191 
192  restrictinfo->eval_cost.startup = -1;
193  restrictinfo->norm_selec = -1;
194  restrictinfo->outer_selec = -1;
195 
196  restrictinfo->mergeopfamilies = NIL;
197 
198  restrictinfo->left_ec = NULL;
199  restrictinfo->right_ec = NULL;
200  restrictinfo->left_em = NULL;
201  restrictinfo->right_em = NULL;
202  restrictinfo->scansel_cache = NIL;
203 
204  restrictinfo->outer_is_left = false;
205 
206  restrictinfo->hashjoinoperator = InvalidOid;
207 
208  restrictinfo->left_bucketsize = -1;
209  restrictinfo->right_bucketsize = -1;
210  restrictinfo->left_mcvfreq = -1;
211  restrictinfo->right_mcvfreq = -1;
212 
213  return restrictinfo;
214 }
QualCost eval_cost
Definition: pathnodes.h:2031
#define NIL
Definition: pg_list.h:65
Relids pull_varnos(PlannerInfo *root, Node *node)
Definition: var.c:97
bool contain_leaked_vars(Node *clause)
Definition: clauses.c:1077
Index security_level
Definition: pathnodes.h:2006
Relids required_relids
Definition: pathnodes.h:2012
Selectivity right_mcvfreq
Definition: pathnodes.h:2058
bool leakproof
Definition: pathnodes.h:2004
Expr * orclause
Definition: pathnodes.h:2025
Relids clause_relids
Definition: pathnodes.h:2009
bool pseudoconstant
Definition: pathnodes.h:2002
Definition: nodes.h:528
Relids left_relids
Definition: pathnodes.h:2021
EquivalenceClass * right_ec
Definition: pathnodes.h:2043
List * mergeopfamilies
Definition: pathnodes.h:2039
Cost startup
Definition: pathnodes.h:45
Relids outer_relids
Definition: pathnodes.h:2015
Selectivity norm_selec
Definition: pathnodes.h:2032
EquivalenceMember * left_em
Definition: pathnodes.h:2044
EquivalenceClass * parent_ec
Definition: pathnodes.h:2028
bool outerjoin_delayed
Definition: pathnodes.h:1998
bool outer_is_left
Definition: pathnodes.h:2049
Selectivity outer_selec
Definition: pathnodes.h:2035
static Node * get_leftop(const void *clause)
Definition: nodeFuncs.h:73
EquivalenceMember * right_em
Definition: pathnodes.h:2045
Expr * clause
Definition: pathnodes.h:1994
bool bms_is_empty(const Bitmapset *a)
Definition: bitmapset.c:701
Relids nullable_relids
Definition: pathnodes.h:2018
static Node * get_rightop(const void *clause)
Definition: nodeFuncs.h:85
#define InvalidOid
Definition: postgres_ext.h:36
bool is_pushed_down
Definition: pathnodes.h:1996
Selectivity left_bucketsize
Definition: pathnodes.h:2055
#define makeNode(_type_)
Definition: nodes.h:576
Relids right_relids
Definition: pathnodes.h:2022
#define Assert(condition)
Definition: c.h:792
Selectivity left_mcvfreq
Definition: pathnodes.h:2057
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:225
Oid hashjoinoperator
Definition: pathnodes.h:2052
static int list_length(const List *l)
Definition: pg_list.h:149
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:494
Selectivity right_bucketsize
Definition: pathnodes.h:2056
EquivalenceClass * left_ec
Definition: pathnodes.h:2042
static bool is_opclause(const void *clause)
Definition: nodeFuncs.h:66
List * scansel_cache
Definition: pathnodes.h:2046

◆ make_sub_restrictinfos()

static Expr * make_sub_restrictinfos ( PlannerInfo root,
Expr clause,
bool  is_pushed_down,
bool  outerjoin_delayed,
bool  pseudoconstant,
Index  security_level,
Relids  required_relids,
Relids  outer_relids,
Relids  nullable_relids 
)
static

Definition at line 234 of file restrictinfo.c.

References generate_unaccent_rules::args, is_andclause(), is_orclause(), lappend(), lfirst, make_andclause(), make_orclause(), make_restrictinfo_internal(), and NIL.

Referenced by make_restrictinfo().

243 {
244  if (is_orclause(clause))
245  {
246  List *orlist = NIL;
247  ListCell *temp;
248 
249  foreach(temp, ((BoolExpr *) clause)->args)
250  orlist = lappend(orlist,
252  lfirst(temp),
253  is_pushed_down,
254  outerjoin_delayed,
255  pseudoconstant,
256  security_level,
257  NULL,
258  outer_relids,
259  nullable_relids));
260  return (Expr *) make_restrictinfo_internal(root,
261  clause,
262  make_orclause(orlist),
263  is_pushed_down,
264  outerjoin_delayed,
265  pseudoconstant,
266  security_level,
267  required_relids,
268  outer_relids,
269  nullable_relids);
270  }
271  else if (is_andclause(clause))
272  {
273  List *andlist = NIL;
274  ListCell *temp;
275 
276  foreach(temp, ((BoolExpr *) clause)->args)
277  andlist = lappend(andlist,
279  lfirst(temp),
280  is_pushed_down,
281  outerjoin_delayed,
282  pseudoconstant,
283  security_level,
284  required_relids,
285  outer_relids,
286  nullable_relids));
287  return make_andclause(andlist);
288  }
289  else
290  return (Expr *) make_restrictinfo_internal(root,
291  clause,
292  NULL,
293  is_pushed_down,
294  outerjoin_delayed,
295  pseudoconstant,
296  security_level,
297  required_relids,
298  outer_relids,
299  nullable_relids);
300 }
#define NIL
Definition: pg_list.h:65
static bool is_orclause(const void *clause)
Definition: nodeFuncs.h:106
static RestrictInfo * make_restrictinfo_internal(PlannerInfo *root, Expr *clause, Expr *orclause, bool is_pushed_down, bool outerjoin_delayed, bool pseudoconstant, Index security_level, Relids required_relids, Relids outer_relids, Relids nullable_relids)
Definition: restrictinfo.c:107
static bool is_andclause(const void *clause)
Definition: nodeFuncs.h:97
Expr * make_orclause(List *orclauses)
Definition: makefuncs.c:652
static Expr * make_sub_restrictinfos(PlannerInfo *root, Expr *clause, bool is_pushed_down, bool outerjoin_delayed, bool pseudoconstant, Index security_level, Relids required_relids, Relids outer_relids, Relids nullable_relids)
Definition: restrictinfo.c:234
Expr * make_andclause(List *andclauses)
Definition: makefuncs.c:636
List * lappend(List *list, void *datum)
Definition: list.c:336
#define lfirst(lc)
Definition: pg_list.h:169
Definition: pg_list.h:50

◆ restriction_is_or_clause()

bool restriction_is_or_clause ( RestrictInfo restrictinfo)

Definition at line 372 of file restrictinfo.c.

References RestrictInfo::orclause.

Referenced by extract_or_clause(), extract_restriction_or_clauses(), generate_bitmap_or_paths(), match_join_clauses_to_index(), and TidQualFromRestrictInfoList().

373 {
374  if (restrictinfo->orclause != NULL)
375  return true;
376  else
377  return false;
378 }
Expr * orclause
Definition: pathnodes.h:2025

◆ restriction_is_securely_promotable()

bool restriction_is_securely_promotable ( RestrictInfo restrictinfo,
RelOptInfo rel 
)

Definition at line 387 of file restrictinfo.c.

References RelOptInfo::baserestrict_min_security, RestrictInfo::leakproof, and RestrictInfo::security_level.

Referenced by BuildParameterizedTidPaths(), match_clause_to_index(), and TidQualFromRestrictInfo().

389 {
390  /*
391  * It's okay if there are no baserestrictinfo clauses for the rel that
392  * would need to go before this one, *or* if this one is leakproof.
393  */
394  if (restrictinfo->security_level <= rel->baserestrict_min_security ||
395  restrictinfo->leakproof)
396  return true;
397  else
398  return false;
399 }
Index security_level
Definition: pathnodes.h:2006
bool leakproof
Definition: pathnodes.h:2004
Index baserestrict_min_security
Definition: pathnodes.h:730