PostgreSQL Source Code git master
restrictinfo.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * restrictinfo.h
4 * prototypes for restrictinfo.c.
5 *
6 *
7 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/optimizer/restrictinfo.h
11 *
12 *-------------------------------------------------------------------------
13 */
14#ifndef RESTRICTINFO_H
15#define RESTRICTINFO_H
16
17#include "nodes/pathnodes.h"
18
19
20/* Convenience macro for the common case of a valid-everywhere qual */
21#define make_simple_restrictinfo(root, clause) \
22 make_restrictinfo(root, clause, true, false, false, false, 0, \
23 NULL, NULL, NULL)
24
26 Expr *clause,
27 Expr *orclause,
28 bool is_pushed_down,
29 bool has_clone,
30 bool is_clone,
31 bool pseudoconstant,
32 Index security_level,
33 Relids required_relids,
34 Relids incompatible_relids,
35 Relids outer_relids);
37 Expr *clause,
38 bool is_pushed_down,
39 bool has_clone,
40 bool is_clone,
41 bool pseudoconstant,
42 Index security_level,
43 Relids required_relids,
44 Relids incompatible_relids,
45 Relids outer_relids);
46extern RestrictInfo *commute_restrictinfo(RestrictInfo *rinfo, Oid comm_op);
47extern bool restriction_is_or_clause(RestrictInfo *restrictinfo);
48extern bool restriction_is_securely_promotable(RestrictInfo *restrictinfo,
49 RelOptInfo *rel);
50extern List *get_actual_clauses(List *restrictinfo_list);
51extern List *extract_actual_clauses(List *restrictinfo_list,
52 bool pseudoconstant);
53extern void extract_actual_join_clauses(List *restrictinfo_list,
54 Relids joinrelids,
55 List **joinquals,
56 List **otherquals);
57extern bool join_clause_is_movable_to(RestrictInfo *rinfo, RelOptInfo *baserel);
59 Relids currentrelids,
60 Relids current_and_outer);
61
62/*
63 * clause_sides_match_join
64 * Determine whether a join clause is of the right form to use in this join.
65 *
66 * We already know that the clause is a binary opclause referencing only the
67 * rels in the current join. The point here is to check whether it has the
68 * form "outerrel_expr op innerrel_expr" or "innerrel_expr op outerrel_expr",
69 * rather than mixing outer and inner vars on either side. If it matches,
70 * we set the transient flag outer_is_left to identify which side is which.
71 */
72static inline bool
74 Relids innerrelids)
75{
76 if (bms_is_subset(rinfo->left_relids, outerrelids) &&
77 bms_is_subset(rinfo->right_relids, innerrelids))
78 {
79 /* lefthand side is outer */
80 rinfo->outer_is_left = true;
81 return true;
82 }
83 else if (bms_is_subset(rinfo->left_relids, innerrelids) &&
84 bms_is_subset(rinfo->right_relids, outerrelids))
85 {
86 /* righthand side is outer */
87 rinfo->outer_is_left = false;
88 return true;
89 }
90 return false; /* no good for these input relations */
91}
92
93#endif /* RESTRICTINFO_H */
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
Definition: bitmapset.c:412
unsigned int Index
Definition: c.h:571
unsigned int Oid
Definition: postgres_ext.h:32
tree ctl root
Definition: radixtree.h:1857
static bool clause_sides_match_join(RestrictInfo *rinfo, Relids outerrelids, Relids innerrelids)
Definition: restrictinfo.h:73
bool restriction_is_or_clause(RestrictInfo *restrictinfo)
Definition: restrictinfo.c:407
List * extract_actual_clauses(List *restrictinfo_list, bool pseudoconstant)
Definition: restrictinfo.c:485
void extract_actual_join_clauses(List *restrictinfo_list, Relids joinrelids, List **joinquals, List **otherquals)
Definition: restrictinfo.c:513
bool restriction_is_securely_promotable(RestrictInfo *restrictinfo, RelOptInfo *rel)
Definition: restrictinfo.c:422
RestrictInfo * make_plain_restrictinfo(PlannerInfo *root, Expr *clause, Expr *orclause, bool is_pushed_down, bool has_clone, bool is_clone, bool pseudoconstant, Index security_level, Relids required_relids, Relids incompatible_relids, Relids outer_relids)
Definition: restrictinfo.c:103
List * get_actual_clauses(List *restrictinfo_list)
Definition: restrictinfo.c:460
bool join_clause_is_movable_into(RestrictInfo *rinfo, Relids currentrelids, Relids current_and_outer)
Definition: restrictinfo.c:661
bool join_clause_is_movable_to(RestrictInfo *rinfo, RelOptInfo *baserel)
Definition: restrictinfo.c:575
RestrictInfo * make_restrictinfo(PlannerInfo *root, Expr *clause, bool is_pushed_down, bool has_clone, bool is_clone, bool pseudoconstant, Index security_level, Relids required_relids, Relids incompatible_relids, Relids outer_relids)
Definition: restrictinfo.c:52
RestrictInfo * commute_restrictinfo(RestrictInfo *rinfo, Oid comm_op)
Definition: restrictinfo.c:350
Definition: pg_list.h:54