Age Owner Branch data TLA Line data Source code
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 : :
25 : : extern RestrictInfo *make_plain_restrictinfo(PlannerInfo *root,
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);
36 : : extern RestrictInfo *make_restrictinfo(PlannerInfo *root,
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);
46 : : extern RestrictInfo *commute_restrictinfo(RestrictInfo *rinfo, Oid comm_op);
47 : : extern bool restriction_is_or_clause(RestrictInfo *restrictinfo);
48 : : extern bool restriction_is_securely_promotable(RestrictInfo *restrictinfo,
49 : : RelOptInfo *rel);
50 : : extern List *get_actual_clauses(List *restrictinfo_list);
51 : : extern List *extract_actual_clauses(List *restrictinfo_list,
52 : : bool pseudoconstant);
53 : : extern void extract_actual_join_clauses(List *restrictinfo_list,
54 : : Relids joinrelids,
55 : : List **joinquals,
56 : : List **otherquals);
57 : : extern bool join_clause_is_movable_to(RestrictInfo *rinfo, RelOptInfo *baserel);
58 : : extern bool join_clause_is_movable_into(RestrictInfo *rinfo,
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 : : */
72 : : static inline bool
326 drowley@postgresql.o 73 :CBC 889888 : clause_sides_match_join(RestrictInfo *rinfo, Relids outerrelids,
74 : : Relids innerrelids)
75 : : {
76 [ + + + + ]: 1330404 : if (bms_is_subset(rinfo->left_relids, outerrelids) &&
77 : 440516 : bms_is_subset(rinfo->right_relids, innerrelids))
78 : : {
79 : : /* lefthand side is outer */
80 : 440284 : rinfo->outer_is_left = true;
81 : 440284 : return true;
82 : : }
83 [ + + + + ]: 891969 : else if (bms_is_subset(rinfo->left_relids, innerrelids) &&
84 : 442365 : bms_is_subset(rinfo->right_relids, outerrelids))
85 : : {
86 : : /* righthand side is outer */
87 : 422168 : rinfo->outer_is_left = false;
88 : 422168 : return true;
89 : : }
90 : 27436 : return false; /* no good for these input relations */
91 : : }
92 : :
93 : : #endif /* RESTRICTINFO_H */
|