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 (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 (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 (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 306 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().

307 {
308  RestrictInfo *result;
309  OpExpr *newclause;
310  OpExpr *clause = castNode(OpExpr, rinfo->clause);
311 
312  Assert(list_length(clause->args) == 2);
313 
314  /* flat-copy all the fields of clause ... */
315  newclause = makeNode(OpExpr);
316  memcpy(newclause, clause, sizeof(OpExpr));
317 
318  /* ... and adjust those we need to change to commute it */
319  newclause->opno = comm_op;
320  newclause->opfuncid = InvalidOid;
321  newclause->args = list_make2(lsecond(clause->args),
322  linitial(clause->args));
323 
324  /* likewise, flat-copy all the fields of rinfo ... */
325  result = makeNode(RestrictInfo);
326  memcpy(result, rinfo, sizeof(RestrictInfo));
327 
328  /*
329  * ... and adjust those we need to change. Note in particular that we can
330  * preserve any cached selectivity or cost estimates, since those ought to
331  * be the same for the new clause. Likewise we can keep the source's
332  * parent_ec.
333  */
334  result->clause = (Expr *) newclause;
335  result->left_relids = rinfo->right_relids;
336  result->right_relids = rinfo->left_relids;
337  Assert(result->orclause == NULL);
338  result->left_ec = rinfo->right_ec;
339  result->right_ec = rinfo->left_ec;
340  result->left_em = rinfo->right_em;
341  result->right_em = rinfo->left_em;
342  result->scansel_cache = NIL; /* not worth updating this */
343  if (rinfo->hashjoinoperator == clause->opno)
344  result->hashjoinoperator = comm_op;
345  else
346  result->hashjoinoperator = InvalidOid;
347  result->left_bucketsize = rinfo->right_bucketsize;
348  result->right_bucketsize = rinfo->left_bucketsize;
349  result->left_mcvfreq = rinfo->right_mcvfreq;
350  result->right_mcvfreq = rinfo->left_mcvfreq;
351 
352  return result;
353 }
#define list_make2(x1, x2)
Definition: pg_list.h:229
#define NIL
Definition: pg_list.h:65
Selectivity right_mcvfreq
Definition: pathnodes.h:2007
#define castNode(_type_, nodeptr)
Definition: nodes.h:594
Expr * orclause
Definition: pathnodes.h:1974
Relids left_relids
Definition: pathnodes.h:1970
EquivalenceClass * right_ec
Definition: pathnodes.h:1992
#define lsecond(l)
Definition: pg_list.h:200
#define linitial(l)
Definition: pg_list.h:195
EquivalenceMember * left_em
Definition: pathnodes.h:1993
EquivalenceMember * right_em
Definition: pathnodes.h:1994
Expr * clause
Definition: pathnodes.h:1943
Oid opfuncid
Definition: primnodes.h:503
#define InvalidOid
Definition: postgres_ext.h:36
Selectivity left_bucketsize
Definition: pathnodes.h:2004
#define makeNode(_type_)
Definition: nodes.h:573
Relids right_relids
Definition: pathnodes.h:1971
#define Assert(condition)
Definition: c.h:732
Selectivity left_mcvfreq
Definition: pathnodes.h:2006
Oid hashjoinoperator
Definition: pathnodes.h:2001
static int list_length(const List *l)
Definition: pg_list.h:169
Selectivity right_bucketsize
Definition: pathnodes.h:2005
EquivalenceClass * left_ec
Definition: pathnodes.h:1991
Oid opno
Definition: primnodes.h:502
List * args
Definition: primnodes.h:508
List * scansel_cache
Definition: pathnodes.h:1995

◆ 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 449 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().

453 {
454  ListCell *l;
455 
456  *joinquals = NIL;
457  *otherquals = NIL;
458 
459  foreach(l, restrictinfo_list)
460  {
462 
463  if (RINFO_IS_PUSHED_DOWN(rinfo, joinrelids))
464  {
465  if (!rinfo->pseudoconstant)
466  *otherquals = lappend(*otherquals, rinfo->clause);
467  }
468  else
469  {
470  /* joinquals shouldn't have been marked pseudoconstant */
471  Assert(!rinfo->pseudoconstant);
472  *joinquals = lappend(*joinquals, rinfo->clause);
473  }
474  }
475 }
#define NIL
Definition: pg_list.h:65
bool pseudoconstant
Definition: pathnodes.h:1951
#define lfirst_node(type, lc)
Definition: pg_list.h:193
List * lappend(List *list, void *datum)
Definition: list.c:322
Expr * clause
Definition: pathnodes.h:1943
#define RINFO_IS_PUSHED_DOWN(rinfo, joinrelids)
Definition: pathnodes.h:2020
#define Assert(condition)
Definition: c.h:732

◆ get_actual_clauses()

List* get_actual_clauses ( List restrictinfo_list)

Definition at line 399 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().

400 {
401  List *result = NIL;
402  ListCell *l;
403 
404  foreach(l, restrictinfo_list)
405  {
407 
408  Assert(!rinfo->pseudoconstant);
409 
410  result = lappend(result, rinfo->clause);
411  }
412  return result;
413 }
#define NIL
Definition: pg_list.h:65
bool pseudoconstant
Definition: pathnodes.h:1951
#define lfirst_node(type, lc)
Definition: pg_list.h:193
List * lappend(List *list, void *datum)
Definition: list.c:322
Expr * clause
Definition: pathnodes.h:1943
#define Assert(condition)
Definition: c.h:732
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 577 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().

580 {
581  /* Clause must be evaluable given available context */
582  if (!bms_is_subset(rinfo->clause_relids, current_and_outer))
583  return false;
584 
585  /* Clause must physically reference at least one target rel */
586  if (!bms_overlap(currentrelids, rinfo->clause_relids))
587  return false;
588 
589  /* Cannot move an outer-join clause into the join's outer side */
590  if (bms_overlap(currentrelids, rinfo->outer_relids))
591  return false;
592 
593  /*
594  * Target rel(s) must not be nullable below the clause. This is
595  * approximate, in the safe direction, because the current join might be
596  * above the join where the nulling would happen, in which case the clause
597  * would work correctly here. But we don't have enough info to be sure.
598  */
599  if (bms_overlap(currentrelids, rinfo->nullable_relids))
600  return false;
601 
602  return true;
603 }
Relids clause_relids
Definition: pathnodes.h:1958
Relids outer_relids
Definition: pathnodes.h:1964
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:315
Relids nullable_relids
Definition: pathnodes.h:1967
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 504 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().

505 {
506  /* Clause must physically reference target rel */
507  if (!bms_is_member(baserel->relid, rinfo->clause_relids))
508  return false;
509 
510  /* Cannot move an outer-join clause into the join's outer side */
511  if (bms_is_member(baserel->relid, rinfo->outer_relids))
512  return false;
513 
514  /* Target rel must not be nullable below the clause */
515  if (bms_is_member(baserel->relid, rinfo->nullable_relids))
516  return false;
517 
518  /* Clause must not use any rels with LATERAL references to this rel */
519  if (bms_overlap(baserel->lateral_referencers, rinfo->clause_relids))
520  return false;
521 
522  return true;
523 }
Relids clause_relids
Definition: pathnodes.h:1958
Relids outer_relids
Definition: pathnodes.h:1964
Index relid
Definition: pathnodes.h:669
Relids lateral_referencers
Definition: pathnodes.h:677
Relids nullable_relids
Definition: pathnodes.h:1967
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 ( 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 59 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(), and process_equivalence().

67 {
68  /*
69  * If it's an OR clause, build a modified copy with RestrictInfos inserted
70  * above each subclause of the top-level AND/OR structure.
71  */
72  if (is_orclause(clause))
73  return (RestrictInfo *) make_sub_restrictinfos(clause,
74  is_pushed_down,
75  outerjoin_delayed,
76  pseudoconstant,
77  security_level,
78  required_relids,
79  outer_relids,
80  nullable_relids);
81 
82  /* Shouldn't be an AND clause, else AND/OR flattening messed up */
83  Assert(!is_andclause(clause));
84 
85  return make_restrictinfo_internal(clause,
86  NULL,
87  is_pushed_down,
88  outerjoin_delayed,
89  pseudoconstant,
90  security_level,
91  required_relids,
92  outer_relids,
93  nullable_relids);
94 }
static bool is_orclause(const void *clause)
Definition: nodeFuncs.h:103
static RestrictInfo * make_restrictinfo_internal(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:102
static bool is_andclause(const void *clause)
Definition: nodeFuncs.h:94
static Expr * make_sub_restrictinfos(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:228
#define Assert(condition)
Definition: c.h:732

◆ make_restrictinfo_internal()

static RestrictInfo * make_restrictinfo_internal ( 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 102 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().

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

◆ make_sub_restrictinfos()

static Expr * make_sub_restrictinfos ( 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 228 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().

236 {
237  if (is_orclause(clause))
238  {
239  List *orlist = NIL;
240  ListCell *temp;
241 
242  foreach(temp, ((BoolExpr *) clause)->args)
243  orlist = lappend(orlist,
245  is_pushed_down,
246  outerjoin_delayed,
247  pseudoconstant,
248  security_level,
249  NULL,
250  outer_relids,
251  nullable_relids));
252  return (Expr *) make_restrictinfo_internal(clause,
253  make_orclause(orlist),
254  is_pushed_down,
255  outerjoin_delayed,
256  pseudoconstant,
257  security_level,
258  required_relids,
259  outer_relids,
260  nullable_relids);
261  }
262  else if (is_andclause(clause))
263  {
264  List *andlist = NIL;
265  ListCell *temp;
266 
267  foreach(temp, ((BoolExpr *) clause)->args)
268  andlist = lappend(andlist,
270  is_pushed_down,
271  outerjoin_delayed,
272  pseudoconstant,
273  security_level,
274  required_relids,
275  outer_relids,
276  nullable_relids));
277  return make_andclause(andlist);
278  }
279  else
280  return (Expr *) make_restrictinfo_internal(clause,
281  NULL,
282  is_pushed_down,
283  outerjoin_delayed,
284  pseudoconstant,
285  security_level,
286  required_relids,
287  outer_relids,
288  nullable_relids);
289 }
#define NIL
Definition: pg_list.h:65
static bool is_orclause(const void *clause)
Definition: nodeFuncs.h:103
static RestrictInfo * make_restrictinfo_internal(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:102
static bool is_andclause(const void *clause)
Definition: nodeFuncs.h:94
Expr * make_orclause(List *orclauses)
Definition: makefuncs.c:649
Expr * make_andclause(List *andclauses)
Definition: makefuncs.c:633
List * lappend(List *list, void *datum)
Definition: list.c:322
static Expr * make_sub_restrictinfos(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:228
#define lfirst(lc)
Definition: pg_list.h:190
Definition: pg_list.h:50

◆ restriction_is_or_clause()

bool restriction_is_or_clause ( RestrictInfo restrictinfo)

Definition at line 361 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().

362 {
363  if (restrictinfo->orclause != NULL)
364  return true;
365  else
366  return false;
367 }
Expr * orclause
Definition: pathnodes.h:1974

◆ restriction_is_securely_promotable()

bool restriction_is_securely_promotable ( RestrictInfo restrictinfo,
RelOptInfo rel 
)

Definition at line 376 of file restrictinfo.c.

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

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

378 {
379  /*
380  * It's okay if there are no baserestrictinfo clauses for the rel that
381  * would need to go before this one, *or* if this one is leakproof.
382  */
383  if (restrictinfo->security_level <= rel->baserestrict_min_security ||
384  restrictinfo->leakproof)
385  return true;
386  else
387  return false;
388 }
Index security_level
Definition: pathnodes.h:1955
bool leakproof
Definition: pathnodes.h:1953
Index baserestrict_min_security
Definition: pathnodes.h:705