LCOV - code coverage report
Current view: top level - src/include/optimizer - restrictinfo.h (source / functions) Hit Total Coverage
Test: PostgreSQL 18devel Lines: 10 10 100.0 %
Date: 2024-12-12 20:14:52 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  * restrictinfo.h
       4             :  *    prototypes for restrictinfo.c.
       5             :  *
       6             :  *
       7             :  * Portions Copyright (c) 1996-2024, 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
      73     1505986 : clause_sides_match_join(RestrictInfo *rinfo, Relids outerrelids,
      74             :                         Relids innerrelids)
      75             : {
      76     2250282 :     if (bms_is_subset(rinfo->left_relids, outerrelids) &&
      77      744296 :         bms_is_subset(rinfo->right_relids, innerrelids))
      78             :     {
      79             :         /* lefthand side is outer */
      80      743942 :         rinfo->outer_is_left = true;
      81      743942 :         return true;
      82             :     }
      83     1506200 :     else if (bms_is_subset(rinfo->left_relids, innerrelids) &&
      84      744156 :              bms_is_subset(rinfo->right_relids, outerrelids))
      85             :     {
      86             :         /* righthand side is outer */
      87      698996 :         rinfo->outer_is_left = false;
      88      698996 :         return true;
      89             :     }
      90       63048 :     return false;               /* no good for these input relations */
      91             : }
      92             : 
      93             : #endif                          /* RESTRICTINFO_H */

Generated by: LCOV version 1.14