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-10-30 01:19:11 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_restrictinfo(PlannerInfo *root,
      26             :                                        Expr *clause,
      27             :                                        bool is_pushed_down,
      28             :                                        bool has_clone,
      29             :                                        bool is_clone,
      30             :                                        bool pseudoconstant,
      31             :                                        Index security_level,
      32             :                                        Relids required_relids,
      33             :                                        Relids incompatible_relids,
      34             :                                        Relids outer_relids);
      35             : extern RestrictInfo *commute_restrictinfo(RestrictInfo *rinfo, Oid comm_op);
      36             : extern bool restriction_is_or_clause(RestrictInfo *restrictinfo);
      37             : extern bool restriction_is_securely_promotable(RestrictInfo *restrictinfo,
      38             :                                                RelOptInfo *rel);
      39             : extern List *get_actual_clauses(List *restrictinfo_list);
      40             : extern List *extract_actual_clauses(List *restrictinfo_list,
      41             :                                     bool pseudoconstant);
      42             : extern void extract_actual_join_clauses(List *restrictinfo_list,
      43             :                                         Relids joinrelids,
      44             :                                         List **joinquals,
      45             :                                         List **otherquals);
      46             : extern bool join_clause_is_movable_to(RestrictInfo *rinfo, RelOptInfo *baserel);
      47             : extern bool join_clause_is_movable_into(RestrictInfo *rinfo,
      48             :                                         Relids currentrelids,
      49             :                                         Relids current_and_outer);
      50             : 
      51             : /*
      52             :  * clause_sides_match_join
      53             :  *    Determine whether a join clause is of the right form to use in this join.
      54             :  *
      55             :  * We already know that the clause is a binary opclause referencing only the
      56             :  * rels in the current join.  The point here is to check whether it has the
      57             :  * form "outerrel_expr op innerrel_expr" or "innerrel_expr op outerrel_expr",
      58             :  * rather than mixing outer and inner vars on either side.  If it matches,
      59             :  * we set the transient flag outer_is_left to identify which side is which.
      60             :  */
      61             : static inline bool
      62     1428728 : clause_sides_match_join(RestrictInfo *rinfo, Relids outerrelids,
      63             :                         Relids innerrelids)
      64             : {
      65     2133786 :     if (bms_is_subset(rinfo->left_relids, outerrelids) &&
      66      705058 :         bms_is_subset(rinfo->right_relids, innerrelids))
      67             :     {
      68             :         /* lefthand side is outer */
      69      704704 :         rinfo->outer_is_left = true;
      70      704704 :         return true;
      71             :     }
      72     1430256 :     else if (bms_is_subset(rinfo->left_relids, innerrelids) &&
      73      706232 :              bms_is_subset(rinfo->right_relids, outerrelids))
      74             :     {
      75             :         /* righthand side is outer */
      76      661458 :         rinfo->outer_is_left = false;
      77      661458 :         return true;
      78             :     }
      79       62566 :     return false;               /* no good for these input relations */
      80             : }
      81             : 
      82             : #endif                          /* RESTRICTINFO_H */

Generated by: LCOV version 1.14