LCOV - differential code coverage report
Current view: top level - src/include/nodes - nodeFuncs.h (source / functions) Coverage Total Hit UIC GBC GIC CBC EUB ECB DCB
Current: Differential Code Coverage HEAD vs 15 Lines: 92.9 % 28 26 2 1 15 10 1 15 1
Current Date: 2023-04-08 15:15:32 Functions: 100.0 % 8 8 8 7 1
Baseline: 15
Baseline Date: 2023-04-08 15:09:40
Legend: Lines: hit not hit

           TLA  Line data    Source code
       1                 : /*-------------------------------------------------------------------------
       2                 :  *
       3                 :  * nodeFuncs.h
       4                 :  *      Various general-purpose manipulations of Node trees
       5                 :  *
       6                 :  * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
       7                 :  * Portions Copyright (c) 1994, Regents of the University of California
       8                 :  *
       9                 :  * src/include/nodes/nodeFuncs.h
      10                 :  *
      11                 :  *-------------------------------------------------------------------------
      12                 :  */
      13                 : #ifndef NODEFUNCS_H
      14                 : #define NODEFUNCS_H
      15                 : 
      16                 : #include "nodes/parsenodes.h"
      17                 : 
      18                 : struct PlanState;               /* avoid including execnodes.h too */
      19                 : 
      20                 : 
      21                 : /* flags bits for query_tree_walker and query_tree_mutator */
      22                 : #define QTW_IGNORE_RT_SUBQUERIES    0x01    /* subqueries in rtable */
      23                 : #define QTW_IGNORE_CTE_SUBQUERIES   0x02    /* subqueries in cteList */
      24                 : #define QTW_IGNORE_RC_SUBQUERIES    0x03    /* both of above */
      25                 : #define QTW_IGNORE_JOINALIASES      0x04    /* JOIN alias var lists */
      26                 : #define QTW_IGNORE_RANGE_TABLE      0x08    /* skip rangetable entirely */
      27                 : #define QTW_EXAMINE_RTES_BEFORE     0x10    /* examine RTE nodes before their
      28                 :                                              * contents */
      29                 : #define QTW_EXAMINE_RTES_AFTER      0x20    /* examine RTE nodes after their
      30                 :                                              * contents */
      31                 : #define QTW_DONT_COPY_QUERY         0x40    /* do not copy top Query */
      32                 : #define QTW_EXAMINE_SORTGROUP       0x80    /* include SortGroupNode lists */
      33                 : 
      34                 : /* callback function for check_functions_in_node */
      35                 : typedef bool (*check_function_callback) (Oid func_id, void *context);
      36                 : 
      37                 : /* callback functions for tree walkers */
      38                 : typedef bool (*tree_walker_callback) (Node *node, void *context);
      39                 : typedef bool (*planstate_tree_walker_callback) (struct PlanState *planstate,
      40                 :                                                 void *context);
      41                 : 
      42                 : /* callback functions for tree mutators */
      43                 : typedef Node *(*tree_mutator_callback) (Node *node, void *context);
      44                 : 
      45                 : 
      46                 : extern Oid  exprType(const Node *expr);
      47                 : extern int32 exprTypmod(const Node *expr);
      48                 : extern bool exprIsLengthCoercion(const Node *expr, int32 *coercedTypmod);
      49                 : extern Node *applyRelabelType(Node *arg, Oid rtype, int32 rtypmod, Oid rcollid,
      50                 :                               CoercionForm rformat, int rlocation,
      51                 :                               bool overwrite_ok);
      52                 : extern Node *relabel_to_typmod(Node *expr, int32 typmod);
      53                 : extern Node *strip_implicit_coercions(Node *node);
      54                 : extern bool expression_returns_set(Node *clause);
      55                 : 
      56                 : extern Oid  exprCollation(const Node *expr);
      57                 : extern Oid  exprInputCollation(const Node *expr);
      58                 : extern void exprSetCollation(Node *expr, Oid collation);
      59                 : extern void exprSetInputCollation(Node *expr, Oid inputcollation);
      60                 : 
      61                 : extern int  exprLocation(const Node *expr);
      62                 : 
      63                 : extern void fix_opfuncids(Node *node);
      64                 : extern void set_opfuncid(OpExpr *opexpr);
      65                 : extern void set_sa_opfuncid(ScalarArrayOpExpr *opexpr);
      66                 : 
      67                 : /* Is clause a FuncExpr clause? */
      68                 : static inline bool
      69 GIC       28809 : is_funcclause(const void *clause)
      70                 : {
      71           28809 :     return clause != NULL && IsA(clause, FuncExpr);
      72                 : }
      73                 : 
      74                 : /* Is clause an OpExpr clause? */
      75                 : static inline bool
      76         1950003 : is_opclause(const void *clause)
      77                 : {
      78         1950003 :     return clause != NULL && IsA(clause, OpExpr);
      79 ECB             : }
      80                 : 
      81                 : /* Extract left arg of a binary opclause, or only arg of a unary opclause */
      82                 : static inline Node *
      83 GIC      625163 : get_leftop(const void *clause)
      84                 : {
      85          625163 :     const OpExpr *expr = (const OpExpr *) clause;
      86 ECB             : 
      87 GIC      625163 :     if (expr->args != NIL)
      88 CBC      625163 :         return (Node *) linitial(expr->args);
      89                 :     else
      90 UIC           0 :         return NULL;
      91                 : }
      92                 : 
      93 ECB             : /* Extract right arg of a binary opclause (NULL if it's a unary opclause) */
      94                 : static inline Node *
      95 CBC      596557 : get_rightop(const void *clause)
      96                 : {
      97          596557 :     const OpExpr *expr = (const OpExpr *) clause;
      98 ECB             : 
      99 GIC      596557 :     if (list_length(expr->args) >= 2)
     100 GBC      596557 :         return (Node *) lsecond(expr->args);
     101                 :     else
     102 UIC           0 :         return NULL;
     103                 : }
     104                 : 
     105 ECB             : /* Is clause an AND clause? */
     106                 : static inline bool
     107 CBC     2437934 : is_andclause(const void *clause)
     108                 : {
     109         2437934 :     return (clause != NULL &&
     110         2609649 :             IsA(clause, BoolExpr) &&
     111 GIC      171715 :             ((const BoolExpr *) clause)->boolop == AND_EXPR);
     112 EUB             : }
     113                 : 
     114                 : /* Is clause an OR clause? */
     115                 : static inline bool
     116 GIC     1643625 : is_orclause(const void *clause)
     117 ECB             : {
     118 GIC     1643625 :     return (clause != NULL &&
     119 CBC     1743854 :             IsA(clause, BoolExpr) &&
     120          100229 :             ((const BoolExpr *) clause)->boolop == OR_EXPR);
     121 ECB             : }
     122                 : 
     123                 : /* Is clause a NOT clause? */
     124                 : static inline bool
     125 GIC      406766 : is_notclause(const void *clause)
     126 ECB             : {
     127 GIC      406766 :     return (clause != NULL &&
     128 CBC      427781 :             IsA(clause, BoolExpr) &&
     129           21015 :             ((const BoolExpr *) clause)->boolop == NOT_EXPR);
     130 ECB             : }
     131                 : 
     132                 : /* Extract argument from a clause known to be a NOT clause */
     133                 : static inline Expr *
     134 GIC        6706 : get_notclausearg(const void *notclause)
     135 ECB             : {
     136 GIC        6706 :     return (Expr *) linitial(((const BoolExpr *) notclause)->args);
     137 ECB             : }
     138                 : 
     139                 : extern bool check_functions_in_node(Node *node, check_function_callback checker,
     140                 :                                     void *context);
     141                 : 
     142                 : /*
     143                 :  * The following functions are usually passed walker or mutator callbacks
     144                 :  * that are declared like "bool walker(Node *node, my_struct *context)"
     145                 :  * rather than "bool walker(Node *node, void *context)" as a strict reading
     146                 :  * of the C standard would require.  Changing the callbacks' declarations
     147                 :  * to "void *" would create serious hazards of passing them the wrong context
     148                 :  * struct type, so we respectfully decline to support the standard's position
     149                 :  * that a pointer to struct is incompatible with "void *".  Instead, silence
     150                 :  * related compiler warnings by inserting casts into these macro wrappers.
     151                 :  */
     152                 : 
     153                 : #define expression_tree_walker(n, w, c) \
     154                 :     expression_tree_walker_impl(n, (tree_walker_callback) (w), c)
     155                 : #define expression_tree_mutator(n, m, c) \
     156                 :     expression_tree_mutator_impl(n, (tree_mutator_callback) (m), c)
     157                 : 
     158                 : #define query_tree_walker(q, w, c, f) \
     159                 :     query_tree_walker_impl(q, (tree_walker_callback) (w), c, f)
     160                 : #define query_tree_mutator(q, m, c, f) \
     161                 :     query_tree_mutator_impl(q, (tree_mutator_callback) (m), c, f)
     162                 : 
     163                 : #define range_table_walker(rt, w, c, f) \
     164                 :     range_table_walker_impl(rt, (tree_walker_callback) (w), c, f)
     165                 : #define range_table_mutator(rt, m, c, f) \
     166                 :     range_table_mutator_impl(rt, (tree_mutator_callback) (m), c, f)
     167                 : 
     168                 : #define range_table_entry_walker(r, w, c, f) \
     169                 :     range_table_entry_walker_impl(r, (tree_walker_callback) (w), c, f)
     170                 : 
     171                 : #define query_or_expression_tree_walker(n, w, c, f) \
     172                 :     query_or_expression_tree_walker_impl(n, (tree_walker_callback) (w), c, f)
     173                 : #define query_or_expression_tree_mutator(n, m, c, f) \
     174                 :     query_or_expression_tree_mutator_impl(n, (tree_mutator_callback) (m), c, f)
     175                 : 
     176                 : #define raw_expression_tree_walker(n, w, c) \
     177                 :     raw_expression_tree_walker_impl(n, (tree_walker_callback) (w), c)
     178                 : 
     179                 : #define planstate_tree_walker(ps, w, c) \
     180                 :     planstate_tree_walker_impl(ps, (planstate_tree_walker_callback) (w), c)
     181                 : 
     182                 : extern bool expression_tree_walker_impl(Node *node,
     183                 :                                         tree_walker_callback walker,
     184                 :                                         void *context);
     185                 : extern Node *expression_tree_mutator_impl(Node *node,
     186                 :                                           tree_mutator_callback mutator,
     187                 :                                           void *context);
     188                 : 
     189                 : extern bool query_tree_walker_impl(Query *query,
     190                 :                                    tree_walker_callback walker,
     191                 :                                    void *context, int flags);
     192                 : extern Query *query_tree_mutator_impl(Query *query,
     193                 :                                       tree_mutator_callback mutator,
     194                 :                                       void *context, int flags);
     195                 : 
     196                 : extern bool range_table_walker_impl(List *rtable,
     197                 :                                     tree_walker_callback walker,
     198                 :                                     void *context, int flags);
     199                 : extern List *range_table_mutator_impl(List *rtable,
     200                 :                                       tree_mutator_callback mutator,
     201                 :                                       void *context, int flags);
     202                 : 
     203                 : extern bool range_table_entry_walker_impl(RangeTblEntry *rte,
     204                 :                                           tree_walker_callback walker,
     205                 :                                           void *context, int flags);
     206                 : 
     207                 : extern bool query_or_expression_tree_walker_impl(Node *node,
     208                 :                                                  tree_walker_callback walker,
     209                 :                                                  void *context, int flags);
     210                 : extern Node *query_or_expression_tree_mutator_impl(Node *node,
     211                 :                                                    tree_mutator_callback mutator,
     212                 :                                                    void *context, int flags);
     213                 : 
     214                 : extern bool raw_expression_tree_walker_impl(Node *node,
     215                 :                                             tree_walker_callback walker,
     216                 :                                             void *context);
     217                 : 
     218                 : extern bool planstate_tree_walker_impl(struct PlanState *planstate,
     219                 :                                        planstate_tree_walker_callback walker,
     220                 :                                        void *context);
     221                 : 
     222                 : #endif                          /* NODEFUNCS_H */
        

Generated by: LCOV version v1.16-55-g56c0a2a