PostgreSQL Source Code git master
Loading...
Searching...
No Matches
nodeFuncs.h File Reference
#include "nodes/parsenodes.h"
Include dependency graph for nodeFuncs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define QTW_IGNORE_RT_SUBQUERIES   0x01 /* subqueries in rtable */
 
#define QTW_IGNORE_CTE_SUBQUERIES   0x02 /* subqueries in cteList */
 
#define QTW_IGNORE_RC_SUBQUERIES   0x03 /* both of above */
 
#define QTW_IGNORE_JOINALIASES   0x04 /* JOIN alias var lists */
 
#define QTW_IGNORE_RANGE_TABLE   0x08 /* skip rangetable entirely */
 
#define QTW_EXAMINE_RTES_BEFORE
 
#define QTW_EXAMINE_RTES_AFTER
 
#define QTW_DONT_COPY_QUERY   0x40 /* do not copy top Query */
 
#define QTW_EXAMINE_SORTGROUP   0x80 /* include SortGroupClause lists */
 
#define QTW_IGNORE_GROUPEXPRS   0x100 /* GROUP expressions list */
 
#define expression_tree_walker(n, w, c)    expression_tree_walker_impl(n, (tree_walker_callback) (w), c)
 
#define expression_tree_mutator(n, m, c)    expression_tree_mutator_impl(n, (tree_mutator_callback) (m), c)
 
#define query_tree_walker(q, w, c, f)    query_tree_walker_impl(q, (tree_walker_callback) (w), c, f)
 
#define query_tree_mutator(q, m, c, f)    query_tree_mutator_impl(q, (tree_mutator_callback) (m), c, f)
 
#define range_table_walker(rt, w, c, f)    range_table_walker_impl(rt, (tree_walker_callback) (w), c, f)
 
#define range_table_mutator(rt, m, c, f)    range_table_mutator_impl(rt, (tree_mutator_callback) (m), c, f)
 
#define range_table_entry_walker(r, w, c, f)    range_table_entry_walker_impl(r, (tree_walker_callback) (w), c, f)
 
#define query_or_expression_tree_walker(n, w, c, f)    query_or_expression_tree_walker_impl(n, (tree_walker_callback) (w), c, f)
 
#define query_or_expression_tree_mutator(n, m, c, f)    query_or_expression_tree_mutator_impl(n, (tree_mutator_callback) (m), c, f)
 
#define raw_expression_tree_walker(n, w, c)    raw_expression_tree_walker_impl(n, (tree_walker_callback) (w), c)
 
#define planstate_tree_walker(ps, w, c)    planstate_tree_walker_impl(ps, (planstate_tree_walker_callback) (w), c)
 

Typedefs

typedef struct PlanState PlanState
 
typedef bool(* check_function_callback) (Oid func_id, void *context)
 
typedef bool(* tree_walker_callback) (Node *node, void *context)
 
typedef bool(* planstate_tree_walker_callback) (PlanState *planstate, void *context)
 
typedef Node *(* tree_mutator_callback) (Node *node, void *context)
 

Functions

Oid exprType (const Node *expr)
 
int32 exprTypmod (const Node *expr)
 
bool exprIsLengthCoercion (const Node *expr, int32 *coercedTypmod)
 
NodeapplyRelabelType (Node *arg, Oid rtype, int32 rtypmod, Oid rcollid, CoercionForm rformat, int rlocation, bool overwrite_ok)
 
Noderelabel_to_typmod (Node *expr, int32 typmod)
 
Nodestrip_implicit_coercions (Node *node)
 
bool expression_returns_set (Node *clause)
 
Oid exprCollation (const Node *expr)
 
Oid exprInputCollation (const Node *expr)
 
void exprSetCollation (Node *expr, Oid collation)
 
void exprSetInputCollation (Node *expr, Oid inputcollation)
 
int exprLocation (const Node *expr)
 
void fix_opfuncids (Node *node)
 
void set_opfuncid (OpExpr *opexpr)
 
void set_sa_opfuncid (ScalarArrayOpExpr *opexpr)
 
static bool is_funcclause (const void *clause)
 
static bool is_opclause (const void *clause)
 
static Nodeget_leftop (const void *clause)
 
static Nodeget_rightop (const void *clause)
 
static bool is_andclause (const void *clause)
 
static bool is_orclause (const void *clause)
 
static bool is_notclause (const void *clause)
 
static Exprget_notclausearg (const void *notclause)
 
bool check_functions_in_node (Node *node, check_function_callback checker, void *context)
 
bool expression_tree_walker_impl (Node *node, tree_walker_callback walker, void *context)
 
Nodeexpression_tree_mutator_impl (Node *node, tree_mutator_callback mutator, void *context)
 
bool query_tree_walker_impl (Query *query, tree_walker_callback walker, void *context, int flags)
 
Queryquery_tree_mutator_impl (Query *query, tree_mutator_callback mutator, void *context, int flags)
 
bool range_table_walker_impl (List *rtable, tree_walker_callback walker, void *context, int flags)
 
Listrange_table_mutator_impl (List *rtable, tree_mutator_callback mutator, void *context, int flags)
 
bool range_table_entry_walker_impl (RangeTblEntry *rte, tree_walker_callback walker, void *context, int flags)
 
bool query_or_expression_tree_walker_impl (Node *node, tree_walker_callback walker, void *context, int flags)
 
Nodequery_or_expression_tree_mutator_impl (Node *node, tree_mutator_callback mutator, void *context, int flags)
 
bool raw_expression_tree_walker_impl (Node *node, tree_walker_callback walker, void *context)
 
bool planstate_tree_walker_impl (PlanState *planstate, planstate_tree_walker_callback walker, void *context)
 

Macro Definition Documentation

◆ expression_tree_mutator

#define expression_tree_mutator (   n,
  m,
  c 
)     expression_tree_mutator_impl(n, (tree_mutator_callback) (m), c)

Definition at line 155 of file nodeFuncs.h.

◆ expression_tree_walker

#define expression_tree_walker (   n,
  w,
  c 
)     expression_tree_walker_impl(n, (tree_walker_callback) (w), c)

Definition at line 153 of file nodeFuncs.h.

◆ planstate_tree_walker

#define planstate_tree_walker (   ps,
  w,
  c 
)     planstate_tree_walker_impl(ps, (planstate_tree_walker_callback) (w), c)

Definition at line 179 of file nodeFuncs.h.

◆ QTW_DONT_COPY_QUERY

#define QTW_DONT_COPY_QUERY   0x40 /* do not copy top Query */

Definition at line 29 of file nodeFuncs.h.

◆ QTW_EXAMINE_RTES_AFTER

#define QTW_EXAMINE_RTES_AFTER
Value:
0x20 /* examine RTE nodes after their
* contents */

Definition at line 28 of file nodeFuncs.h.

◆ QTW_EXAMINE_RTES_BEFORE

#define QTW_EXAMINE_RTES_BEFORE
Value:
0x10 /* examine RTE nodes before their
* contents */

Definition at line 27 of file nodeFuncs.h.

◆ QTW_EXAMINE_SORTGROUP

#define QTW_EXAMINE_SORTGROUP   0x80 /* include SortGroupClause lists */

Definition at line 30 of file nodeFuncs.h.

◆ QTW_IGNORE_CTE_SUBQUERIES

#define QTW_IGNORE_CTE_SUBQUERIES   0x02 /* subqueries in cteList */

Definition at line 23 of file nodeFuncs.h.

◆ QTW_IGNORE_GROUPEXPRS

#define QTW_IGNORE_GROUPEXPRS   0x100 /* GROUP expressions list */

Definition at line 32 of file nodeFuncs.h.

◆ QTW_IGNORE_JOINALIASES

#define QTW_IGNORE_JOINALIASES   0x04 /* JOIN alias var lists */

Definition at line 25 of file nodeFuncs.h.

◆ QTW_IGNORE_RANGE_TABLE

#define QTW_IGNORE_RANGE_TABLE   0x08 /* skip rangetable entirely */

Definition at line 26 of file nodeFuncs.h.

◆ QTW_IGNORE_RC_SUBQUERIES

#define QTW_IGNORE_RC_SUBQUERIES   0x03 /* both of above */

Definition at line 24 of file nodeFuncs.h.

◆ QTW_IGNORE_RT_SUBQUERIES

#define QTW_IGNORE_RT_SUBQUERIES   0x01 /* subqueries in rtable */

Definition at line 22 of file nodeFuncs.h.

◆ query_or_expression_tree_mutator

#define query_or_expression_tree_mutator (   n,
  m,
  c,
 
)     query_or_expression_tree_mutator_impl(n, (tree_mutator_callback) (m), c, f)

Definition at line 173 of file nodeFuncs.h.

◆ query_or_expression_tree_walker

#define query_or_expression_tree_walker (   n,
  w,
  c,
 
)     query_or_expression_tree_walker_impl(n, (tree_walker_callback) (w), c, f)

Definition at line 171 of file nodeFuncs.h.

◆ query_tree_mutator

#define query_tree_mutator (   q,
  m,
  c,
 
)     query_tree_mutator_impl(q, (tree_mutator_callback) (m), c, f)

Definition at line 160 of file nodeFuncs.h.

◆ query_tree_walker

#define query_tree_walker (   q,
  w,
  c,
 
)     query_tree_walker_impl(q, (tree_walker_callback) (w), c, f)

Definition at line 158 of file nodeFuncs.h.

◆ range_table_entry_walker

#define range_table_entry_walker (   r,
  w,
  c,
 
)     range_table_entry_walker_impl(r, (tree_walker_callback) (w), c, f)

Definition at line 168 of file nodeFuncs.h.

◆ range_table_mutator

#define range_table_mutator (   rt,
  m,
  c,
 
)     range_table_mutator_impl(rt, (tree_mutator_callback) (m), c, f)

Definition at line 165 of file nodeFuncs.h.

◆ range_table_walker

#define range_table_walker (   rt,
  w,
  c,
 
)     range_table_walker_impl(rt, (tree_walker_callback) (w), c, f)

Definition at line 163 of file nodeFuncs.h.

◆ raw_expression_tree_walker

#define raw_expression_tree_walker (   n,
  w,
  c 
)     raw_expression_tree_walker_impl(n, (tree_walker_callback) (w), c)

Definition at line 176 of file nodeFuncs.h.

Typedef Documentation

◆ check_function_callback

typedef bool(* check_function_callback) (Oid func_id, void *context)

Definition at line 35 of file nodeFuncs.h.

◆ PlanState

Definition at line 18 of file nodeFuncs.h.

◆ planstate_tree_walker_callback

typedef bool(* planstate_tree_walker_callback) (PlanState *planstate, void *context)

Definition at line 39 of file nodeFuncs.h.

◆ tree_mutator_callback

typedef Node *(* tree_mutator_callback) (Node *node, void *context)

Definition at line 43 of file nodeFuncs.h.

◆ tree_walker_callback

typedef bool(* tree_walker_callback) (Node *node, void *context)

Definition at line 38 of file nodeFuncs.h.

Function Documentation

◆ applyRelabelType()

Node * applyRelabelType ( Node arg,
Oid  rtype,
int32  rtypmod,
Oid  rcollid,
CoercionForm  rformat,
int  rlocation,
bool  overwrite_ok 
)
extern

Definition at line 641 of file nodeFuncs.c.

643{
644 /*
645 * If we find stacked RelabelTypes (eg, from foo::int::oid) we can discard
646 * all but the top one, and must do so to ensure that semantically
647 * equivalent expressions are equal().
648 */
649 while (arg && IsA(arg, RelabelType))
650 arg = (Node *) ((RelabelType *) arg)->arg;
651
652 if (arg && IsA(arg, Const))
653 {
654 /* Modify the Const directly to preserve const-flatness. */
655 Const *con = (Const *) arg;
656
657 if (!overwrite_ok)
658 con = copyObject(con);
659 con->consttype = rtype;
660 con->consttypmod = rtypmod;
661 con->constcollid = rcollid;
662 /* We keep the Const's original location. */
663 return (Node *) con;
664 }
665 else if (exprType(arg) == rtype &&
666 exprTypmod(arg) == rtypmod &&
668 {
669 /* Sometimes we find a nest of relabels that net out to nothing. */
670 return arg;
671 }
672 else
673 {
674 /* Nope, gotta have a RelabelType. */
676
677 newrelabel->arg = (Expr *) arg;
678 newrelabel->resulttype = rtype;
679 newrelabel->resulttypmod = rtypmod;
680 newrelabel->resultcollid = rcollid;
681 newrelabel->relabelformat = rformat;
682 newrelabel->location = rlocation;
683 return (Node *) newrelabel;
684 }
685}
Datum arg
Definition elog.c:1323
Oid exprType(const Node *expr)
Definition nodeFuncs.c:42
int32 exprTypmod(const Node *expr)
Definition nodeFuncs.c:304
Oid exprCollation(const Node *expr)
Definition nodeFuncs.c:826
#define IsA(nodeptr, _type_)
Definition nodes.h:164
#define copyObject(obj)
Definition nodes.h:232
#define makeNode(_type_)
Definition nodes.h:161
static int fb(int x)
Oid consttype
Definition primnodes.h:330
Definition nodes.h:135

References arg, Const::consttype, copyObject, exprCollation(), exprType(), exprTypmod(), fb(), IsA, and makeNode.

Referenced by canonicalize_ec_expression(), coerce_type_typmod(), eval_const_expressions_mutator(), generate_setop_tlist(), and relabel_to_typmod().

◆ check_functions_in_node()

bool check_functions_in_node ( Node node,
check_function_callback  checker,
void context 
)
extern

Definition at line 1917 of file nodeFuncs.c.

1919{
1920 switch (nodeTag(node))
1921 {
1922 case T_Aggref:
1923 {
1924 Aggref *expr = (Aggref *) node;
1925
1926 if (checker(expr->aggfnoid, context))
1927 return true;
1928 }
1929 break;
1930 case T_WindowFunc:
1931 {
1932 WindowFunc *expr = (WindowFunc *) node;
1933
1934 if (checker(expr->winfnoid, context))
1935 return true;
1936 }
1937 break;
1938 case T_FuncExpr:
1939 {
1940 FuncExpr *expr = (FuncExpr *) node;
1941
1942 if (checker(expr->funcid, context))
1943 return true;
1944 }
1945 break;
1946 case T_OpExpr:
1947 case T_DistinctExpr: /* struct-equivalent to OpExpr */
1948 case T_NullIfExpr: /* struct-equivalent to OpExpr */
1949 {
1950 OpExpr *expr = (OpExpr *) node;
1951
1952 /* Set opfuncid if it wasn't set already */
1953 set_opfuncid(expr);
1954 if (checker(expr->opfuncid, context))
1955 return true;
1956 }
1957 break;
1959 {
1960 ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node;
1961
1962 set_sa_opfuncid(expr);
1963 if (checker(expr->opfuncid, context))
1964 return true;
1965 }
1966 break;
1967 case T_CoerceViaIO:
1968 {
1969 CoerceViaIO *expr = (CoerceViaIO *) node;
1970 Oid iofunc;
1971 Oid typioparam;
1972 bool typisvarlena;
1973
1974 /* check the result type's input function */
1976 &iofunc, &typioparam);
1977 if (checker(iofunc, context))
1978 return true;
1979 /* check the input type's output function */
1981 &iofunc, &typisvarlena);
1982 if (checker(iofunc, context))
1983 return true;
1984 }
1985 break;
1986 case T_RowCompareExpr:
1987 {
1989 ListCell *opid;
1990
1991 foreach(opid, rcexpr->opnos)
1992 {
1994
1995 if (checker(opfuncid, context))
1996 return true;
1997 }
1998 }
1999 break;
2000 default:
2001 break;
2002 }
2003 return false;
2004}
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
Definition lsyscache.c:3102
RegProcedure get_opcode(Oid opno)
Definition lsyscache.c:1478
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
Definition lsyscache.c:3069
void set_sa_opfuncid(ScalarArrayOpExpr *opexpr)
Definition nodeFuncs.c:1890
void set_opfuncid(OpExpr *opexpr)
Definition nodeFuncs.c:1879
#define nodeTag(nodeptr)
Definition nodes.h:139
#define lfirst_oid(lc)
Definition pg_list.h:174
unsigned int Oid
Oid aggfnoid
Definition primnodes.h:464
Oid funcid
Definition primnodes.h:783

References Aggref::aggfnoid, CoerceViaIO::arg, exprType(), fb(), FuncExpr::funcid, get_opcode(), getTypeInputInfo(), getTypeOutputInfo(), lfirst_oid, nodeTag, CoerceViaIO::resulttype, set_opfuncid(), set_sa_opfuncid(), and WindowFunc::winfnoid.

Referenced by check_simple_rowfilter_expr_walker(), check_virtual_generated_security_walker(), contain_leaked_vars_walker(), contain_mutable_functions_walker(), contain_nonstrict_functions_walker(), contain_volatile_functions_not_nextval_walker(), contain_volatile_functions_walker(), and max_parallel_hazard_walker().

◆ exprCollation()

Oid exprCollation ( const Node expr)
extern

Definition at line 826 of file nodeFuncs.c.

827{
828 Oid coll;
829
830 if (!expr)
831 return InvalidOid;
832
833 switch (nodeTag(expr))
834 {
835 case T_Var:
836 coll = ((const Var *) expr)->varcollid;
837 break;
838 case T_Const:
839 coll = ((const Const *) expr)->constcollid;
840 break;
841 case T_Param:
842 coll = ((const Param *) expr)->paramcollid;
843 break;
844 case T_Aggref:
845 coll = ((const Aggref *) expr)->aggcollid;
846 break;
847 case T_GroupingFunc:
849 break;
850 case T_WindowFunc:
851 coll = ((const WindowFunc *) expr)->wincollid;
852 break;
854 coll = ((const MergeSupportFunc *) expr)->msfcollid;
855 break;
857 coll = ((const SubscriptingRef *) expr)->refcollid;
858 break;
859 case T_FuncExpr:
860 coll = ((const FuncExpr *) expr)->funccollid;
861 break;
862 case T_NamedArgExpr:
863 coll = exprCollation((Node *) ((const NamedArgExpr *) expr)->arg);
864 break;
865 case T_OpExpr:
866 coll = ((const OpExpr *) expr)->opcollid;
867 break;
868 case T_DistinctExpr:
869 coll = ((const DistinctExpr *) expr)->opcollid;
870 break;
871 case T_NullIfExpr:
872 coll = ((const NullIfExpr *) expr)->opcollid;
873 break;
875 /* ScalarArrayOpExpr's result is boolean ... */
876 coll = InvalidOid; /* ... so it has no collation */
877 break;
878 case T_BoolExpr:
879 /* BoolExpr's result is boolean ... */
880 coll = InvalidOid; /* ... so it has no collation */
881 break;
882 case T_SubLink:
883 {
884 const SubLink *sublink = (const SubLink *) expr;
885
886 if (sublink->subLinkType == EXPR_SUBLINK ||
887 sublink->subLinkType == ARRAY_SUBLINK)
888 {
889 /* get the collation of subselect's first target column */
890 Query *qtree = (Query *) sublink->subselect;
892
893 if (!qtree || !IsA(qtree, Query))
894 elog(ERROR, "cannot get collation for untransformed sublink");
895 tent = linitial_node(TargetEntry, qtree->targetList);
896 Assert(!tent->resjunk);
897 coll = exprCollation((Node *) tent->expr);
898 /* collation doesn't change if it's converted to array */
899 }
900 else
901 {
902 /* otherwise, SubLink's result is RECORD or BOOLEAN */
903 coll = InvalidOid; /* ... so it has no collation */
904 }
905 }
906 break;
907 case T_SubPlan:
908 {
909 const SubPlan *subplan = (const SubPlan *) expr;
910
911 if (subplan->subLinkType == EXPR_SUBLINK ||
912 subplan->subLinkType == ARRAY_SUBLINK)
913 {
914 /* get the collation of subselect's first target column */
915 coll = subplan->firstColCollation;
916 /* collation doesn't change if it's converted to array */
917 }
918 else
919 {
920 /* otherwise, SubPlan's result is RECORD or BOOLEAN */
921 coll = InvalidOid; /* ... so it has no collation */
922 }
923 }
924 break;
926 {
927 const AlternativeSubPlan *asplan = (const AlternativeSubPlan *) expr;
928
929 /* subplans should all return the same thing */
930 coll = exprCollation((Node *) linitial(asplan->subplans));
931 }
932 break;
933 case T_FieldSelect:
934 coll = ((const FieldSelect *) expr)->resultcollid;
935 break;
936 case T_FieldStore:
937 /* FieldStore's result is composite ... */
938 coll = InvalidOid; /* ... so it has no collation */
939 break;
940 case T_RelabelType:
941 coll = ((const RelabelType *) expr)->resultcollid;
942 break;
943 case T_CoerceViaIO:
944 coll = ((const CoerceViaIO *) expr)->resultcollid;
945 break;
947 coll = ((const ArrayCoerceExpr *) expr)->resultcollid;
948 break;
950 /* ConvertRowtypeExpr's result is composite ... */
951 coll = InvalidOid; /* ... so it has no collation */
952 break;
953 case T_CollateExpr:
954 coll = ((const CollateExpr *) expr)->collOid;
955 break;
956 case T_CaseExpr:
957 coll = ((const CaseExpr *) expr)->casecollid;
958 break;
959 case T_CaseTestExpr:
960 coll = ((const CaseTestExpr *) expr)->collation;
961 break;
962 case T_ArrayExpr:
963 coll = ((const ArrayExpr *) expr)->array_collid;
964 break;
965 case T_RowExpr:
966 /* RowExpr's result is composite ... */
967 coll = InvalidOid; /* ... so it has no collation */
968 break;
969 case T_RowCompareExpr:
970 /* RowCompareExpr's result is boolean ... */
971 coll = InvalidOid; /* ... so it has no collation */
972 break;
973 case T_CoalesceExpr:
974 coll = ((const CoalesceExpr *) expr)->coalescecollid;
975 break;
976 case T_MinMaxExpr:
977 coll = ((const MinMaxExpr *) expr)->minmaxcollid;
978 break;
980 /* Returns either NAME or a non-collatable type */
981 if (((const SQLValueFunction *) expr)->type == NAMEOID)
983 else
985 break;
986 case T_XmlExpr:
987
988 /*
989 * XMLSERIALIZE returns text from non-collatable inputs, so its
990 * collation is always default. The other cases return boolean or
991 * XML, which are non-collatable.
992 */
993 if (((const XmlExpr *) expr)->op == IS_XMLSERIALIZE)
995 else
997 break;
998 case T_JsonValueExpr:
999 coll = exprCollation((Node *) ((const JsonValueExpr *) expr)->formatted_expr);
1000 break;
1002 {
1003 const JsonConstructorExpr *ctor = (const JsonConstructorExpr *) expr;
1004
1005 if (ctor->coercion)
1006 coll = exprCollation((Node *) ctor->coercion);
1007 else
1008 coll = InvalidOid;
1009 }
1010 break;
1011 case T_JsonIsPredicate:
1012 /* IS JSON's result is boolean ... */
1013 coll = InvalidOid; /* ... so it has no collation */
1014 break;
1015 case T_JsonExpr:
1016 {
1017 const JsonExpr *jsexpr = (const JsonExpr *) expr;
1018
1019 coll = jsexpr->collation;
1020 }
1021 break;
1022 case T_JsonBehavior:
1023 {
1024 const JsonBehavior *behavior = (const JsonBehavior *) expr;
1025
1026 if (behavior->expr)
1027 coll = exprCollation(behavior->expr);
1028 else
1029 coll = InvalidOid;
1030 }
1031 break;
1032 case T_NullTest:
1033 /* NullTest's result is boolean ... */
1034 coll = InvalidOid; /* ... so it has no collation */
1035 break;
1036 case T_BooleanTest:
1037 /* BooleanTest's result is boolean ... */
1038 coll = InvalidOid; /* ... so it has no collation */
1039 break;
1040 case T_CoerceToDomain:
1041 coll = ((const CoerceToDomain *) expr)->resultcollid;
1042 break;
1044 coll = ((const CoerceToDomainValue *) expr)->collation;
1045 break;
1046 case T_SetToDefault:
1047 coll = ((const SetToDefault *) expr)->collation;
1048 break;
1049 case T_CurrentOfExpr:
1050 /* CurrentOfExpr's result is boolean ... */
1051 coll = InvalidOid; /* ... so it has no collation */
1052 break;
1053 case T_NextValueExpr:
1054 /* NextValueExpr's result is an integer type ... */
1055 coll = InvalidOid; /* ... so it has no collation */
1056 break;
1057 case T_InferenceElem:
1058 coll = exprCollation((Node *) ((const InferenceElem *) expr)->expr);
1059 break;
1060 case T_ReturningExpr:
1061 coll = exprCollation((Node *) ((const ReturningExpr *) expr)->retexpr);
1062 break;
1063 case T_PlaceHolderVar:
1064 coll = exprCollation((Node *) ((const PlaceHolderVar *) expr)->phexpr);
1065 break;
1066 case T_GraphPropertyRef:
1067 coll = ((const GraphPropertyRef *) expr)->collation;
1068 break;
1069 default:
1070 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(expr));
1071 coll = InvalidOid; /* keep compiler quiet */
1072 break;
1073 }
1074 return coll;
1075}
#define Assert(condition)
Definition c.h:943
#define ERROR
Definition elog.h:40
#define elog(elevel,...)
Definition elog.h:228
#define linitial_node(type, l)
Definition pg_list.h:181
#define linitial(l)
Definition pg_list.h:178
#define InvalidOid
@ ARRAY_SUBLINK
Definition primnodes.h:1036
@ EXPR_SUBLINK
Definition primnodes.h:1034
@ IS_XMLSERIALIZE
Definition primnodes.h:1613
Oid collation
Definition primnodes.h:1884
Oid firstColCollation
Definition primnodes.h:1109
SubLinkType subLinkType
Definition primnodes.h:1098
const char * type

References arg, ARRAY_SUBLINK, Assert, JsonExpr::collation, elog, ERROR, JsonBehavior::expr, EXPR_SUBLINK, exprCollation(), fb(), SubPlan::firstColCollation, InvalidOid, IS_XMLSERIALIZE, IsA, linitial, linitial_node, nodeTag, SubPlan::subLinkType, and type.

Referenced by addRangeTableEntryForFunction(), addRangeTableEntryForGraphTable(), addRangeTableEntryForGroup(), addRangeTableEntryForSubquery(), analyzeCTE(), analyzeCTETargetList(), applyRelabelType(), assign_collations_walker(), assign_hypothetical_collations(), build_expression_pathkey(), build_generation_expression(), build_pertrans_for_aggref(), build_subplan(), canonicalize_ec_expression(), check_simple_rowfilter_expr_walker(), coerce_type_typmod(), ComputeIndexAttrs(), ComputePartitionAttrs(), convert_EXISTS_to_ANY(), create_ctas_nodata(), create_grouping_expr_infos(), create_limit_plan(), create_memoize_plan(), create_windowagg_plan(), DefineVirtualRelation(), eval_const_expressions_mutator(), examine_attribute(), examine_attribute(), examine_expression(), ExecInitFunctionScan(), ExecInitIndexScan(), ExecTypeFromExprList(), ExecTypeFromTLInternal(), expandRecordVariable(), expandRTE(), exprCollation(), exprSetCollation(), extended_statistics_update(), extract_grouping_collations(), fix_indexqual_operand(), generate_query_for_empty_path_pattern(), generate_setop_tlist(), generate_subquery_params(), get_eclass_for_sortgroupclause(), get_expr_result_type(), get_first_col_type(), group_by_has_partkey(), have_partkey_equi_join(), init_grouping_targets(), inline_function(), insert_property_record(), make_pathkey_from_sortop(), make_recursive_union(), make_setop(), make_sort_from_groupcols(), make_sort_from_sortclauses(), makeJsonConstructorExpr(), makeVarFromTargetEntry(), makeWholeRowVar(), mcv_match_expression(), ordered_set_startup(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), preprocess_minmax_aggregates(), relabel_to_typmod(), RelationBuildPartitionKey(), RelationGetDummyIndexExpressions(), remove_unused_subquery_outputs(), replace_nestloop_param_placeholdervar(), replace_outer_placeholdervar(), replace_outer_returning(), scalararraysel(), set_dummy_tlist_references(), set_joinrel_partition_key_exprs(), statatt_get_type(), tlist_same_collations(), transformCaseExpr(), transformFromClauseItem(), transformJsonBehavior(), transformJsonTableColumns(), transformMultiAssignRef(), transformPLAssignStmtTarget(), transformSubLink(), and transformWindowDefinitions().

◆ expression_returns_set()

◆ expression_tree_mutator_impl()

Node * expression_tree_mutator_impl ( Node node,
tree_mutator_callback  mutator,
void context 
)
extern

Definition at line 3004 of file nodeFuncs.c.

3007{
3008 /*
3009 * The mutator has already decided not to modify the current node, but we
3010 * must call the mutator for any sub-nodes.
3011 */
3012
3013#define FLATCOPY(newnode, node, nodetype) \
3014 ( (newnode) = palloc_object(nodetype), \
3015 memcpy((newnode), (node), sizeof(nodetype)) )
3016
3017#define MUTATE(newfield, oldfield, fieldtype) \
3018 ( (newfield) = (fieldtype) mutator((Node *) (oldfield), context) )
3019
3020 if (node == NULL)
3021 return NULL;
3022
3023 /* Guard against stack overflow due to overly complex expressions */
3025
3026 switch (nodeTag(node))
3027 {
3028 /*
3029 * Primitive node types with no expression subnodes. Var and
3030 * Const are frequent enough to deserve special cases, the others
3031 * we just use copyObject for.
3032 */
3033 case T_Var:
3034 {
3035 Var *var = (Var *) node;
3036 Var *newnode;
3037
3038 FLATCOPY(newnode, var, Var);
3039 /* Assume we need not copy the varnullingrels bitmapset */
3040 return (Node *) newnode;
3041 }
3042 break;
3043 case T_Const:
3044 {
3045 Const *oldnode = (Const *) node;
3046 Const *newnode;
3047
3049 /* XXX we don't bother with datumCopy; should we? */
3050 return (Node *) newnode;
3051 }
3052 break;
3053 case T_Param:
3054 case T_CaseTestExpr:
3055 case T_SQLValueFunction:
3056 case T_JsonFormat:
3058 case T_SetToDefault:
3059 case T_CurrentOfExpr:
3060 case T_NextValueExpr:
3061 case T_RangeTblRef:
3062 case T_SortGroupClause:
3063 case T_CTESearchClause:
3064 case T_MergeSupportFunc:
3065 return copyObject(node);
3066 case T_WithCheckOption:
3067 {
3070
3072 MUTATE(newnode->qual, wco->qual, Node *);
3073 return (Node *) newnode;
3074 }
3075 case T_Aggref:
3076 {
3077 Aggref *aggref = (Aggref *) node;
3078 Aggref *newnode;
3079
3080 FLATCOPY(newnode, aggref, Aggref);
3081 /* assume mutation doesn't change types of arguments */
3082 newnode->aggargtypes = list_copy(aggref->aggargtypes);
3083 MUTATE(newnode->aggdirectargs, aggref->aggdirectargs, List *);
3084 MUTATE(newnode->args, aggref->args, List *);
3085 MUTATE(newnode->aggorder, aggref->aggorder, List *);
3086 MUTATE(newnode->aggdistinct, aggref->aggdistinct, List *);
3087 MUTATE(newnode->aggfilter, aggref->aggfilter, Expr *);
3088 return (Node *) newnode;
3089 }
3090 break;
3091 case T_GroupingFunc:
3092 {
3095
3097 MUTATE(newnode->args, grouping->args, List *);
3098
3099 /*
3100 * We assume here that mutating the arguments does not change
3101 * the semantics, i.e. that the arguments are not mutated in a
3102 * way that makes them semantically different from their
3103 * previously matching expressions in the GROUP BY clause.
3104 *
3105 * If a mutator somehow wanted to do this, it would have to
3106 * handle the refs and cols lists itself as appropriate.
3107 */
3108 newnode->refs = list_copy(grouping->refs);
3109 newnode->cols = list_copy(grouping->cols);
3110
3111 return (Node *) newnode;
3112 }
3113 break;
3114 case T_WindowFunc:
3115 {
3116 WindowFunc *wfunc = (WindowFunc *) node;
3118
3119 FLATCOPY(newnode, wfunc, WindowFunc);
3120 MUTATE(newnode->args, wfunc->args, List *);
3121 MUTATE(newnode->aggfilter, wfunc->aggfilter, Expr *);
3122 return (Node *) newnode;
3123 }
3124 break;
3126 {
3129
3131 MUTATE(newnode->arg, wfuncrc->arg, Expr *);
3132 return (Node *) newnode;
3133 }
3134 break;
3135 case T_SubscriptingRef:
3136 {
3137 SubscriptingRef *sbsref = (SubscriptingRef *) node;
3139
3141 MUTATE(newnode->refupperindexpr, sbsref->refupperindexpr,
3142 List *);
3143 MUTATE(newnode->reflowerindexpr, sbsref->reflowerindexpr,
3144 List *);
3145 MUTATE(newnode->refexpr, sbsref->refexpr,
3146 Expr *);
3147 MUTATE(newnode->refassgnexpr, sbsref->refassgnexpr,
3148 Expr *);
3149
3150 return (Node *) newnode;
3151 }
3152 break;
3153 case T_FuncExpr:
3154 {
3155 FuncExpr *expr = (FuncExpr *) node;
3157
3158 FLATCOPY(newnode, expr, FuncExpr);
3159 MUTATE(newnode->args, expr->args, List *);
3160 return (Node *) newnode;
3161 }
3162 break;
3163 case T_NamedArgExpr:
3164 {
3165 NamedArgExpr *nexpr = (NamedArgExpr *) node;
3167
3169 MUTATE(newnode->arg, nexpr->arg, Expr *);
3170 return (Node *) newnode;
3171 }
3172 break;
3173 case T_OpExpr:
3174 {
3175 OpExpr *expr = (OpExpr *) node;
3176 OpExpr *newnode;
3177
3178 FLATCOPY(newnode, expr, OpExpr);
3179 MUTATE(newnode->args, expr->args, List *);
3180 return (Node *) newnode;
3181 }
3182 break;
3183 case T_DistinctExpr:
3184 {
3185 DistinctExpr *expr = (DistinctExpr *) node;
3187
3189 MUTATE(newnode->args, expr->args, List *);
3190 return (Node *) newnode;
3191 }
3192 break;
3193 case T_NullIfExpr:
3194 {
3195 NullIfExpr *expr = (NullIfExpr *) node;
3197
3198 FLATCOPY(newnode, expr, NullIfExpr);
3199 MUTATE(newnode->args, expr->args, List *);
3200 return (Node *) newnode;
3201 }
3202 break;
3204 {
3205 ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node;
3207
3209 MUTATE(newnode->args, expr->args, List *);
3210 return (Node *) newnode;
3211 }
3212 break;
3213 case T_BoolExpr:
3214 {
3215 BoolExpr *expr = (BoolExpr *) node;
3217
3218 FLATCOPY(newnode, expr, BoolExpr);
3219 MUTATE(newnode->args, expr->args, List *);
3220 return (Node *) newnode;
3221 }
3222 break;
3223 case T_SubLink:
3224 {
3225 SubLink *sublink = (SubLink *) node;
3227
3229 MUTATE(newnode->testexpr, sublink->testexpr, Node *);
3230
3231 /*
3232 * Also invoke the mutator on the sublink's Query node, so it
3233 * can recurse into the sub-query if it wants to.
3234 */
3235 MUTATE(newnode->subselect, sublink->subselect, Node *);
3236 return (Node *) newnode;
3237 }
3238 break;
3239 case T_SubPlan:
3240 {
3241 SubPlan *subplan = (SubPlan *) node;
3243
3244 FLATCOPY(newnode, subplan, SubPlan);
3245 /* transform testexpr */
3246 MUTATE(newnode->testexpr, subplan->testexpr, Node *);
3247 /* transform args list (params to be passed to subplan) */
3248 MUTATE(newnode->args, subplan->args, List *);
3249 /* but not the sub-Plan itself, which is referenced as-is */
3250 return (Node *) newnode;
3251 }
3252 break;
3254 {
3257
3259 MUTATE(newnode->subplans, asplan->subplans, List *);
3260 return (Node *) newnode;
3261 }
3262 break;
3263 case T_FieldSelect:
3264 {
3265 FieldSelect *fselect = (FieldSelect *) node;
3267
3269 MUTATE(newnode->arg, fselect->arg, Expr *);
3270 return (Node *) newnode;
3271 }
3272 break;
3273 case T_FieldStore:
3274 {
3275 FieldStore *fstore = (FieldStore *) node;
3277
3278 FLATCOPY(newnode, fstore, FieldStore);
3279 MUTATE(newnode->arg, fstore->arg, Expr *);
3280 MUTATE(newnode->newvals, fstore->newvals, List *);
3281 newnode->fieldnums = list_copy(fstore->fieldnums);
3282 return (Node *) newnode;
3283 }
3284 break;
3285 case T_RelabelType:
3286 {
3287 RelabelType *relabel = (RelabelType *) node;
3289
3291 MUTATE(newnode->arg, relabel->arg, Expr *);
3292 return (Node *) newnode;
3293 }
3294 break;
3295 case T_CoerceViaIO:
3296 {
3297 CoerceViaIO *iocoerce = (CoerceViaIO *) node;
3299
3300 FLATCOPY(newnode, iocoerce, CoerceViaIO);
3301 MUTATE(newnode->arg, iocoerce->arg, Expr *);
3302 return (Node *) newnode;
3303 }
3304 break;
3305 case T_ArrayCoerceExpr:
3306 {
3309
3311 MUTATE(newnode->arg, acoerce->arg, Expr *);
3312 MUTATE(newnode->elemexpr, acoerce->elemexpr, Expr *);
3313 return (Node *) newnode;
3314 }
3315 break;
3317 {
3320
3322 MUTATE(newnode->arg, convexpr->arg, Expr *);
3323 return (Node *) newnode;
3324 }
3325 break;
3326 case T_CollateExpr:
3327 {
3328 CollateExpr *collate = (CollateExpr *) node;
3330
3331 FLATCOPY(newnode, collate, CollateExpr);
3332 MUTATE(newnode->arg, collate->arg, Expr *);
3333 return (Node *) newnode;
3334 }
3335 break;
3336 case T_CaseExpr:
3337 {
3338 CaseExpr *caseexpr = (CaseExpr *) node;
3340
3342 MUTATE(newnode->arg, caseexpr->arg, Expr *);
3343 MUTATE(newnode->args, caseexpr->args, List *);
3344 MUTATE(newnode->defresult, caseexpr->defresult, Expr *);
3345 return (Node *) newnode;
3346 }
3347 break;
3348 case T_CaseWhen:
3349 {
3350 CaseWhen *casewhen = (CaseWhen *) node;
3352
3354 MUTATE(newnode->expr, casewhen->expr, Expr *);
3355 MUTATE(newnode->result, casewhen->result, Expr *);
3356 return (Node *) newnode;
3357 }
3358 break;
3359 case T_ArrayExpr:
3360 {
3361 ArrayExpr *arrayexpr = (ArrayExpr *) node;
3363
3364 FLATCOPY(newnode, arrayexpr, ArrayExpr);
3365 MUTATE(newnode->elements, arrayexpr->elements, List *);
3366 return (Node *) newnode;
3367 }
3368 break;
3369 case T_RowExpr:
3370 {
3371 RowExpr *rowexpr = (RowExpr *) node;
3373
3374 FLATCOPY(newnode, rowexpr, RowExpr);
3375 MUTATE(newnode->args, rowexpr->args, List *);
3376 /* Assume colnames needn't be duplicated */
3377 return (Node *) newnode;
3378 }
3379 break;
3380 case T_RowCompareExpr:
3381 {
3384
3386 MUTATE(newnode->largs, rcexpr->largs, List *);
3387 MUTATE(newnode->rargs, rcexpr->rargs, List *);
3388 return (Node *) newnode;
3389 }
3390 break;
3391 case T_CoalesceExpr:
3392 {
3395
3397 MUTATE(newnode->args, coalesceexpr->args, List *);
3398 return (Node *) newnode;
3399 }
3400 break;
3401 case T_MinMaxExpr:
3402 {
3403 MinMaxExpr *minmaxexpr = (MinMaxExpr *) node;
3405
3407 MUTATE(newnode->args, minmaxexpr->args, List *);
3408 return (Node *) newnode;
3409 }
3410 break;
3411 case T_XmlExpr:
3412 {
3413 XmlExpr *xexpr = (XmlExpr *) node;
3415
3416 FLATCOPY(newnode, xexpr, XmlExpr);
3417 MUTATE(newnode->named_args, xexpr->named_args, List *);
3418 /* assume mutator does not care about arg_names */
3419 MUTATE(newnode->args, xexpr->args, List *);
3420 return (Node *) newnode;
3421 }
3422 break;
3423 case T_JsonReturning:
3424 {
3425 JsonReturning *jr = (JsonReturning *) node;
3427
3429 MUTATE(newnode->format, jr->format, JsonFormat *);
3430
3431 return (Node *) newnode;
3432 }
3433 case T_JsonValueExpr:
3434 {
3435 JsonValueExpr *jve = (JsonValueExpr *) node;
3437
3439 MUTATE(newnode->raw_expr, jve->raw_expr, Expr *);
3440 MUTATE(newnode->formatted_expr, jve->formatted_expr, Expr *);
3441 MUTATE(newnode->format, jve->format, JsonFormat *);
3442
3443 return (Node *) newnode;
3444 }
3446 {
3449
3451 MUTATE(newnode->args, jce->args, List *);
3452 MUTATE(newnode->func, jce->func, Expr *);
3453 MUTATE(newnode->coercion, jce->coercion, Expr *);
3454 MUTATE(newnode->returning, jce->returning, JsonReturning *);
3455
3456 return (Node *) newnode;
3457 }
3458 case T_JsonIsPredicate:
3459 {
3460 JsonIsPredicate *pred = (JsonIsPredicate *) node;
3462
3464 MUTATE(newnode->expr, pred->expr, Node *);
3465 MUTATE(newnode->format, pred->format, JsonFormat *);
3466
3467 return (Node *) newnode;
3468 }
3469 case T_JsonExpr:
3470 {
3471 JsonExpr *jexpr = (JsonExpr *) node;
3473
3475 MUTATE(newnode->formatted_expr, jexpr->formatted_expr, Node *);
3476 MUTATE(newnode->path_spec, jexpr->path_spec, Node *);
3477 MUTATE(newnode->passing_values, jexpr->passing_values, List *);
3478 /* assume mutator does not care about passing_names */
3479 MUTATE(newnode->on_empty, jexpr->on_empty, JsonBehavior *);
3480 MUTATE(newnode->on_error, jexpr->on_error, JsonBehavior *);
3481 return (Node *) newnode;
3482 }
3483 break;
3484 case T_JsonBehavior:
3485 {
3486 JsonBehavior *behavior = (JsonBehavior *) node;
3488
3489 FLATCOPY(newnode, behavior, JsonBehavior);
3490 MUTATE(newnode->expr, behavior->expr, Node *);
3491 return (Node *) newnode;
3492 }
3493 break;
3494 case T_NullTest:
3495 {
3496 NullTest *ntest = (NullTest *) node;
3498
3500 MUTATE(newnode->arg, ntest->arg, Expr *);
3501 return (Node *) newnode;
3502 }
3503 break;
3504 case T_BooleanTest:
3505 {
3506 BooleanTest *btest = (BooleanTest *) node;
3508
3510 MUTATE(newnode->arg, btest->arg, Expr *);
3511 return (Node *) newnode;
3512 }
3513 break;
3514 case T_CoerceToDomain:
3515 {
3518
3520 MUTATE(newnode->arg, ctest->arg, Expr *);
3521 return (Node *) newnode;
3522 }
3523 break;
3524 case T_ReturningExpr:
3525 {
3526 ReturningExpr *rexpr = (ReturningExpr *) node;
3528
3530 MUTATE(newnode->retexpr, rexpr->retexpr, Expr *);
3531 return (Node *) newnode;
3532 }
3533 break;
3534 case T_TargetEntry:
3535 {
3538
3540 MUTATE(newnode->expr, targetentry->expr, Expr *);
3541 return (Node *) newnode;
3542 }
3543 break;
3544 case T_Query:
3545 /* Do nothing with a sub-Query, per discussion above */
3546 return node;
3547 case T_WindowClause:
3548 {
3549 WindowClause *wc = (WindowClause *) node;
3551
3553 MUTATE(newnode->partitionClause, wc->partitionClause, List *);
3554 MUTATE(newnode->orderClause, wc->orderClause, List *);
3555 MUTATE(newnode->startOffset, wc->startOffset, Node *);
3556 MUTATE(newnode->endOffset, wc->endOffset, Node *);
3557 return (Node *) newnode;
3558 }
3559 break;
3560 case T_CTECycleClause:
3561 {
3562 CTECycleClause *cc = (CTECycleClause *) node;
3564
3566 MUTATE(newnode->cycle_mark_value, cc->cycle_mark_value, Node *);
3567 MUTATE(newnode->cycle_mark_default, cc->cycle_mark_default, Node *);
3568 return (Node *) newnode;
3569 }
3570 break;
3571 case T_CommonTableExpr:
3572 {
3573 CommonTableExpr *cte = (CommonTableExpr *) node;
3575
3577
3578 /*
3579 * Also invoke the mutator on the CTE's Query node, so it can
3580 * recurse into the sub-query if it wants to.
3581 */
3582 MUTATE(newnode->ctequery, cte->ctequery, Node *);
3583
3584 MUTATE(newnode->search_clause, cte->search_clause, CTESearchClause *);
3585 MUTATE(newnode->cycle_clause, cte->cycle_clause, CTECycleClause *);
3586
3587 return (Node *) newnode;
3588 }
3589 break;
3591 {
3594
3596 MUTATE(newnode->listdatums, pbs->listdatums, List *);
3597 MUTATE(newnode->lowerdatums, pbs->lowerdatums, List *);
3598 MUTATE(newnode->upperdatums, pbs->upperdatums, List *);
3599 return (Node *) newnode;
3600 }
3601 break;
3603 {
3606
3608 MUTATE(newnode->value, prd->value, Node *);
3609 return (Node *) newnode;
3610 }
3611 break;
3612 case T_List:
3613 {
3614 /*
3615 * We assume the mutator isn't interested in the list nodes
3616 * per se, so just invoke it on each list element. NOTE: this
3617 * would fail badly on a list with integer elements!
3618 */
3620 ListCell *temp;
3621
3622 resultlist = NIL;
3623 foreach(temp, (List *) node)
3624 {
3626 mutator((Node *) lfirst(temp),
3627 context));
3628 }
3629 return (Node *) resultlist;
3630 }
3631 break;
3632 case T_FromExpr:
3633 {
3634 FromExpr *from = (FromExpr *) node;
3636
3637 FLATCOPY(newnode, from, FromExpr);
3638 MUTATE(newnode->fromlist, from->fromlist, List *);
3639 MUTATE(newnode->quals, from->quals, Node *);
3640 return (Node *) newnode;
3641 }
3642 break;
3643 case T_OnConflictExpr:
3644 {
3645 OnConflictExpr *oc = (OnConflictExpr *) node;
3647
3649 MUTATE(newnode->arbiterElems, oc->arbiterElems, List *);
3650 MUTATE(newnode->arbiterWhere, oc->arbiterWhere, Node *);
3651 MUTATE(newnode->onConflictSet, oc->onConflictSet, List *);
3652 MUTATE(newnode->onConflictWhere, oc->onConflictWhere, Node *);
3653 MUTATE(newnode->exclRelTlist, oc->exclRelTlist, List *);
3654
3655 return (Node *) newnode;
3656 }
3657 break;
3658 case T_MergeAction:
3659 {
3660 MergeAction *action = (MergeAction *) node;
3662
3663 FLATCOPY(newnode, action, MergeAction);
3664 MUTATE(newnode->qual, action->qual, Node *);
3665 MUTATE(newnode->targetList, action->targetList, List *);
3666
3667 return (Node *) newnode;
3668 }
3669 break;
3670 case T_ForPortionOfExpr:
3671 {
3674
3676 MUTATE(newnode->rangeVar, fpo->rangeVar, Var *);
3677 MUTATE(newnode->targetFrom, fpo->targetFrom, Node *);
3678 MUTATE(newnode->targetTo, fpo->targetTo, Node *);
3679 MUTATE(newnode->targetRange, fpo->targetRange, Node *);
3680 MUTATE(newnode->overlapsExpr, fpo->overlapsExpr, Node *);
3681 MUTATE(newnode->rangeTargetList, fpo->rangeTargetList, List *);
3682
3683 return (Node *) newnode;
3684 }
3685 break;
3687 {
3690
3692 MUTATE(newnode->exprs, opstep->exprs, List *);
3693
3694 return (Node *) newnode;
3695 }
3696 break;
3698 /* no expression sub-nodes */
3699 return copyObject(node);
3700 case T_JoinExpr:
3701 {
3702 JoinExpr *join = (JoinExpr *) node;
3704
3705 FLATCOPY(newnode, join, JoinExpr);
3706 MUTATE(newnode->larg, join->larg, Node *);
3707 MUTATE(newnode->rarg, join->rarg, Node *);
3708 MUTATE(newnode->quals, join->quals, Node *);
3709 /* We do not mutate alias or using by default */
3710 return (Node *) newnode;
3711 }
3712 break;
3713 case T_SetOperationStmt:
3714 {
3715 SetOperationStmt *setop = (SetOperationStmt *) node;
3717
3719 MUTATE(newnode->larg, setop->larg, Node *);
3720 MUTATE(newnode->rarg, setop->rarg, Node *);
3721 /* We do not mutate groupClauses by default */
3722 return (Node *) newnode;
3723 }
3724 break;
3725 case T_IndexClause:
3726 {
3727 IndexClause *iclause = (IndexClause *) node;
3729
3731 MUTATE(newnode->rinfo, iclause->rinfo, RestrictInfo *);
3732 MUTATE(newnode->indexquals, iclause->indexquals, List *);
3733 return (Node *) newnode;
3734 }
3735 break;
3736 case T_PlaceHolderVar:
3737 {
3738 PlaceHolderVar *phv = (PlaceHolderVar *) node;
3740
3742 MUTATE(newnode->phexpr, phv->phexpr, Expr *);
3743 /* Assume we need not copy the relids bitmapsets */
3744 return (Node *) newnode;
3745 }
3746 break;
3747 case T_InferenceElem:
3748 {
3751
3753 MUTATE(newnode->expr, newnode->expr, Node *);
3754 return (Node *) newnode;
3755 }
3756 break;
3757 case T_AppendRelInfo:
3758 {
3761
3763 MUTATE(newnode->translated_vars, appinfo->translated_vars, List *);
3764 /* Assume nothing need be done with parent_colnos[] */
3765 return (Node *) newnode;
3766 }
3767 break;
3768 case T_PlaceHolderInfo:
3769 {
3772
3774 MUTATE(newnode->ph_var, phinfo->ph_var, PlaceHolderVar *);
3775 /* Assume we need not copy the relids bitmapsets */
3776 return (Node *) newnode;
3777 }
3778 break;
3779 case T_RangeTblFunction:
3780 {
3781 RangeTblFunction *rtfunc = (RangeTblFunction *) node;
3783
3785 MUTATE(newnode->funcexpr, rtfunc->funcexpr, Node *);
3786 /* Assume we need not copy the coldef info lists */
3787 return (Node *) newnode;
3788 }
3789 break;
3791 {
3794
3796 MUTATE(newnode->args, tsc->args, List *);
3797 MUTATE(newnode->repeatable, tsc->repeatable, Expr *);
3798 return (Node *) newnode;
3799 }
3800 break;
3801 case T_TableFunc:
3802 {
3803 TableFunc *tf = (TableFunc *) node;
3805
3807 MUTATE(newnode->ns_uris, tf->ns_uris, List *);
3808 MUTATE(newnode->docexpr, tf->docexpr, Node *);
3809 MUTATE(newnode->rowexpr, tf->rowexpr, Node *);
3810 MUTATE(newnode->colexprs, tf->colexprs, List *);
3811 MUTATE(newnode->coldefexprs, tf->coldefexprs, List *);
3812 MUTATE(newnode->colvalexprs, tf->colvalexprs, List *);
3813 MUTATE(newnode->passingvalexprs, tf->passingvalexprs, List *);
3814 return (Node *) newnode;
3815 }
3816 break;
3817 default:
3818 elog(ERROR, "unrecognized node type: %d",
3819 (int) nodeTag(node));
3820 break;
3821 }
3822 /* can't get here, but keep compiler happy */
3823 return NULL;
3824}
List * lappend(List *list, void *datum)
Definition list.c:339
List * list_copy(const List *oldlist)
Definition list.c:1573
#define FLATCOPY(newnode, node, nodetype)
#define MUTATE(newfield, oldfield, fieldtype)
#define lfirst(lc)
Definition pg_list.h:172
#define NIL
Definition pg_list.h:68
void check_stack_depth(void)
Definition stack_depth.c:95
List * aggdistinct
Definition primnodes.h:494
List * aggdirectargs
Definition primnodes.h:485
List * args
Definition primnodes.h:488
Expr * aggfilter
Definition primnodes.h:497
List * aggorder
Definition primnodes.h:491
List * args
Definition primnodes.h:973
Node * cycle_mark_default
Node * cycle_mark_value
List * newvals
Definition primnodes.h:1195
Expr * arg
Definition primnodes.h:1194
Node * quals
Definition primnodes.h:2385
List * fromlist
Definition primnodes.h:2384
List * args
Definition primnodes.h:801
Node * quals
Definition primnodes.h:2365
Node * larg
Definition primnodes.h:2358
Node * rarg
Definition primnodes.h:2359
JsonFormat * format
Definition primnodes.h:1763
Definition pg_list.h:54
List * args
Definition primnodes.h:869
List * args
Definition primnodes.h:1450
List * args
Definition primnodes.h:1125
Node * testexpr
Definition primnodes.h:1100
Expr * refassgnexpr
Definition primnodes.h:736
List * refupperindexpr
Definition primnodes.h:726
List * reflowerindexpr
Definition primnodes.h:732
Node * docexpr
Definition primnodes.h:121
Node * rowexpr
Definition primnodes.h:123
List * colexprs
Definition primnodes.h:133
Node * startOffset
List * partitionClause
Node * endOffset
List * orderClause
List * args
Definition primnodes.h:606
Expr * aggfilter
Definition primnodes.h:608
List * args
Definition primnodes.h:1635
List * named_args
Definition primnodes.h:1631

References Aggref::aggdirectargs, Aggref::aggdistinct, Aggref::aggfilter, WindowFunc::aggfilter, Aggref::aggorder, FieldStore::arg, CoerceViaIO::arg, CollateExpr::arg, Aggref::args, WindowFunc::args, FuncExpr::args, OpExpr::args, ScalarArrayOpExpr::args, BoolExpr::args, SubPlan::args, RowExpr::args, XmlExpr::args, check_stack_depth(), TableFunc::colexprs, copyObject, CommonTableExpr::ctequery, CTECycleClause::cycle_mark_default, CTECycleClause::cycle_mark_value, TableFunc::docexpr, elog, WindowClause::endOffset, ERROR, JsonIsPredicate::expr, JsonBehavior::expr, fb(), FLATCOPY, JsonIsPredicate::format, FromExpr::fromlist, RangeTblFunction::funcexpr, lappend(), SetOperationStmt::larg, JoinExpr::larg, lfirst, list_copy(), MUTATE, XmlExpr::named_args, FieldStore::newvals, NIL, nodeTag, WindowClause::orderClause, WindowClause::partitionClause, JoinExpr::quals, FromExpr::quals, SetOperationStmt::rarg, JoinExpr::rarg, SubscriptingRef::refassgnexpr, SubscriptingRef::refexpr, SubscriptingRef::reflowerindexpr, SubscriptingRef::refupperindexpr, ReturningExpr::retexpr, TableFunc::rowexpr, WindowClause::startOffset, and SubPlan::testexpr.

◆ expression_tree_walker_impl()

bool expression_tree_walker_impl ( Node node,
tree_walker_callback  walker,
void context 
)
extern

Definition at line 2100 of file nodeFuncs.c.

2103{
2104 ListCell *temp;
2105
2106 /*
2107 * The walker has already visited the current node, and so we need only
2108 * recurse into any sub-nodes it has.
2109 *
2110 * We assume that the walker is not interested in List nodes per se, so
2111 * when we expect a List we just recurse directly to self without
2112 * bothering to call the walker.
2113 */
2114#define WALK(n) walker((Node *) (n), context)
2115
2116#define LIST_WALK(l) expression_tree_walker_impl((Node *) (l), walker, context)
2117
2118 if (node == NULL)
2119 return false;
2120
2121 /* Guard against stack overflow due to overly complex expressions */
2123
2124 switch (nodeTag(node))
2125 {
2126 case T_Var:
2127 case T_Const:
2128 case T_Param:
2129 case T_CaseTestExpr:
2130 case T_SQLValueFunction:
2132 case T_SetToDefault:
2133 case T_CurrentOfExpr:
2134 case T_NextValueExpr:
2135 case T_RangeTblRef:
2136 case T_SortGroupClause:
2137 case T_CTESearchClause:
2138 case T_GraphPropertyRef:
2139 case T_MergeSupportFunc:
2140 /* primitive node types with no expression subnodes */
2141 break;
2142 case T_WithCheckOption:
2143 return WALK(((WithCheckOption *) node)->qual);
2144 case T_Aggref:
2145 {
2146 Aggref *expr = (Aggref *) node;
2147
2148 /* recurse directly on Lists */
2149 if (LIST_WALK(expr->aggdirectargs))
2150 return true;
2151 if (LIST_WALK(expr->args))
2152 return true;
2153 if (LIST_WALK(expr->aggorder))
2154 return true;
2155 if (LIST_WALK(expr->aggdistinct))
2156 return true;
2157 if (WALK(expr->aggfilter))
2158 return true;
2159 }
2160 break;
2161 case T_GroupingFunc:
2162 {
2164
2165 if (LIST_WALK(grouping->args))
2166 return true;
2167 }
2168 break;
2169 case T_WindowFunc:
2170 {
2171 WindowFunc *expr = (WindowFunc *) node;
2172
2173 /* recurse directly on List */
2174 if (LIST_WALK(expr->args))
2175 return true;
2176 if (WALK(expr->aggfilter))
2177 return true;
2178 if (WALK(expr->runCondition))
2179 return true;
2180 }
2181 break;
2183 {
2185
2186 if (WALK(expr->arg))
2187 return true;
2188 }
2189 break;
2190 case T_SubscriptingRef:
2191 {
2192 SubscriptingRef *sbsref = (SubscriptingRef *) node;
2193
2194 /* recurse directly for upper/lower container index lists */
2195 if (LIST_WALK(sbsref->refupperindexpr))
2196 return true;
2197 if (LIST_WALK(sbsref->reflowerindexpr))
2198 return true;
2199 /* walker must see the refexpr and refassgnexpr, however */
2200 if (WALK(sbsref->refexpr))
2201 return true;
2202
2203 if (WALK(sbsref->refassgnexpr))
2204 return true;
2205 }
2206 break;
2207 case T_FuncExpr:
2208 {
2209 FuncExpr *expr = (FuncExpr *) node;
2210
2211 if (LIST_WALK(expr->args))
2212 return true;
2213 }
2214 break;
2215 case T_NamedArgExpr:
2216 return WALK(((NamedArgExpr *) node)->arg);
2217 case T_OpExpr:
2218 case T_DistinctExpr: /* struct-equivalent to OpExpr */
2219 case T_NullIfExpr: /* struct-equivalent to OpExpr */
2220 {
2221 OpExpr *expr = (OpExpr *) node;
2222
2223 if (LIST_WALK(expr->args))
2224 return true;
2225 }
2226 break;
2228 {
2229 ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node;
2230
2231 if (LIST_WALK(expr->args))
2232 return true;
2233 }
2234 break;
2235 case T_BoolExpr:
2236 {
2237 BoolExpr *expr = (BoolExpr *) node;
2238
2239 if (LIST_WALK(expr->args))
2240 return true;
2241 }
2242 break;
2243 case T_SubLink:
2244 {
2245 SubLink *sublink = (SubLink *) node;
2246
2247 if (WALK(sublink->testexpr))
2248 return true;
2249
2250 /*
2251 * Also invoke the walker on the sublink's Query node, so it
2252 * can recurse into the sub-query if it wants to.
2253 */
2254 return WALK(sublink->subselect);
2255 }
2256 break;
2257 case T_SubPlan:
2258 {
2259 SubPlan *subplan = (SubPlan *) node;
2260
2261 /* recurse into the testexpr, but not into the Plan */
2262 if (WALK(subplan->testexpr))
2263 return true;
2264 /* also examine args list */
2265 if (LIST_WALK(subplan->args))
2266 return true;
2267 }
2268 break;
2270 return LIST_WALK(((AlternativeSubPlan *) node)->subplans);
2271 case T_FieldSelect:
2272 return WALK(((FieldSelect *) node)->arg);
2273 case T_FieldStore:
2274 {
2275 FieldStore *fstore = (FieldStore *) node;
2276
2277 if (WALK(fstore->arg))
2278 return true;
2279 if (WALK(fstore->newvals))
2280 return true;
2281 }
2282 break;
2283 case T_RelabelType:
2284 return WALK(((RelabelType *) node)->arg);
2285 case T_CoerceViaIO:
2286 return WALK(((CoerceViaIO *) node)->arg);
2287 case T_ArrayCoerceExpr:
2288 {
2290
2291 if (WALK(acoerce->arg))
2292 return true;
2293 if (WALK(acoerce->elemexpr))
2294 return true;
2295 }
2296 break;
2298 return WALK(((ConvertRowtypeExpr *) node)->arg);
2299 case T_CollateExpr:
2300 return WALK(((CollateExpr *) node)->arg);
2301 case T_CaseExpr:
2302 {
2303 CaseExpr *caseexpr = (CaseExpr *) node;
2304
2305 if (WALK(caseexpr->arg))
2306 return true;
2307 /* we assume walker doesn't care about CaseWhens, either */
2308 foreach(temp, caseexpr->args)
2309 {
2311
2312 if (WALK(when->expr))
2313 return true;
2314 if (WALK(when->result))
2315 return true;
2316 }
2317 if (WALK(caseexpr->defresult))
2318 return true;
2319 }
2320 break;
2321 case T_ArrayExpr:
2322 return WALK(((ArrayExpr *) node)->elements);
2323 case T_RowExpr:
2324 /* Assume colnames isn't interesting */
2325 return WALK(((RowExpr *) node)->args);
2326 case T_RowCompareExpr:
2327 {
2329
2330 if (WALK(rcexpr->largs))
2331 return true;
2332 if (WALK(rcexpr->rargs))
2333 return true;
2334 }
2335 break;
2336 case T_CoalesceExpr:
2337 return WALK(((CoalesceExpr *) node)->args);
2338 case T_MinMaxExpr:
2339 return WALK(((MinMaxExpr *) node)->args);
2340 case T_XmlExpr:
2341 {
2342 XmlExpr *xexpr = (XmlExpr *) node;
2343
2344 if (WALK(xexpr->named_args))
2345 return true;
2346 /* we assume walker doesn't care about arg_names */
2347 if (WALK(xexpr->args))
2348 return true;
2349 }
2350 break;
2351 case T_JsonValueExpr:
2352 {
2353 JsonValueExpr *jve = (JsonValueExpr *) node;
2354
2355 if (WALK(jve->raw_expr))
2356 return true;
2357 if (WALK(jve->formatted_expr))
2358 return true;
2359 }
2360 break;
2362 {
2364
2365 if (WALK(ctor->args))
2366 return true;
2367 if (WALK(ctor->func))
2368 return true;
2369 if (WALK(ctor->coercion))
2370 return true;
2371 }
2372 break;
2373 case T_JsonIsPredicate:
2374 return WALK(((JsonIsPredicate *) node)->expr);
2375 case T_JsonExpr:
2376 {
2377 JsonExpr *jexpr = (JsonExpr *) node;
2378
2379 if (WALK(jexpr->formatted_expr))
2380 return true;
2381 if (WALK(jexpr->path_spec))
2382 return true;
2383 if (WALK(jexpr->passing_values))
2384 return true;
2385 /* we assume walker doesn't care about passing_names */
2386 if (WALK(jexpr->on_empty))
2387 return true;
2388 if (WALK(jexpr->on_error))
2389 return true;
2390 }
2391 break;
2392 case T_JsonBehavior:
2393 {
2394 JsonBehavior *behavior = (JsonBehavior *) node;
2395
2396 if (WALK(behavior->expr))
2397 return true;
2398 }
2399 break;
2400 case T_NullTest:
2401 return WALK(((NullTest *) node)->arg);
2402 case T_BooleanTest:
2403 return WALK(((BooleanTest *) node)->arg);
2404 case T_CoerceToDomain:
2405 return WALK(((CoerceToDomain *) node)->arg);
2406 case T_TargetEntry:
2407 return WALK(((TargetEntry *) node)->expr);
2408 case T_Query:
2409 /* Do nothing with a sub-Query, per discussion above */
2410 break;
2411 case T_WindowClause:
2412 {
2413 WindowClause *wc = (WindowClause *) node;
2414
2415 if (WALK(wc->partitionClause))
2416 return true;
2417 if (WALK(wc->orderClause))
2418 return true;
2419 if (WALK(wc->startOffset))
2420 return true;
2421 if (WALK(wc->endOffset))
2422 return true;
2423 }
2424 break;
2425 case T_CTECycleClause:
2426 {
2427 CTECycleClause *cc = (CTECycleClause *) node;
2428
2429 if (WALK(cc->cycle_mark_value))
2430 return true;
2431 if (WALK(cc->cycle_mark_default))
2432 return true;
2433 }
2434 break;
2435 case T_CommonTableExpr:
2436 {
2437 CommonTableExpr *cte = (CommonTableExpr *) node;
2438
2439 /*
2440 * Invoke the walker on the CTE's Query node, so it can
2441 * recurse into the sub-query if it wants to.
2442 */
2443 if (WALK(cte->ctequery))
2444 return true;
2445
2446 if (WALK(cte->search_clause))
2447 return true;
2448 if (WALK(cte->cycle_clause))
2449 return true;
2450 }
2451 break;
2452 case T_JsonKeyValue:
2453 {
2454 JsonKeyValue *kv = (JsonKeyValue *) node;
2455
2456 if (WALK(kv->key))
2457 return true;
2458 if (WALK(kv->value))
2459 return true;
2460 }
2461 break;
2463 {
2465
2466 if (LIST_WALK(ctor->exprs))
2467 return true;
2468 }
2469 break;
2471 {
2473
2474 if (LIST_WALK(ctor->exprs))
2475 return true;
2476 }
2477 break;
2479 {
2481
2482 if (WALK(ctor->query))
2483 return true;
2484 }
2485 break;
2487 {
2489
2490 if (WALK(ctor->agg_filter))
2491 return true;
2492 if (WALK(ctor->agg_order))
2493 return true;
2494 if (WALK(ctor->over))
2495 return true;
2496 }
2497 break;
2498 case T_JsonObjectAgg:
2499 {
2500 JsonObjectAgg *ctor = (JsonObjectAgg *) node;
2501
2502 if (WALK(ctor->constructor))
2503 return true;
2504 if (WALK(ctor->arg))
2505 return true;
2506 }
2507 break;
2508 case T_JsonArrayAgg:
2509 {
2510 JsonArrayAgg *ctor = (JsonArrayAgg *) node;
2511
2512 if (WALK(ctor->constructor))
2513 return true;
2514 if (WALK(ctor->arg))
2515 return true;
2516 }
2517 break;
2518
2520 {
2522
2523 if (WALK(pbs->listdatums))
2524 return true;
2525 if (WALK(pbs->lowerdatums))
2526 return true;
2527 if (WALK(pbs->upperdatums))
2528 return true;
2529 }
2530 break;
2532 {
2534
2535 if (WALK(prd->value))
2536 return true;
2537 }
2538 break;
2539 case T_List:
2540 foreach(temp, (List *) node)
2541 {
2542 if (WALK(lfirst(temp)))
2543 return true;
2544 }
2545 break;
2546 case T_FromExpr:
2547 {
2548 FromExpr *from = (FromExpr *) node;
2549
2550 if (LIST_WALK(from->fromlist))
2551 return true;
2552 if (WALK(from->quals))
2553 return true;
2554 }
2555 break;
2556 case T_OnConflictExpr:
2557 {
2558 OnConflictExpr *onconflict = (OnConflictExpr *) node;
2559
2560 if (WALK(onconflict->arbiterElems))
2561 return true;
2562 if (WALK(onconflict->arbiterWhere))
2563 return true;
2564 if (WALK(onconflict->onConflictSet))
2565 return true;
2566 if (WALK(onconflict->onConflictWhere))
2567 return true;
2568 if (WALK(onconflict->exclRelTlist))
2569 return true;
2570 }
2571 break;
2572 case T_MergeAction:
2573 {
2574 MergeAction *action = (MergeAction *) node;
2575
2576 if (WALK(action->qual))
2577 return true;
2578 if (WALK(action->targetList))
2579 return true;
2580 }
2581 break;
2582 case T_ForPortionOfExpr:
2583 {
2584 ForPortionOfExpr *forPortionOf = (ForPortionOfExpr *) node;
2585
2586 if (WALK(forPortionOf->rangeVar))
2587 return true;
2588 if (WALK(forPortionOf->targetFrom))
2589 return true;
2590 if (WALK(forPortionOf->targetTo))
2591 return true;
2592 if (WALK(forPortionOf->targetRange))
2593 return true;
2594 if (WALK(forPortionOf->overlapsExpr))
2595 return true;
2596 if (WALK(forPortionOf->rangeTargetList))
2597 return true;
2598 }
2599 break;
2601 {
2603
2604 if (WALK(opstep->exprs))
2605 return true;
2606 }
2607 break;
2609 /* no expression subnodes */
2610 break;
2611 case T_JoinExpr:
2612 {
2613 JoinExpr *join = (JoinExpr *) node;
2614
2615 if (WALK(join->larg))
2616 return true;
2617 if (WALK(join->rarg))
2618 return true;
2619 if (WALK(join->quals))
2620 return true;
2621
2622 /*
2623 * alias clause, using list are deemed uninteresting.
2624 */
2625 }
2626 break;
2627 case T_SetOperationStmt:
2628 {
2629 SetOperationStmt *setop = (SetOperationStmt *) node;
2630
2631 if (WALK(setop->larg))
2632 return true;
2633 if (WALK(setop->rarg))
2634 return true;
2635
2636 /* groupClauses are deemed uninteresting */
2637 }
2638 break;
2639 case T_IndexClause:
2640 {
2641 IndexClause *iclause = (IndexClause *) node;
2642
2643 if (WALK(iclause->rinfo))
2644 return true;
2645 if (LIST_WALK(iclause->indexquals))
2646 return true;
2647 }
2648 break;
2649 case T_PlaceHolderVar:
2650 return WALK(((PlaceHolderVar *) node)->phexpr);
2651 case T_InferenceElem:
2652 return WALK(((InferenceElem *) node)->expr);
2653 case T_ReturningExpr:
2654 return WALK(((ReturningExpr *) node)->retexpr);
2655 case T_AppendRelInfo:
2656 {
2658
2659 if (LIST_WALK(appinfo->translated_vars))
2660 return true;
2661 }
2662 break;
2663 case T_PlaceHolderInfo:
2664 return WALK(((PlaceHolderInfo *) node)->ph_var);
2665 case T_RangeTblFunction:
2666 return WALK(((RangeTblFunction *) node)->funcexpr);
2668 {
2670
2671 if (LIST_WALK(tsc->args))
2672 return true;
2673 if (WALK(tsc->repeatable))
2674 return true;
2675 }
2676 break;
2677 case T_TableFunc:
2678 {
2679 TableFunc *tf = (TableFunc *) node;
2680
2681 if (WALK(tf->ns_uris))
2682 return true;
2683 if (WALK(tf->docexpr))
2684 return true;
2685 if (WALK(tf->rowexpr))
2686 return true;
2687 if (WALK(tf->colexprs))
2688 return true;
2689 if (WALK(tf->coldefexprs))
2690 return true;
2691 if (WALK(tf->colvalexprs))
2692 return true;
2693 if (WALK(tf->passingvalexprs))
2694 return true;
2695 }
2696 break;
2698 {
2700
2701 if (WALK(gep->subexpr))
2702 return true;
2703 if (WALK(gep->whereClause))
2704 return true;
2705 }
2706 break;
2707 case T_GraphPattern:
2708 {
2709 GraphPattern *gp = (GraphPattern *) node;
2710
2711 if (LIST_WALK(gp->path_pattern_list))
2712 return true;
2713 if (WALK(gp->whereClause))
2714 return true;
2715 }
2716 break;
2717 default:
2718 elog(ERROR, "unrecognized node type: %d",
2719 (int) nodeTag(node));
2720 break;
2721 }
2722 return false;
2723
2724 /* The WALK() macro can be re-used below, but LIST_WALK() not so much */
2725#undef LIST_WALK
2726}
#define LIST_WALK(l)
#define WALK(n)
#define lfirst_node(type, lc)
Definition pg_list.h:176
List * rangeTargetList
Definition primnodes.h:2448
List * arbiterElems
Definition primnodes.h:2403
List * onConflictSet
Definition primnodes.h:2412
List * exclRelTlist
Definition primnodes.h:2417
Node * onConflictWhere
Definition primnodes.h:2415
Node * arbiterWhere
Definition primnodes.h:2405
Definition type.h:89

References Aggref::aggdirectargs, Aggref::aggdistinct, Aggref::aggfilter, WindowFunc::aggfilter, Aggref::aggorder, OnConflictExpr::arbiterElems, OnConflictExpr::arbiterWhere, arg, WindowFuncRunCondition::arg, FieldStore::arg, Aggref::args, WindowFunc::args, FuncExpr::args, OpExpr::args, ScalarArrayOpExpr::args, BoolExpr::args, SubPlan::args, XmlExpr::args, check_stack_depth(), TableFunc::colexprs, CommonTableExpr::ctequery, CTECycleClause::cycle_mark_default, CTECycleClause::cycle_mark_value, TableFunc::docexpr, elog, WindowClause::endOffset, ERROR, OnConflictExpr::exclRelTlist, JsonBehavior::expr, fb(), FromExpr::fromlist, SetOperationStmt::larg, JoinExpr::larg, lfirst, lfirst_node, LIST_WALK, XmlExpr::named_args, FieldStore::newvals, nodeTag, OnConflictExpr::onConflictSet, OnConflictExpr::onConflictWhere, WindowClause::orderClause, ForPortionOfExpr::overlapsExpr, WindowClause::partitionClause, JoinExpr::quals, FromExpr::quals, ForPortionOfExpr::rangeTargetList, ForPortionOfExpr::rangeVar, SetOperationStmt::rarg, JoinExpr::rarg, SubscriptingRef::refassgnexpr, SubscriptingRef::refexpr, SubscriptingRef::reflowerindexpr, SubscriptingRef::refupperindexpr, TableFunc::rowexpr, WindowClause::startOffset, ForPortionOfExpr::targetFrom, ForPortionOfExpr::targetRange, ForPortionOfExpr::targetTo, SubPlan::testexpr, and WALK.

◆ exprInputCollation()

Oid exprInputCollation ( const Node expr)
extern

Definition at line 1084 of file nodeFuncs.c.

1085{
1086 Oid coll;
1087
1088 if (!expr)
1089 return InvalidOid;
1090
1091 switch (nodeTag(expr))
1092 {
1093 case T_Aggref:
1094 coll = ((const Aggref *) expr)->inputcollid;
1095 break;
1096 case T_WindowFunc:
1097 coll = ((const WindowFunc *) expr)->inputcollid;
1098 break;
1099 case T_FuncExpr:
1100 coll = ((const FuncExpr *) expr)->inputcollid;
1101 break;
1102 case T_OpExpr:
1103 coll = ((const OpExpr *) expr)->inputcollid;
1104 break;
1105 case T_DistinctExpr:
1106 coll = ((const DistinctExpr *) expr)->inputcollid;
1107 break;
1108 case T_NullIfExpr:
1109 coll = ((const NullIfExpr *) expr)->inputcollid;
1110 break;
1112 coll = ((const ScalarArrayOpExpr *) expr)->inputcollid;
1113 break;
1114 case T_MinMaxExpr:
1115 coll = ((const MinMaxExpr *) expr)->inputcollid;
1116 break;
1117 default:
1118 coll = InvalidOid;
1119 break;
1120 }
1121 return coll;
1122}

References fb(), InvalidOid, and nodeTag.

Referenced by check_simple_rowfilter_expr_walker(), and resolve_polymorphic_tupdesc().

◆ exprIsLengthCoercion()

bool exprIsLengthCoercion ( const Node expr,
int32 coercedTypmod 
)
extern

Definition at line 562 of file nodeFuncs.c.

563{
564 if (coercedTypmod != NULL)
565 *coercedTypmod = -1; /* default result on failure */
566
567 /*
568 * Scalar-type length coercions are FuncExprs, array-type length coercions
569 * are ArrayCoerceExprs
570 */
571 if (expr && IsA(expr, FuncExpr))
572 {
573 const FuncExpr *func = (const FuncExpr *) expr;
574 int nargs;
576
577 /*
578 * If it didn't come from a coercion context, reject.
579 */
580 if (func->funcformat != COERCE_EXPLICIT_CAST &&
581 func->funcformat != COERCE_IMPLICIT_CAST)
582 return false;
583
584 /*
585 * If it's not a two-argument or three-argument function with the
586 * second argument being an int4 constant, it can't have been created
587 * from a length coercion (it must be a type coercion, instead).
588 */
589 nargs = list_length(func->args);
591 return false;
592
593 second_arg = (Const *) lsecond(func->args);
594 if (!IsA(second_arg, Const) ||
595 second_arg->consttype != INT4OID ||
596 second_arg->constisnull)
597 return false;
598
599 /*
600 * OK, it is indeed a length-coercion function.
601 */
602 if (coercedTypmod != NULL)
603 *coercedTypmod = DatumGetInt32(second_arg->constvalue);
604
605 return true;
606 }
607
608 if (expr && IsA(expr, ArrayCoerceExpr))
609 {
610 const ArrayCoerceExpr *acoerce = (const ArrayCoerceExpr *) expr;
611
612 /* It's not a length coercion unless there's a nondefault typmod */
613 if (acoerce->resulttypmod < 0)
614 return false;
615
616 /*
617 * OK, it is indeed a length-coercion expression.
618 */
619 if (coercedTypmod != NULL)
620 *coercedTypmod = acoerce->resulttypmod;
621
622 return true;
623 }
624
625 return false;
626}
static int list_length(const List *l)
Definition pg_list.h:152
#define lsecond(l)
Definition pg_list.h:183
static int32 DatumGetInt32(Datum X)
Definition postgres.h:202
@ COERCE_IMPLICIT_CAST
Definition primnodes.h:769
@ COERCE_EXPLICIT_CAST
Definition primnodes.h:768

References FuncExpr::args, COERCE_EXPLICIT_CAST, COERCE_IMPLICIT_CAST, DatumGetInt32(), fb(), IsA, list_length(), and lsecond.

Referenced by deparseFuncExpr(), exprTypmod(), and get_func_expr().

◆ exprLocation()

int exprLocation ( const Node expr)
extern

Definition at line 1392 of file nodeFuncs.c.

1393{
1394 int loc;
1395
1396 if (expr == NULL)
1397 return -1;
1398 switch (nodeTag(expr))
1399 {
1400 case T_RangeVar:
1401 loc = ((const RangeVar *) expr)->location;
1402 break;
1403 case T_TableFunc:
1404 loc = ((const TableFunc *) expr)->location;
1405 break;
1406 case T_Var:
1407 loc = ((const Var *) expr)->location;
1408 break;
1409 case T_Const:
1410 loc = ((const Const *) expr)->location;
1411 break;
1412 case T_Param:
1413 loc = ((const Param *) expr)->location;
1414 break;
1415 case T_Aggref:
1416 /* function name should always be the first thing */
1417 loc = ((const Aggref *) expr)->location;
1418 break;
1419 case T_GroupingFunc:
1420 loc = ((const GroupingFunc *) expr)->location;
1421 break;
1422 case T_WindowFunc:
1423 /* function name should always be the first thing */
1424 loc = ((const WindowFunc *) expr)->location;
1425 break;
1426 case T_MergeSupportFunc:
1427 loc = ((const MergeSupportFunc *) expr)->location;
1428 break;
1429 case T_SubscriptingRef:
1430 /* just use container argument's location */
1431 loc = exprLocation((Node *) ((const SubscriptingRef *) expr)->refexpr);
1432 break;
1433 case T_FuncExpr:
1434 {
1435 const FuncExpr *fexpr = (const FuncExpr *) expr;
1436
1437 /* consider both function name and leftmost arg */
1438 loc = leftmostLoc(fexpr->location,
1439 exprLocation((Node *) fexpr->args));
1440 }
1441 break;
1442 case T_NamedArgExpr:
1443 {
1444 const NamedArgExpr *na = (const NamedArgExpr *) expr;
1445
1446 /* consider both argument name and value */
1447 loc = leftmostLoc(na->location,
1448 exprLocation((Node *) na->arg));
1449 }
1450 break;
1451 case T_OpExpr:
1452 case T_DistinctExpr: /* struct-equivalent to OpExpr */
1453 case T_NullIfExpr: /* struct-equivalent to OpExpr */
1454 {
1455 const OpExpr *opexpr = (const OpExpr *) expr;
1456
1457 /* consider both operator name and leftmost arg */
1458 loc = leftmostLoc(opexpr->location,
1459 exprLocation((Node *) opexpr->args));
1460 }
1461 break;
1463 {
1464 const ScalarArrayOpExpr *saopexpr = (const ScalarArrayOpExpr *) expr;
1465
1466 /* consider both operator name and leftmost arg */
1467 loc = leftmostLoc(saopexpr->location,
1468 exprLocation((Node *) saopexpr->args));
1469 }
1470 break;
1471 case T_BoolExpr:
1472 {
1473 const BoolExpr *bexpr = (const BoolExpr *) expr;
1474
1475 /*
1476 * Same as above, to handle either NOT or AND/OR. We can't
1477 * special-case NOT because of the way that it's used for
1478 * things like IS NOT BETWEEN.
1479 */
1480 loc = leftmostLoc(bexpr->location,
1481 exprLocation((Node *) bexpr->args));
1482 }
1483 break;
1484 case T_SubLink:
1485 {
1486 const SubLink *sublink = (const SubLink *) expr;
1487
1488 /* check the testexpr, if any, and the operator/keyword */
1489 loc = leftmostLoc(exprLocation(sublink->testexpr),
1490 sublink->location);
1491 }
1492 break;
1493 case T_FieldSelect:
1494 /* just use argument's location */
1495 loc = exprLocation((Node *) ((const FieldSelect *) expr)->arg);
1496 break;
1497 case T_FieldStore:
1498 /* just use argument's location */
1499 loc = exprLocation((Node *) ((const FieldStore *) expr)->arg);
1500 break;
1501 case T_RelabelType:
1502 {
1503 const RelabelType *rexpr = (const RelabelType *) expr;
1504
1505 /* Much as above */
1506 loc = leftmostLoc(rexpr->location,
1507 exprLocation((Node *) rexpr->arg));
1508 }
1509 break;
1510 case T_CoerceViaIO:
1511 {
1512 const CoerceViaIO *cexpr = (const CoerceViaIO *) expr;
1513
1514 /* Much as above */
1515 loc = leftmostLoc(cexpr->location,
1516 exprLocation((Node *) cexpr->arg));
1517 }
1518 break;
1519 case T_ArrayCoerceExpr:
1520 {
1521 const ArrayCoerceExpr *cexpr = (const ArrayCoerceExpr *) expr;
1522
1523 /* Much as above */
1524 loc = leftmostLoc(cexpr->location,
1525 exprLocation((Node *) cexpr->arg));
1526 }
1527 break;
1529 {
1530 const ConvertRowtypeExpr *cexpr = (const ConvertRowtypeExpr *) expr;
1531
1532 /* Much as above */
1533 loc = leftmostLoc(cexpr->location,
1534 exprLocation((Node *) cexpr->arg));
1535 }
1536 break;
1537 case T_CollateExpr:
1538 /* just use argument's location */
1539 loc = exprLocation((Node *) ((const CollateExpr *) expr)->arg);
1540 break;
1541 case T_CaseExpr:
1542 /* CASE keyword should always be the first thing */
1543 loc = ((const CaseExpr *) expr)->location;
1544 break;
1545 case T_CaseWhen:
1546 /* WHEN keyword should always be the first thing */
1547 loc = ((const CaseWhen *) expr)->location;
1548 break;
1549 case T_ArrayExpr:
1550 /* the location points at ARRAY or [, which must be leftmost */
1551 loc = ((const ArrayExpr *) expr)->location;
1552 break;
1553 case T_RowExpr:
1554 /* the location points at ROW or (, which must be leftmost */
1555 loc = ((const RowExpr *) expr)->location;
1556 break;
1557 case T_RowCompareExpr:
1558 /* just use leftmost argument's location */
1559 loc = exprLocation((Node *) ((const RowCompareExpr *) expr)->largs);
1560 break;
1561 case T_CoalesceExpr:
1562 /* COALESCE keyword should always be the first thing */
1563 loc = ((const CoalesceExpr *) expr)->location;
1564 break;
1565 case T_MinMaxExpr:
1566 /* GREATEST/LEAST keyword should always be the first thing */
1567 loc = ((const MinMaxExpr *) expr)->location;
1568 break;
1569 case T_SQLValueFunction:
1570 /* function keyword should always be the first thing */
1571 loc = ((const SQLValueFunction *) expr)->location;
1572 break;
1573 case T_XmlExpr:
1574 {
1575 const XmlExpr *xexpr = (const XmlExpr *) expr;
1576
1577 /* consider both function name and leftmost arg */
1578 loc = leftmostLoc(xexpr->location,
1579 exprLocation((Node *) xexpr->args));
1580 }
1581 break;
1582 case T_JsonFormat:
1583 loc = ((const JsonFormat *) expr)->location;
1584 break;
1585 case T_JsonValueExpr:
1586 loc = exprLocation((Node *) ((const JsonValueExpr *) expr)->raw_expr);
1587 break;
1589 loc = ((const JsonConstructorExpr *) expr)->location;
1590 break;
1591 case T_JsonIsPredicate:
1592 loc = ((const JsonIsPredicate *) expr)->location;
1593 break;
1594 case T_JsonExpr:
1595 {
1596 const JsonExpr *jsexpr = (const JsonExpr *) expr;
1597
1598 /* consider both function name and leftmost arg */
1599 loc = leftmostLoc(jsexpr->location,
1600 exprLocation(jsexpr->formatted_expr));
1601 }
1602 break;
1603 case T_JsonBehavior:
1604 loc = exprLocation(((const JsonBehavior *) expr)->expr);
1605 break;
1606 case T_NullTest:
1607 {
1608 const NullTest *nexpr = (const NullTest *) expr;
1609
1610 /* Much as above */
1611 loc = leftmostLoc(nexpr->location,
1612 exprLocation((Node *) nexpr->arg));
1613 }
1614 break;
1615 case T_BooleanTest:
1616 {
1617 const BooleanTest *bexpr = (const BooleanTest *) expr;
1618
1619 /* Much as above */
1620 loc = leftmostLoc(bexpr->location,
1621 exprLocation((Node *) bexpr->arg));
1622 }
1623 break;
1624 case T_CoerceToDomain:
1625 {
1626 const CoerceToDomain *cexpr = (const CoerceToDomain *) expr;
1627
1628 /* Much as above */
1629 loc = leftmostLoc(cexpr->location,
1630 exprLocation((Node *) cexpr->arg));
1631 }
1632 break;
1634 loc = ((const CoerceToDomainValue *) expr)->location;
1635 break;
1636 case T_SetToDefault:
1637 loc = ((const SetToDefault *) expr)->location;
1638 break;
1639 case T_ReturningExpr:
1640 loc = exprLocation((Node *) ((const ReturningExpr *) expr)->retexpr);
1641 break;
1642 case T_TargetEntry:
1643 /* just use argument's location */
1644 loc = exprLocation((Node *) ((const TargetEntry *) expr)->expr);
1645 break;
1646 case T_IntoClause:
1647 /* use the contained RangeVar's location --- close enough */
1648 loc = exprLocation((Node *) ((const IntoClause *) expr)->rel);
1649 break;
1650 case T_List:
1651 {
1652 /* report location of first list member that has a location */
1653 ListCell *lc;
1654
1655 loc = -1; /* just to suppress compiler warning */
1656 foreach(lc, (const List *) expr)
1657 {
1658 loc = exprLocation((Node *) lfirst(lc));
1659 if (loc >= 0)
1660 break;
1661 }
1662 }
1663 break;
1664 case T_A_Expr:
1665 {
1666 const A_Expr *aexpr = (const A_Expr *) expr;
1667
1668 /* use leftmost of operator or left operand (if any) */
1669 /* we assume right operand can't be to left of operator */
1670 loc = leftmostLoc(aexpr->location,
1671 exprLocation(aexpr->lexpr));
1672 }
1673 break;
1674 case T_ColumnRef:
1675 loc = ((const ColumnRef *) expr)->location;
1676 break;
1677 case T_ParamRef:
1678 loc = ((const ParamRef *) expr)->location;
1679 break;
1680 case T_A_Const:
1681 loc = ((const A_Const *) expr)->location;
1682 break;
1683 case T_FuncCall:
1684 {
1685 const FuncCall *fc = (const FuncCall *) expr;
1686
1687 /* consider both function name and leftmost arg */
1688 /* (we assume any ORDER BY nodes must be to right of name) */
1689 loc = leftmostLoc(fc->location,
1690 exprLocation((Node *) fc->args));
1691 }
1692 break;
1693 case T_A_ArrayExpr:
1694 /* the location points at ARRAY or [, which must be leftmost */
1695 loc = ((const A_ArrayExpr *) expr)->location;
1696 break;
1697 case T_ResTarget:
1698 /* we need not examine the contained expression (if any) */
1699 loc = ((const ResTarget *) expr)->location;
1700 break;
1701 case T_MultiAssignRef:
1702 loc = exprLocation(((const MultiAssignRef *) expr)->source);
1703 break;
1704 case T_TypeCast:
1705 {
1706 const TypeCast *tc = (const TypeCast *) expr;
1707
1708 /*
1709 * This could represent CAST(), ::, or TypeName 'literal', so
1710 * any of the components might be leftmost.
1711 */
1712 loc = exprLocation(tc->arg);
1713 loc = leftmostLoc(loc, tc->typeName->location);
1714 loc = leftmostLoc(loc, tc->location);
1715 }
1716 break;
1717 case T_CollateClause:
1718 /* just use argument's location */
1719 loc = exprLocation(((const CollateClause *) expr)->arg);
1720 break;
1721 case T_SortBy:
1722 /* just use argument's location (ignore operator, if any) */
1723 loc = exprLocation(((const SortBy *) expr)->node);
1724 break;
1725 case T_WindowDef:
1726 loc = ((const WindowDef *) expr)->location;
1727 break;
1728 case T_RangeTableSample:
1729 loc = ((const RangeTableSample *) expr)->location;
1730 break;
1731 case T_TypeName:
1732 loc = ((const TypeName *) expr)->location;
1733 break;
1734 case T_ColumnDef:
1735 loc = ((const ColumnDef *) expr)->location;
1736 break;
1737 case T_IndexElem:
1738 loc = ((const IndexElem *) expr)->location;
1739 break;
1740 case T_Constraint:
1741 loc = ((const Constraint *) expr)->location;
1742 break;
1744 loc = ((const FunctionParameter *) expr)->location;
1745 break;
1746 case T_XmlSerialize:
1747 /* XMLSERIALIZE keyword should always be the first thing */
1748 loc = ((const XmlSerialize *) expr)->location;
1749 break;
1750 case T_GroupingSet:
1751 loc = ((const GroupingSet *) expr)->location;
1752 break;
1753 case T_WithClause:
1754 loc = ((const WithClause *) expr)->location;
1755 break;
1756 case T_InferClause:
1757 loc = ((const InferClause *) expr)->location;
1758 break;
1759 case T_OnConflictClause:
1760 loc = ((const OnConflictClause *) expr)->location;
1761 break;
1762 case T_CTESearchClause:
1763 loc = ((const CTESearchClause *) expr)->location;
1764 break;
1765 case T_CTECycleClause:
1766 loc = ((const CTECycleClause *) expr)->location;
1767 break;
1768 case T_CommonTableExpr:
1769 loc = ((const CommonTableExpr *) expr)->location;
1770 break;
1771 case T_JsonKeyValue:
1772 /* just use the key's location */
1773 loc = exprLocation((Node *) ((const JsonKeyValue *) expr)->key);
1774 break;
1776 loc = ((const JsonObjectConstructor *) expr)->location;
1777 break;
1779 loc = ((const JsonArrayConstructor *) expr)->location;
1780 break;
1782 loc = ((const JsonArrayQueryConstructor *) expr)->location;
1783 break;
1785 loc = ((const JsonAggConstructor *) expr)->location;
1786 break;
1787 case T_JsonObjectAgg:
1788 loc = exprLocation((Node *) ((const JsonObjectAgg *) expr)->constructor);
1789 break;
1790 case T_JsonArrayAgg:
1791 loc = exprLocation((Node *) ((const JsonArrayAgg *) expr)->constructor);
1792 break;
1793 case T_PlaceHolderVar:
1794 /* just use argument's location */
1795 loc = exprLocation((Node *) ((const PlaceHolderVar *) expr)->phexpr);
1796 break;
1797 case T_InferenceElem:
1798 /* just use nested expr's location */
1799 loc = exprLocation((Node *) ((const InferenceElem *) expr)->expr);
1800 break;
1801 case T_PartitionElem:
1802 loc = ((const PartitionElem *) expr)->location;
1803 break;
1804 case T_PartitionSpec:
1805 loc = ((const PartitionSpec *) expr)->location;
1806 break;
1808 loc = ((const PartitionBoundSpec *) expr)->location;
1809 break;
1811 loc = ((const PartitionRangeDatum *) expr)->location;
1812 break;
1813 default:
1814 /* for any other node type it's just unknown... */
1815 loc = -1;
1816 break;
1817 }
1818 return loc;
1819}
static int leftmostLoc(int loc1, int loc2)
Definition nodeFuncs.c:1827
int exprLocation(const Node *expr)
Definition nodeFuncs.c:1392
static rewind_source * source
Definition pg_rewind.c:89
static int fc(const char *x)
ParseLoc location
Definition primnodes.h:1277
ParseLoc location
Definition primnodes.h:2064
ParseLoc location
Definition primnodes.h:1249
Node * formatted_expr
Definition primnodes.h:1851
ParseLoc location
Definition primnodes.h:1887
ParseLoc location
Definition primnodes.h:872
ParseLoc location
Definition primnodes.h:1227
ParseLoc location
Definition primnodes.h:1644

References arg, RelabelType::arg, CoerceViaIO::arg, ArrayCoerceExpr::arg, ConvertRowtypeExpr::arg, CoerceToDomain::arg, OpExpr::args, XmlExpr::args, exprLocation(), fb(), fc(), JsonExpr::formatted_expr, leftmostLoc(), lfirst, OpExpr::location, RelabelType::location, CoerceViaIO::location, ArrayCoerceExpr::location, ConvertRowtypeExpr::location, XmlExpr::location, JsonExpr::location, CoerceToDomain::location, nodeTag, and source.

Referenced by addRangeTableEntryForFunction(), addRangeTableEntryForTableFunc(), addTargetToSortList(), analyzeCTE(), array_subscript_transform(), assign_collations_walker(), check_agg_arguments_walker(), check_partition_bounds_for_split_list(), check_partition_bounds_for_split_range(), check_partitions_not_overlap_list(), check_simple_rowfilter_expr_walker(), check_srf_call_placement(), check_virtual_generated_security_walker(), checkWellFormedRecursion(), coerce_to_boolean(), coerce_to_common_type(), coerce_to_specific_type_typmod(), coerceJsonFuncExpr(), constructSetOpTargetlist(), EvaluateParams(), ExecInitFunc(), ExecInitSubscriptingRef(), exprLocation(), finalize_grouping_exprs_walker(), generate_union_from_pathqueries(), get_matching_location(), hstore_subscript_transform(), init_sexpr(), jsonb_subscript_transform(), parseCheckAggregates(), ParseFuncOrColumn(), parser_coercion_errposition(), replace_outer_returning(), select_common_type(), transformAggregateCall(), transformArrayExpr(), transformAssignedExpr(), transformCaseExpr(), transformCoalesceExpr(), transformContainerSubscripts(), transformDistinctClause(), transformDistinctOnClause(), transformForPortionOfClause(), transformFrameOffset(), transformFromClauseItem(), transformGroupClause(), transformGroupClauseExpr(), transformGroupingSet(), transformIndirection(), transformInsertRow(), transformInsertStmt(), transformJsonBehavior(), transformJsonFuncExpr(), transformJsonIsPredicate(), transformJsonParseArg(), transformJsonValueExpr(), transformMultiAssignRef(), transformOnConflictArbiter(), transformPartitionBound(), transformPartitionBoundValue(), transformPartitionRangeBounds(), transformPLAssignStmtTarget(), transformRangeFunction(), transformReturningClause(), transformSelectStmt(), transformSetOperationStmt(), transformSetOperationTree(), transformValuesClause(), and validateInfiniteBounds().

◆ exprSetCollation()

void exprSetCollation ( Node expr,
Oid  collation 
)
extern

Definition at line 1132 of file nodeFuncs.c.

1133{
1134 switch (nodeTag(expr))
1135 {
1136 case T_Var:
1137 ((Var *) expr)->varcollid = collation;
1138 break;
1139 case T_Const:
1140 ((Const *) expr)->constcollid = collation;
1141 break;
1142 case T_Param:
1143 ((Param *) expr)->paramcollid = collation;
1144 break;
1145 case T_Aggref:
1146 ((Aggref *) expr)->aggcollid = collation;
1147 break;
1148 case T_GroupingFunc:
1149 Assert(!OidIsValid(collation));
1150 break;
1151 case T_WindowFunc:
1152 ((WindowFunc *) expr)->wincollid = collation;
1153 break;
1154 case T_MergeSupportFunc:
1155 ((MergeSupportFunc *) expr)->msfcollid = collation;
1156 break;
1157 case T_SubscriptingRef:
1158 ((SubscriptingRef *) expr)->refcollid = collation;
1159 break;
1160 case T_FuncExpr:
1161 ((FuncExpr *) expr)->funccollid = collation;
1162 break;
1163 case T_NamedArgExpr:
1164 Assert(collation == exprCollation((Node *) ((NamedArgExpr *) expr)->arg));
1165 break;
1166 case T_OpExpr:
1167 ((OpExpr *) expr)->opcollid = collation;
1168 break;
1169 case T_DistinctExpr:
1170 ((DistinctExpr *) expr)->opcollid = collation;
1171 break;
1172 case T_NullIfExpr:
1173 ((NullIfExpr *) expr)->opcollid = collation;
1174 break;
1176 /* ScalarArrayOpExpr's result is boolean ... */
1177 Assert(!OidIsValid(collation)); /* ... so never set a collation */
1178 break;
1179 case T_BoolExpr:
1180 /* BoolExpr's result is boolean ... */
1181 Assert(!OidIsValid(collation)); /* ... so never set a collation */
1182 break;
1183 case T_SubLink:
1184#ifdef USE_ASSERT_CHECKING
1185 {
1186 SubLink *sublink = (SubLink *) expr;
1187
1188 if (sublink->subLinkType == EXPR_SUBLINK ||
1189 sublink->subLinkType == ARRAY_SUBLINK)
1190 {
1191 /* get the collation of subselect's first target column */
1192 Query *qtree = (Query *) sublink->subselect;
1194
1195 if (!qtree || !IsA(qtree, Query))
1196 elog(ERROR, "cannot set collation for untransformed sublink");
1197 tent = linitial_node(TargetEntry, qtree->targetList);
1198 Assert(!tent->resjunk);
1199 Assert(collation == exprCollation((Node *) tent->expr));
1200 }
1201 else
1202 {
1203 /* otherwise, result is RECORD or BOOLEAN */
1204 Assert(!OidIsValid(collation));
1205 }
1206 }
1207#endif /* USE_ASSERT_CHECKING */
1208 break;
1209 case T_FieldSelect:
1210 ((FieldSelect *) expr)->resultcollid = collation;
1211 break;
1212 case T_FieldStore:
1213 /* FieldStore's result is composite ... */
1214 Assert(!OidIsValid(collation)); /* ... so never set a collation */
1215 break;
1216 case T_RelabelType:
1217 ((RelabelType *) expr)->resultcollid = collation;
1218 break;
1219 case T_CoerceViaIO:
1220 ((CoerceViaIO *) expr)->resultcollid = collation;
1221 break;
1222 case T_ArrayCoerceExpr:
1223 ((ArrayCoerceExpr *) expr)->resultcollid = collation;
1224 break;
1226 /* ConvertRowtypeExpr's result is composite ... */
1227 Assert(!OidIsValid(collation)); /* ... so never set a collation */
1228 break;
1229 case T_CaseExpr:
1230 ((CaseExpr *) expr)->casecollid = collation;
1231 break;
1232 case T_ArrayExpr:
1233 ((ArrayExpr *) expr)->array_collid = collation;
1234 break;
1235 case T_RowExpr:
1236 /* RowExpr's result is composite ... */
1237 Assert(!OidIsValid(collation)); /* ... so never set a collation */
1238 break;
1239 case T_RowCompareExpr:
1240 /* RowCompareExpr's result is boolean ... */
1241 Assert(!OidIsValid(collation)); /* ... so never set a collation */
1242 break;
1243 case T_CoalesceExpr:
1244 ((CoalesceExpr *) expr)->coalescecollid = collation;
1245 break;
1246 case T_MinMaxExpr:
1247 ((MinMaxExpr *) expr)->minmaxcollid = collation;
1248 break;
1249 case T_SQLValueFunction:
1250 Assert((((SQLValueFunction *) expr)->type == NAMEOID) ?
1251 (collation == C_COLLATION_OID) :
1252 (collation == InvalidOid));
1253 break;
1254 case T_XmlExpr:
1255 Assert((((XmlExpr *) expr)->op == IS_XMLSERIALIZE) ?
1256 (collation == DEFAULT_COLLATION_OID) :
1257 (collation == InvalidOid));
1258 break;
1259 case T_JsonValueExpr:
1260 exprSetCollation((Node *) ((JsonValueExpr *) expr)->formatted_expr,
1261 collation);
1262 break;
1264 {
1266
1267 if (ctor->coercion)
1268 exprSetCollation((Node *) ctor->coercion, collation);
1269 else
1270 Assert(!OidIsValid(collation)); /* result is always a
1271 * json[b] type */
1272 }
1273 break;
1274 case T_JsonIsPredicate:
1275 Assert(!OidIsValid(collation)); /* result is always boolean */
1276 break;
1277 case T_JsonExpr:
1278 {
1279 JsonExpr *jexpr = (JsonExpr *) expr;
1280
1281 jexpr->collation = collation;
1282 }
1283 break;
1284 case T_JsonBehavior:
1285 Assert(((JsonBehavior *) expr)->expr == NULL ||
1286 exprCollation(((JsonBehavior *) expr)->expr) == collation);
1287 break;
1288 case T_NullTest:
1289 /* NullTest's result is boolean ... */
1290 Assert(!OidIsValid(collation)); /* ... so never set a collation */
1291 break;
1292 case T_BooleanTest:
1293 /* BooleanTest's result is boolean ... */
1294 Assert(!OidIsValid(collation)); /* ... so never set a collation */
1295 break;
1296 case T_CoerceToDomain:
1297 ((CoerceToDomain *) expr)->resultcollid = collation;
1298 break;
1300 ((CoerceToDomainValue *) expr)->collation = collation;
1301 break;
1302 case T_SetToDefault:
1303 ((SetToDefault *) expr)->collation = collation;
1304 break;
1305 case T_CurrentOfExpr:
1306 /* CurrentOfExpr's result is boolean ... */
1307 Assert(!OidIsValid(collation)); /* ... so never set a collation */
1308 break;
1309 case T_NextValueExpr:
1310 /* NextValueExpr's result is an integer type ... */
1311 Assert(!OidIsValid(collation)); /* ... so never set a collation */
1312 break;
1313 default:
1314 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(expr));
1315 break;
1316 }
1317}
#define OidIsValid(objectId)
Definition c.h:858
void exprSetCollation(Node *expr, Oid collation)
Definition nodeFuncs.c:1132

References arg, ARRAY_SUBLINK, Assert, elog, ERROR, EXPR_SUBLINK, exprCollation(), exprSetCollation(), fb(), InvalidOid, IS_XMLSERIALIZE, IsA, linitial_node, nodeTag, OidIsValid, and type.

Referenced by assign_collations_walker(), and exprSetCollation().

◆ exprSetInputCollation()

void exprSetInputCollation ( Node expr,
Oid  inputcollation 
)
extern

Definition at line 1328 of file nodeFuncs.c.

1329{
1330 switch (nodeTag(expr))
1331 {
1332 case T_Aggref:
1333 ((Aggref *) expr)->inputcollid = inputcollation;
1334 break;
1335 case T_WindowFunc:
1336 ((WindowFunc *) expr)->inputcollid = inputcollation;
1337 break;
1338 case T_FuncExpr:
1339 ((FuncExpr *) expr)->inputcollid = inputcollation;
1340 break;
1341 case T_OpExpr:
1342 ((OpExpr *) expr)->inputcollid = inputcollation;
1343 break;
1344 case T_DistinctExpr:
1345 ((DistinctExpr *) expr)->inputcollid = inputcollation;
1346 break;
1347 case T_NullIfExpr:
1348 ((NullIfExpr *) expr)->inputcollid = inputcollation;
1349 break;
1351 ((ScalarArrayOpExpr *) expr)->inputcollid = inputcollation;
1352 break;
1353 case T_MinMaxExpr:
1354 ((MinMaxExpr *) expr)->inputcollid = inputcollation;
1355 break;
1356 default:
1357 break;
1358 }
1359}

References fb(), and nodeTag.

Referenced by assign_collations_walker().

◆ exprType()

Oid exprType ( const Node expr)
extern

Definition at line 42 of file nodeFuncs.c.

43{
44 Oid type;
45
46 if (!expr)
47 return InvalidOid;
48
49 switch (nodeTag(expr))
50 {
51 case T_Var:
52 type = ((const Var *) expr)->vartype;
53 break;
54 case T_Const:
55 type = ((const Const *) expr)->consttype;
56 break;
57 case T_Param:
58 type = ((const Param *) expr)->paramtype;
59 break;
60 case T_Aggref:
61 type = ((const Aggref *) expr)->aggtype;
62 break;
63 case T_GroupingFunc:
64 type = INT4OID;
65 break;
66 case T_WindowFunc:
67 type = ((const WindowFunc *) expr)->wintype;
68 break;
70 type = ((const MergeSupportFunc *) expr)->msftype;
71 break;
73 type = ((const SubscriptingRef *) expr)->refrestype;
74 break;
75 case T_FuncExpr:
76 type = ((const FuncExpr *) expr)->funcresulttype;
77 break;
78 case T_NamedArgExpr:
79 type = exprType((Node *) ((const NamedArgExpr *) expr)->arg);
80 break;
81 case T_OpExpr:
82 type = ((const OpExpr *) expr)->opresulttype;
83 break;
84 case T_DistinctExpr:
85 type = ((const DistinctExpr *) expr)->opresulttype;
86 break;
87 case T_NullIfExpr:
88 type = ((const NullIfExpr *) expr)->opresulttype;
89 break;
91 type = BOOLOID;
92 break;
93 case T_BoolExpr:
94 type = BOOLOID;
95 break;
96 case T_SubLink:
97 {
98 const SubLink *sublink = (const SubLink *) expr;
99
100 if (sublink->subLinkType == EXPR_SUBLINK ||
101 sublink->subLinkType == ARRAY_SUBLINK)
102 {
103 /* get the type of the subselect's first target column */
104 Query *qtree = (Query *) sublink->subselect;
106
107 if (!qtree || !IsA(qtree, Query))
108 elog(ERROR, "cannot get type for untransformed sublink");
109 tent = linitial_node(TargetEntry, qtree->targetList);
110 Assert(!tent->resjunk);
111 type = exprType((Node *) tent->expr);
112 if (sublink->subLinkType == ARRAY_SUBLINK)
113 {
115 if (!OidIsValid(type))
118 errmsg("could not find array type for data type %s",
119 format_type_be(exprType((Node *) tent->expr)))));
120 }
121 }
122 else if (sublink->subLinkType == MULTIEXPR_SUBLINK)
123 {
124 /* MULTIEXPR is always considered to return RECORD */
125 type = RECORDOID;
126 }
127 else
128 {
129 /* for all other sublink types, result is boolean */
130 type = BOOLOID;
131 }
132 }
133 break;
134 case T_SubPlan:
135 {
136 const SubPlan *subplan = (const SubPlan *) expr;
137
138 if (subplan->subLinkType == EXPR_SUBLINK ||
139 subplan->subLinkType == ARRAY_SUBLINK)
140 {
141 /* get the type of the subselect's first target column */
142 type = subplan->firstColType;
143 if (subplan->subLinkType == ARRAY_SUBLINK)
144 {
146 if (!OidIsValid(type))
149 errmsg("could not find array type for data type %s",
150 format_type_be(subplan->firstColType))));
151 }
152 }
153 else if (subplan->subLinkType == MULTIEXPR_SUBLINK)
154 {
155 /* MULTIEXPR is always considered to return RECORD */
156 type = RECORDOID;
157 }
158 else
159 {
160 /* for all other subplan types, result is boolean */
161 type = BOOLOID;
162 }
163 }
164 break;
166 {
167 const AlternativeSubPlan *asplan = (const AlternativeSubPlan *) expr;
168
169 /* subplans should all return the same thing */
170 type = exprType((Node *) linitial(asplan->subplans));
171 }
172 break;
173 case T_FieldSelect:
174 type = ((const FieldSelect *) expr)->resulttype;
175 break;
176 case T_FieldStore:
177 type = ((const FieldStore *) expr)->resulttype;
178 break;
179 case T_RelabelType:
180 type = ((const RelabelType *) expr)->resulttype;
181 break;
182 case T_CoerceViaIO:
183 type = ((const CoerceViaIO *) expr)->resulttype;
184 break;
186 type = ((const ArrayCoerceExpr *) expr)->resulttype;
187 break;
189 type = ((const ConvertRowtypeExpr *) expr)->resulttype;
190 break;
191 case T_CollateExpr:
192 type = exprType((Node *) ((const CollateExpr *) expr)->arg);
193 break;
194 case T_CaseExpr:
195 type = ((const CaseExpr *) expr)->casetype;
196 break;
197 case T_CaseTestExpr:
198 type = ((const CaseTestExpr *) expr)->typeId;
199 break;
200 case T_ArrayExpr:
201 type = ((const ArrayExpr *) expr)->array_typeid;
202 break;
203 case T_RowExpr:
204 type = ((const RowExpr *) expr)->row_typeid;
205 break;
206 case T_RowCompareExpr:
207 type = BOOLOID;
208 break;
209 case T_CoalesceExpr:
210 type = ((const CoalesceExpr *) expr)->coalescetype;
211 break;
212 case T_MinMaxExpr:
213 type = ((const MinMaxExpr *) expr)->minmaxtype;
214 break;
216 type = ((const SQLValueFunction *) expr)->type;
217 break;
218 case T_XmlExpr:
219 if (((const XmlExpr *) expr)->op == IS_DOCUMENT)
220 type = BOOLOID;
221 else if (((const XmlExpr *) expr)->op == IS_XMLSERIALIZE)
222 type = TEXTOID;
223 else
224 type = XMLOID;
225 break;
226 case T_JsonValueExpr:
227 {
228 const JsonValueExpr *jve = (const JsonValueExpr *) expr;
229
230 type = exprType((Node *) jve->formatted_expr);
231 }
232 break;
234 type = ((const JsonConstructorExpr *) expr)->returning->typid;
235 break;
237 type = BOOLOID;
238 break;
239 case T_JsonExpr:
240 {
241 const JsonExpr *jexpr = (const JsonExpr *) expr;
242
244 break;
245 }
246 case T_JsonBehavior:
247 {
248 const JsonBehavior *behavior = (const JsonBehavior *) expr;
249
250 type = exprType(behavior->expr);
251 break;
252 }
253 case T_NullTest:
254 type = BOOLOID;
255 break;
256 case T_BooleanTest:
257 type = BOOLOID;
258 break;
259 case T_CoerceToDomain:
260 type = ((const CoerceToDomain *) expr)->resulttype;
261 break;
263 type = ((const CoerceToDomainValue *) expr)->typeId;
264 break;
265 case T_SetToDefault:
266 type = ((const SetToDefault *) expr)->typeId;
267 break;
268 case T_CurrentOfExpr:
269 type = BOOLOID;
270 break;
271 case T_NextValueExpr:
272 type = ((const NextValueExpr *) expr)->typeId;
273 break;
274 case T_InferenceElem:
275 {
276 const InferenceElem *n = (const InferenceElem *) expr;
277
278 type = exprType((Node *) n->expr);
279 }
280 break;
281 case T_ReturningExpr:
282 type = exprType((Node *) ((const ReturningExpr *) expr)->retexpr);
283 break;
284 case T_PlaceHolderVar:
285 type = exprType((Node *) ((const PlaceHolderVar *) expr)->phexpr);
286 break;
288 type = ((const GraphPropertyRef *) expr)->typeId;
289 break;
290 default:
291 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(expr));
292 type = InvalidOid; /* keep compiler quiet */
293 break;
294 }
295 return type;
296}
int errcode(int sqlerrcode)
Definition elog.c:875
#define ereport(elevel,...)
Definition elog.h:152
char * format_type_be(Oid type_oid)
Oid get_promoted_array_type(Oid typid)
Definition lsyscache.c:3006
static char * errmsg
@ MULTIEXPR_SUBLINK
Definition primnodes.h:1035
@ IS_DOCUMENT
Definition primnodes.h:1614
JsonReturning * returning
Definition primnodes.h:1860
Oid firstColType
Definition primnodes.h:1107

References arg, ARRAY_SUBLINK, Assert, elog, ereport, errcode(), errmsg, ERROR, JsonBehavior::expr, InferenceElem::expr, EXPR_SUBLINK, exprType(), fb(), SubPlan::firstColType, format_type_be(), get_promoted_array_type(), InvalidOid, IS_DOCUMENT, IS_XMLSERIALIZE, IsA, linitial, linitial_node, MULTIEXPR_SUBLINK, nodeTag, OidIsValid, SubPlan::subLinkType, and type.

Referenced by add_row_identity_var(), add_setop_child_rel_equivalences(), addRangeTableEntryForFunction(), addRangeTableEntryForGraphTable(), addRangeTableEntryForGroup(), addRangeTableEntryForSubquery(), addTargetToGroupList(), addTargetToSortList(), agg_args_support_sendreceive(), analyzeCTE(), analyzeCTETargetList(), appendAggOrderBy(), appendOrderByClause(), applyRelabelType(), array_subscript_transform(), assign_collations_walker(), assign_hypothetical_collations(), assign_param_for_placeholdervar(), ATExecAlterColumnType(), ATPrepAlterColumnType(), build_coercion_expression(), build_column_default(), build_edge_vertex_link_quals(), build_subplan(), calculate_frame_offsets(), CallStmtResultDesc(), can_minmax_aggs(), canonicalize_ec_expression(), check_functions_in_node(), check_hashjoinable(), check_memoizable(), check_mergejoinable(), check_simple_rowfilter_expr_walker(), check_sql_stmt_retval(), check_virtual_generated_security_walker(), checkRuleResultList(), coerce_fn_result_column(), coerce_record_to_complex(), coerce_to_boolean(), coerce_to_common_type(), coerce_to_specific_type_typmod(), coerceJsonFuncExpr(), compare_tlist_datatypes(), compute_semijoin_info(), ComputeIndexAttrs(), ComputePartitionAttrs(), constructSetOpTargetlist(), ConstructTupleDescriptor(), contain_mutable_functions_walker(), convert_EXISTS_to_ANY(), convert_VALUES_to_ANY(), cookDefault(), cost_qual_eval_walker(), create_ctas_nodata(), create_grouping_expr_infos(), create_indexscan_plan(), CreateStatistics(), DefineVirtualRelation(), deparseNullTest(), deparseOpExpr(), estimate_num_groups(), eval_const_expressions_mutator(), EvaluateParams(), examine_attribute(), examine_attribute(), examine_expression(), examine_variable(), exec_save_simple_expr(), ExecBuildProjectionInfo(), ExecBuildUpdateProjection(), ExecCheckPlanOutput(), ExecEvalXmlExpr(), ExecInitExprRec(), ExecInitIndexScan(), ExecInitJsonExpr(), ExecInitSubPlanExpr(), ExecMakeTableFunctionResult(), ExecTypeFromExprList(), ExecTypeFromTLInternal(), expandRecordVariable(), expandRTE(), exprType(), exprTypmod(), extended_statistics_update(), find_expr_references_walker(), find_placeholder_info(), fix_indexqual_operand(), foreign_expr_walker(), generate_append_tlist(), generate_join_implied_equalities_normal(), generate_query_for_empty_path_pattern(), generate_setop_child_grouplist(), generate_setop_tlist(), generate_subquery_params(), generateClonedIndexStmt(), get_call_expr_argtype(), get_expr_result_tupdesc(), get_expr_result_type(), get_expr_width(), get_first_col_type(), get_fn_expr_rettype(), get_func_expr(), get_oper_expr(), get_rule_expr(), get_rule_expr_funccall(), get_rule_orderby(), get_simple_binary_op_name(), get_sublink_expr(), get_windowfunc_expr_helper(), GetIndexInputType(), hash_ok_operator(), hstore_subscript_transform(), init_grouping_targets(), initialize_peragg(), inline_function(), insert_property_record(), internal_get_result_type(), jsonb_exec_setup(), jsonb_subscript_transform(), JsonTableInitOpaque(), jspIsMutableWalker(), make_op(), make_scalar_array_op(), makeJsonConstructorExpr(), makeVarFromTargetEntry(), makeWholeRowVar(), match_orclause_to_indexcol(), match_pattern_prefix(), ordered_set_startup(), paraminfo_get_equal_hashops(), ParseFuncOrColumn(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), prepare_query_params(), preprocess_aggref(), preprocess_minmax_aggregates(), ProcedureCreate(), process_equivalence(), process_matched_tle(), recheck_cast_function_args(), relabel_to_typmod(), RelationBuildPartitionKey(), RelationGetDummyIndexExpressions(), remove_unused_subquery_outputs(), replace_nestloop_param_placeholdervar(), replace_outer_grouping(), replace_outer_merge_support(), replace_outer_placeholdervar(), replace_outer_returning(), resolveTargetListUnknowns(), scalararraysel(), select_common_type(), select_common_typmod(), set_append_rel_size(), set_dummy_tlist_references(), set_joinrel_partition_key_exprs(), set_rel_width(), show_sortorder_options(), statatt_get_type(), tlist_same_datatypes(), transformAExprNullIf(), transformAggregateCall(), transformArrayExpr(), transformAssignedExpr(), transformAssignmentIndirection(), transformAssignmentSubscripts(), transformCaseExpr(), transformCollateClause(), transformExprRecurse(), transformForPortionOfClause(), transformFrameOffset(), transformFromClauseItem(), transformIndirection(), transformInsertStmt(), transformJsonBehavior(), transformJsonConstructorOutput(), transformJsonFuncExpr(), transformJsonIsPredicate(), transformJsonParseArg(), transformJsonScalarExpr(), transformJsonTableColumns(), transformJsonValueExpr(), transformMultiAssignRef(), transformPartitionBoundValue(), transformPLAssignStmtTarget(), transformSubLink(), transformTypeCast(), unknown_attribute(), verify_common_type(), and xmlelement().

◆ exprTypmod()

int32 exprTypmod ( const Node expr)
extern

Definition at line 304 of file nodeFuncs.c.

305{
306 if (!expr)
307 return -1;
308
309 switch (nodeTag(expr))
310 {
311 case T_Var:
312 return ((const Var *) expr)->vartypmod;
313 case T_Const:
314 return ((const Const *) expr)->consttypmod;
315 case T_Param:
316 return ((const Param *) expr)->paramtypmod;
318 return ((const SubscriptingRef *) expr)->reftypmod;
319 case T_FuncExpr:
320 {
322
323 /* Be smart about length-coercion functions... */
325 return coercedTypmod;
326 }
327 break;
328 case T_NamedArgExpr:
329 return exprTypmod((Node *) ((const NamedArgExpr *) expr)->arg);
330 case T_NullIfExpr:
331 {
332 /*
333 * Result is either first argument or NULL, so we can report
334 * first argument's typmod if known.
335 */
336 const NullIfExpr *nexpr = (const NullIfExpr *) expr;
337
338 return exprTypmod((Node *) linitial(nexpr->args));
339 }
340 break;
341 case T_SubLink:
342 {
343 const SubLink *sublink = (const SubLink *) expr;
344
345 if (sublink->subLinkType == EXPR_SUBLINK ||
346 sublink->subLinkType == ARRAY_SUBLINK)
347 {
348 /* get the typmod of the subselect's first target column */
349 Query *qtree = (Query *) sublink->subselect;
351
352 if (!qtree || !IsA(qtree, Query))
353 elog(ERROR, "cannot get type for untransformed sublink");
354 tent = linitial_node(TargetEntry, qtree->targetList);
355 Assert(!tent->resjunk);
356 return exprTypmod((Node *) tent->expr);
357 /* note we don't need to care if it's an array */
358 }
359 /* otherwise, result is RECORD or BOOLEAN, typmod is -1 */
360 }
361 break;
362 case T_SubPlan:
363 {
364 const SubPlan *subplan = (const SubPlan *) expr;
365
366 if (subplan->subLinkType == EXPR_SUBLINK ||
367 subplan->subLinkType == ARRAY_SUBLINK)
368 {
369 /* get the typmod of the subselect's first target column */
370 /* note we don't need to care if it's an array */
371 return subplan->firstColTypmod;
372 }
373 /* otherwise, result is RECORD or BOOLEAN, typmod is -1 */
374 }
375 break;
377 {
378 const AlternativeSubPlan *asplan = (const AlternativeSubPlan *) expr;
379
380 /* subplans should all return the same thing */
381 return exprTypmod((Node *) linitial(asplan->subplans));
382 }
383 break;
384 case T_FieldSelect:
385 return ((const FieldSelect *) expr)->resulttypmod;
386 case T_RelabelType:
387 return ((const RelabelType *) expr)->resulttypmod;
389 return ((const ArrayCoerceExpr *) expr)->resulttypmod;
390 case T_CollateExpr:
391 return exprTypmod((Node *) ((const CollateExpr *) expr)->arg);
392 case T_CaseExpr:
393 {
394 /*
395 * If all the alternatives agree on type/typmod, return that
396 * typmod, else use -1
397 */
398 const CaseExpr *cexpr = (const CaseExpr *) expr;
399 Oid casetype = cexpr->casetype;
400 int32 typmod;
401 ListCell *arg;
402
403 if (!cexpr->defresult)
404 return -1;
405 if (exprType((Node *) cexpr->defresult) != casetype)
406 return -1;
407 typmod = exprTypmod((Node *) cexpr->defresult);
408 if (typmod < 0)
409 return -1; /* no point in trying harder */
410 foreach(arg, cexpr->args)
411 {
413
414 if (exprType((Node *) w->result) != casetype)
415 return -1;
416 if (exprTypmod((Node *) w->result) != typmod)
417 return -1;
418 }
419 return typmod;
420 }
421 break;
422 case T_CaseTestExpr:
423 return ((const CaseTestExpr *) expr)->typeMod;
424 case T_ArrayExpr:
425 {
426 /*
427 * If all the elements agree on type/typmod, return that
428 * typmod, else use -1
429 */
430 const ArrayExpr *arrayexpr = (const ArrayExpr *) expr;
432 int32 typmod;
433 ListCell *elem;
434
435 if (arrayexpr->elements == NIL)
436 return -1;
437 typmod = exprTypmod((Node *) linitial(arrayexpr->elements));
438 if (typmod < 0)
439 return -1; /* no point in trying harder */
440 if (arrayexpr->multidims)
441 commontype = arrayexpr->array_typeid;
442 else
443 commontype = arrayexpr->element_typeid;
444 foreach(elem, arrayexpr->elements)
445 {
446 Node *e = (Node *) lfirst(elem);
447
448 if (exprType(e) != commontype)
449 return -1;
450 if (exprTypmod(e) != typmod)
451 return -1;
452 }
453 return typmod;
454 }
455 break;
456 case T_CoalesceExpr:
457 {
458 /*
459 * If all the alternatives agree on type/typmod, return that
460 * typmod, else use -1
461 */
462 const CoalesceExpr *cexpr = (const CoalesceExpr *) expr;
463 Oid coalescetype = cexpr->coalescetype;
464 int32 typmod;
465 ListCell *arg;
466
467 if (exprType((Node *) linitial(cexpr->args)) != coalescetype)
468 return -1;
469 typmod = exprTypmod((Node *) linitial(cexpr->args));
470 if (typmod < 0)
471 return -1; /* no point in trying harder */
472 for_each_from(arg, cexpr->args, 1)
473 {
474 Node *e = (Node *) lfirst(arg);
475
476 if (exprType(e) != coalescetype)
477 return -1;
478 if (exprTypmod(e) != typmod)
479 return -1;
480 }
481 return typmod;
482 }
483 break;
484 case T_MinMaxExpr:
485 {
486 /*
487 * If all the alternatives agree on type/typmod, return that
488 * typmod, else use -1
489 */
490 const MinMaxExpr *mexpr = (const MinMaxExpr *) expr;
491 Oid minmaxtype = mexpr->minmaxtype;
492 int32 typmod;
493 ListCell *arg;
494
495 if (exprType((Node *) linitial(mexpr->args)) != minmaxtype)
496 return -1;
497 typmod = exprTypmod((Node *) linitial(mexpr->args));
498 if (typmod < 0)
499 return -1; /* no point in trying harder */
500 for_each_from(arg, mexpr->args, 1)
501 {
502 Node *e = (Node *) lfirst(arg);
503
504 if (exprType(e) != minmaxtype)
505 return -1;
506 if (exprTypmod(e) != typmod)
507 return -1;
508 }
509 return typmod;
510 }
511 break;
513 return ((const SQLValueFunction *) expr)->typmod;
514 case T_JsonValueExpr:
515 return exprTypmod((Node *) ((const JsonValueExpr *) expr)->formatted_expr);
517 return ((const JsonConstructorExpr *) expr)->returning->typmod;
518 case T_JsonExpr:
519 {
520 const JsonExpr *jexpr = (const JsonExpr *) expr;
521
522 return jexpr->returning->typmod;
523 }
524 break;
525 case T_JsonBehavior:
526 {
527 const JsonBehavior *behavior = (const JsonBehavior *) expr;
528
529 return exprTypmod(behavior->expr);
530 }
531 break;
532 case T_CoerceToDomain:
533 return ((const CoerceToDomain *) expr)->resulttypmod;
535 return ((const CoerceToDomainValue *) expr)->typeMod;
536 case T_SetToDefault:
537 return ((const SetToDefault *) expr)->typeMod;
538 case T_ReturningExpr:
539 return exprTypmod((Node *) ((const ReturningExpr *) expr)->retexpr);
540 case T_PlaceHolderVar:
541 return exprTypmod((Node *) ((const PlaceHolderVar *) expr)->phexpr);
543 return ((const GraphPropertyRef *) expr)->typmod;
544 default:
545 break;
546 }
547 return -1;
548}
int32_t int32
Definition c.h:620
bool exprIsLengthCoercion(const Node *expr, int32 *coercedTypmod)
Definition nodeFuncs.c:562
#define for_each_from(cell, lst, N)
Definition pg_list.h:446
e
Expr * defresult
Definition primnodes.h:1350
List * args
Definition primnodes.h:1349
Expr * result
Definition primnodes.h:1361
int32 firstColTypmod
Definition primnodes.h:1108

References arg, CaseExpr::args, CoalesceExpr::args, ARRAY_SUBLINK, Assert, CaseExpr::defresult, elog, ERROR, JsonBehavior::expr, EXPR_SUBLINK, exprIsLengthCoercion(), exprType(), exprTypmod(), fb(), SubPlan::firstColTypmod, for_each_from, IsA, lfirst, lfirst_node, linitial, linitial_node, NIL, nodeTag, CaseWhen::result, and SubPlan::subLinkType.

Referenced by add_row_identity_var(), addRangeTableEntryForFunction(), addRangeTableEntryForGraphTable(), addRangeTableEntryForGroup(), addRangeTableEntryForSubquery(), analyzeCTE(), analyzeCTETargetList(), applyRelabelType(), assign_hypothetical_collations(), build_coercion_expression(), build_subplan(), canonicalize_ec_expression(), checkRuleResultList(), coerce_type_typmod(), ConstructTupleDescriptor(), convert_EXISTS_to_ANY(), create_ctas_nodata(), DefineVirtualRelation(), eval_const_expressions_mutator(), examine_attribute(), examine_attribute(), examine_expression(), examine_variable(), exec_save_simple_expr(), ExecInitJsonExpr(), ExecTypeFromExprList(), ExecTypeFromTLInternal(), expandRecordVariable(), expandRTE(), exprTypmod(), extended_statistics_update(), find_placeholder_info(), generate_append_tlist(), generate_query_for_empty_path_pattern(), generate_setop_tlist(), generate_subquery_params(), get_expr_result_type(), get_expr_width(), get_first_col_type(), get_rule_expr(), get_rule_expr_funccall(), insert_property_record(), interval_support(), JsonTableInitOpaque(), makeJsonConstructorExpr(), makeVarFromTargetEntry(), numeric_support(), preprocess_aggref(), RelationBuildPartitionKey(), RelationGetDummyIndexExpressions(), remove_unused_subquery_outputs(), replace_nestloop_param_placeholdervar(), replace_outer_placeholdervar(), replace_outer_returning(), select_common_typmod(), set_append_rel_size(), set_dummy_tlist_references(), set_rel_width(), statatt_get_type(), TemporalSimplify(), transformCaseExpr(), transformFromClauseItem(), transformIndirection(), transformInsertStmt(), transformJsonTableColumns(), transformMultiAssignRef(), transformPLAssignStmtTarget(), transformSubLink(), varbit_support(), and varchar_support().

◆ fix_opfuncids()

void fix_opfuncids ( Node node)
extern

Definition at line 1848 of file nodeFuncs.c.

1849{
1850 /* This tree walk requires no special setup, so away we go... */
1852}
static bool fix_opfuncids_walker(Node *node, void *context)
Definition nodeFuncs.c:1855

References fb(), and fix_opfuncids_walker().

Referenced by evaluate_expr(), expression_planner(), expression_planner_with_deps(), extended_statistics_update(), fetch_statentries_for_relation(), get_qual_for_range(), get_relation_statistics(), operator_predicate_proof(), RelationBuildPartitionKey(), RelationGetIndexExpressions(), and RelationGetIndexPredicate().

◆ get_leftop()

◆ get_notclausearg()

◆ get_rightop()

◆ is_andclause()

◆ is_funcclause()

◆ is_notclause()

◆ is_opclause()

◆ is_orclause()

◆ planstate_tree_walker_impl()

bool planstate_tree_walker_impl ( PlanState planstate,
planstate_tree_walker_callback  walker,
void context 
)
extern

Definition at line 4830 of file nodeFuncs.c.

4833{
4834 Plan *plan = planstate->plan;
4835 ListCell *lc;
4836
4837 /* We don't need implicit coercions to Node here */
4838#define PSWALK(n) walker(n, context)
4839
4840 /* Guard against stack overflow due to overly complex plan trees */
4842
4843 /* initPlan-s */
4844 if (planstate_walk_subplans(planstate->initPlan, walker, context))
4845 return true;
4846
4847 /* lefttree */
4848 if (outerPlanState(planstate))
4849 {
4850 if (PSWALK(outerPlanState(planstate)))
4851 return true;
4852 }
4853
4854 /* righttree */
4855 if (innerPlanState(planstate))
4856 {
4857 if (PSWALK(innerPlanState(planstate)))
4858 return true;
4859 }
4860
4861 /* special child plans */
4862 switch (nodeTag(plan))
4863 {
4864 case T_Append:
4865 if (planstate_walk_members(((AppendState *) planstate)->appendplans,
4866 ((AppendState *) planstate)->as_nplans,
4867 walker, context))
4868 return true;
4869 break;
4870 case T_MergeAppend:
4871 if (planstate_walk_members(((MergeAppendState *) planstate)->mergeplans,
4872 ((MergeAppendState *) planstate)->ms_nplans,
4873 walker, context))
4874 return true;
4875 break;
4876 case T_BitmapAnd:
4877 if (planstate_walk_members(((BitmapAndState *) planstate)->bitmapplans,
4878 ((BitmapAndState *) planstate)->nplans,
4879 walker, context))
4880 return true;
4881 break;
4882 case T_BitmapOr:
4883 if (planstate_walk_members(((BitmapOrState *) planstate)->bitmapplans,
4884 ((BitmapOrState *) planstate)->nplans,
4885 walker, context))
4886 return true;
4887 break;
4888 case T_SubqueryScan:
4889 if (PSWALK(((SubqueryScanState *) planstate)->subplan))
4890 return true;
4891 break;
4892 case T_CustomScan:
4893 foreach(lc, ((CustomScanState *) planstate)->custom_ps)
4894 {
4895 if (PSWALK(lfirst(lc)))
4896 return true;
4897 }
4898 break;
4899 default:
4900 break;
4901 }
4902
4903 /* subPlan-s */
4904 if (planstate_walk_subplans(planstate->subPlan, walker, context))
4905 return true;
4906
4907 return false;
4908}
#define outerPlanState(node)
Definition execnodes.h:1299
#define innerPlanState(node)
Definition execnodes.h:1298
static bool planstate_walk_subplans(List *plans, planstate_tree_walker_callback walker, void *context)
Definition nodeFuncs.c:4914
#define PSWALK(n)
static bool planstate_walk_members(PlanState **planstates, int nplans, planstate_tree_walker_callback walker, void *context)
Definition nodeFuncs.c:4936
#define plan(x)
Definition pg_regress.c:164
Plan * plan
Definition execnodes.h:1201
List * initPlan
Definition execnodes.h:1228

References check_stack_depth(), fb(), PlanState::initPlan, innerPlanState, lfirst, nodeTag, outerPlanState, PlanState::plan, plan, planstate_walk_members(), planstate_walk_subplans(), PSWALK, and PlanState::subPlan.

◆ query_or_expression_tree_mutator_impl()

Node * query_or_expression_tree_mutator_impl ( Node node,
tree_mutator_callback  mutator,
void context,
int  flags 
)
extern

Definition at line 4044 of file nodeFuncs.c.

4048{
4049 if (node && IsA(node, Query))
4050 return (Node *) query_tree_mutator((Query *) node,
4051 mutator,
4052 context,
4053 flags);
4054 else
4055 return mutator(node, context);
4056}
#define query_tree_mutator(q, m, c, f)
Definition nodeFuncs.h:160

References fb(), IsA, and query_tree_mutator.

◆ query_or_expression_tree_walker_impl()

bool query_or_expression_tree_walker_impl ( Node node,
tree_walker_callback  walker,
void context,
int  flags 
)
extern

Definition at line 4021 of file nodeFuncs.c.

4025{
4026 if (node && IsA(node, Query))
4027 return query_tree_walker((Query *) node,
4028 walker,
4029 context,
4030 flags);
4031 else
4032 return WALK(node);
4033}
#define query_tree_walker(q, w, c, f)
Definition nodeFuncs.h:158

References fb(), IsA, query_tree_walker, and WALK.

◆ query_tree_mutator_impl()

Query * query_tree_mutator_impl ( Query query,
tree_mutator_callback  mutator,
void context,
int  flags 
)
extern

Definition at line 3847 of file nodeFuncs.c.

3851{
3852 Assert(query != NULL && IsA(query, Query));
3853
3854 if (!(flags & QTW_DONT_COPY_QUERY))
3855 {
3856 Query *newquery;
3857
3858 FLATCOPY(newquery, query, Query);
3859 query = newquery;
3860 }
3861
3862 MUTATE(query->targetList, query->targetList, List *);
3863 MUTATE(query->withCheckOptions, query->withCheckOptions, List *);
3864 MUTATE(query->onConflict, query->onConflict, OnConflictExpr *);
3865 MUTATE(query->mergeActionList, query->mergeActionList, List *);
3868 MUTATE(query->returningList, query->returningList, List *);
3869 MUTATE(query->jointree, query->jointree, FromExpr *);
3870 MUTATE(query->setOperations, query->setOperations, Node *);
3871 MUTATE(query->havingQual, query->havingQual, Node *);
3872 MUTATE(query->limitOffset, query->limitOffset, Node *);
3873 MUTATE(query->limitCount, query->limitCount, Node *);
3874
3875 /*
3876 * Most callers aren't interested in SortGroupClause nodes since those
3877 * don't contain actual expressions. However they do contain OIDs, which
3878 * may be of interest to some mutators.
3879 */
3880
3881 if ((flags & QTW_EXAMINE_SORTGROUP))
3882 {
3883 MUTATE(query->groupClause, query->groupClause, List *);
3884 MUTATE(query->windowClause, query->windowClause, List *);
3885 MUTATE(query->sortClause, query->sortClause, List *);
3886 MUTATE(query->distinctClause, query->distinctClause, List *);
3887 }
3888 else
3889 {
3890 /*
3891 * But we need to mutate the expressions under WindowClause nodes even
3892 * if we're not interested in SortGroupClause nodes.
3893 */
3895 ListCell *temp;
3896
3897 resultlist = NIL;
3898 foreach(temp, query->windowClause)
3899 {
3902
3904 MUTATE(newnode->startOffset, wc->startOffset, Node *);
3905 MUTATE(newnode->endOffset, wc->endOffset, Node *);
3906
3908 }
3909 query->windowClause = resultlist;
3910 }
3911
3912 /*
3913 * groupingSets and rowMarks are not mutated:
3914 *
3915 * groupingSets contain only ressortgroup refs (integers) which are
3916 * meaningless without the groupClause or tlist. Accordingly, any mutator
3917 * that needs to care about them needs to handle them itself in its Query
3918 * processing.
3919 *
3920 * rowMarks contains only rangetable indexes (and flags etc.) and
3921 * therefore should be handled at Query level similarly.
3922 */
3923
3924 if (!(flags & QTW_IGNORE_CTE_SUBQUERIES))
3925 MUTATE(query->cteList, query->cteList, List *);
3926 else /* else copy CTE list as-is */
3927 query->cteList = copyObject(query->cteList);
3928 query->rtable = range_table_mutator(query->rtable,
3929 mutator, context, flags);
3930 return query;
3931}
#define QTW_DONT_COPY_QUERY
Definition nodeFuncs.h:29
#define QTW_IGNORE_CTE_SUBQUERIES
Definition nodeFuncs.h:23
#define QTW_EXAMINE_SORTGROUP
Definition nodeFuncs.h:30
#define range_table_mutator(rt, m, c, f)
Definition nodeFuncs.h:165
Node * mergeJoinCondition
Definition parsenodes.h:199
Node * limitCount
Definition parsenodes.h:234
FromExpr * jointree
Definition parsenodes.h:185
List * returningList
Definition parsenodes.h:217
Node * setOperations
Definition parsenodes.h:239
List * cteList
Definition parsenodes.h:176
OnConflictExpr * onConflict
Definition parsenodes.h:206
ForPortionOfExpr * forPortionOf
Definition parsenodes.h:151
List * groupClause
Definition parsenodes.h:219
Node * havingQual
Definition parsenodes.h:225
List * rtable
Definition parsenodes.h:178
Node * limitOffset
Definition parsenodes.h:233
List * mergeActionList
Definition parsenodes.h:188
List * windowClause
Definition parsenodes.h:227
List * targetList
Definition parsenodes.h:201
List * distinctClause
Definition parsenodes.h:229
List * sortClause
Definition parsenodes.h:231

References Assert, copyObject, Query::cteList, Query::distinctClause, WindowClause::endOffset, fb(), FLATCOPY, Query::forPortionOf, Query::groupClause, Query::havingQual, IsA, Query::jointree, lappend(), lfirst_node, Query::limitCount, Query::limitOffset, Query::mergeActionList, Query::mergeJoinCondition, MUTATE, NIL, Query::onConflict, QTW_DONT_COPY_QUERY, QTW_EXAMINE_SORTGROUP, QTW_IGNORE_CTE_SUBQUERIES, range_table_mutator, Query::returningList, Query::rtable, Query::setOperations, Query::sortClause, WindowClause::startOffset, Query::targetList, and Query::windowClause.

◆ query_tree_walker_impl()

bool query_tree_walker_impl ( Query query,
tree_walker_callback  walker,
void context,
int  flags 
)
extern

Definition at line 2744 of file nodeFuncs.c.

2748{
2749 Assert(query != NULL && IsA(query, Query));
2750
2751 /*
2752 * We don't walk any utilityStmt here. However, we can't easily assert
2753 * that it is absent, since there are at least two code paths by which
2754 * action statements from CREATE RULE end up here, and NOTIFY is allowed
2755 * in a rule action.
2756 */
2757
2758 if (WALK(query->targetList))
2759 return true;
2760 if (WALK(query->withCheckOptions))
2761 return true;
2762 if (WALK(query->onConflict))
2763 return true;
2764 if (WALK(query->mergeActionList))
2765 return true;
2766 if (WALK(query->mergeJoinCondition))
2767 return true;
2768 if (WALK(query->forPortionOf))
2769 return true;
2770 if (WALK(query->returningList))
2771 return true;
2772 if (WALK(query->jointree))
2773 return true;
2774 if (WALK(query->setOperations))
2775 return true;
2776 if (WALK(query->havingQual))
2777 return true;
2778 if (WALK(query->limitOffset))
2779 return true;
2780 if (WALK(query->limitCount))
2781 return true;
2782
2783 /*
2784 * Most callers aren't interested in SortGroupClause nodes since those
2785 * don't contain actual expressions. However they do contain OIDs which
2786 * may be needed by dependency walkers etc.
2787 */
2788 if ((flags & QTW_EXAMINE_SORTGROUP))
2789 {
2790 if (WALK(query->groupClause))
2791 return true;
2792 if (WALK(query->windowClause))
2793 return true;
2794 if (WALK(query->sortClause))
2795 return true;
2796 if (WALK(query->distinctClause))
2797 return true;
2798 }
2799 else
2800 {
2801 /*
2802 * But we need to walk the expressions under WindowClause nodes even
2803 * if we're not interested in SortGroupClause nodes.
2804 */
2805 ListCell *lc;
2806
2807 foreach(lc, query->windowClause)
2808 {
2810
2811 if (WALK(wc->startOffset))
2812 return true;
2813 if (WALK(wc->endOffset))
2814 return true;
2815 }
2816 }
2817
2818 /*
2819 * groupingSets and rowMarks are not walked:
2820 *
2821 * groupingSets contain only ressortgrouprefs (integers) which are
2822 * meaningless without the corresponding groupClause or tlist.
2823 * Accordingly, any walker that needs to care about them needs to handle
2824 * them itself in its Query processing.
2825 *
2826 * rowMarks is not walked because it contains only rangetable indexes (and
2827 * flags etc.) and therefore should be handled at Query level similarly.
2828 */
2829
2830 if (!(flags & QTW_IGNORE_CTE_SUBQUERIES))
2831 {
2832 if (WALK(query->cteList))
2833 return true;
2834 }
2835 if (!(flags & QTW_IGNORE_RANGE_TABLE))
2836 {
2837 if (range_table_walker(query->rtable, walker, context, flags))
2838 return true;
2839 }
2840 return false;
2841}
#define range_table_walker(rt, w, c, f)
Definition nodeFuncs.h:163
#define QTW_IGNORE_RANGE_TABLE
Definition nodeFuncs.h:26

References Assert, Query::cteList, Query::distinctClause, WindowClause::endOffset, fb(), Query::forPortionOf, Query::groupClause, Query::havingQual, IsA, Query::jointree, lfirst_node, Query::limitCount, Query::limitOffset, Query::mergeActionList, Query::mergeJoinCondition, Query::onConflict, QTW_EXAMINE_SORTGROUP, QTW_IGNORE_CTE_SUBQUERIES, QTW_IGNORE_RANGE_TABLE, range_table_walker, Query::returningList, Query::rtable, Query::setOperations, Query::sortClause, WindowClause::startOffset, Query::targetList, WALK, and Query::windowClause.

◆ range_table_entry_walker_impl()

bool range_table_entry_walker_impl ( RangeTblEntry rte,
tree_walker_callback  walker,
void context,
int  flags 
)
extern

Definition at line 2870 of file nodeFuncs.c.

2874{
2875 /*
2876 * Walkers might need to examine the RTE node itself either before or
2877 * after visiting its contents (or, conceivably, both). Note that if you
2878 * specify neither flag, the walker won't be called on the RTE at all.
2879 */
2880 if (flags & QTW_EXAMINE_RTES_BEFORE)
2881 if (WALK(rte))
2882 return true;
2883
2884 switch (rte->rtekind)
2885 {
2886 case RTE_RELATION:
2887 if (WALK(rte->tablesample))
2888 return true;
2889 break;
2890 case RTE_SUBQUERY:
2891 if (!(flags & QTW_IGNORE_RT_SUBQUERIES))
2892 if (WALK(rte->subquery))
2893 return true;
2894 break;
2895 case RTE_JOIN:
2896 if (!(flags & QTW_IGNORE_JOINALIASES))
2897 if (WALK(rte->joinaliasvars))
2898 return true;
2899 break;
2900 case RTE_FUNCTION:
2901 if (WALK(rte->functions))
2902 return true;
2903 break;
2904 case RTE_TABLEFUNC:
2905 if (WALK(rte->tablefunc))
2906 return true;
2907 break;
2908 case RTE_VALUES:
2909 if (WALK(rte->values_lists))
2910 return true;
2911 break;
2912 case RTE_GRAPH_TABLE:
2913 if (WALK(rte->graph_pattern))
2914 return true;
2915 if (WALK(rte->graph_table_columns))
2916 return true;
2917 break;
2918 case RTE_CTE:
2920 case RTE_RESULT:
2921 /* nothing to do */
2922 break;
2923 case RTE_GROUP:
2924 if (!(flags & QTW_IGNORE_GROUPEXPRS))
2925 if (WALK(rte->groupexprs))
2926 return true;
2927 break;
2928 }
2929
2930 if (WALK(rte->securityQuals))
2931 return true;
2932
2933 if (flags & QTW_EXAMINE_RTES_AFTER)
2934 if (WALK(rte))
2935 return true;
2936
2937 return false;
2938}
#define QTW_IGNORE_RT_SUBQUERIES
Definition nodeFuncs.h:22
#define QTW_EXAMINE_RTES_AFTER
Definition nodeFuncs.h:28
#define QTW_IGNORE_GROUPEXPRS
Definition nodeFuncs.h:32
#define QTW_EXAMINE_RTES_BEFORE
Definition nodeFuncs.h:27
#define QTW_IGNORE_JOINALIASES
Definition nodeFuncs.h:25
@ RTE_JOIN
@ RTE_CTE
@ RTE_NAMEDTUPLESTORE
@ RTE_VALUES
@ RTE_SUBQUERY
@ RTE_RESULT
@ RTE_FUNCTION
@ RTE_TABLEFUNC
@ RTE_GROUP
@ RTE_GRAPH_TABLE
@ RTE_RELATION

References fb(), QTW_EXAMINE_RTES_AFTER, QTW_EXAMINE_RTES_BEFORE, QTW_IGNORE_GROUPEXPRS, QTW_IGNORE_JOINALIASES, QTW_IGNORE_RT_SUBQUERIES, RTE_CTE, RTE_FUNCTION, RTE_GRAPH_TABLE, RTE_GROUP, RTE_JOIN, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_RESULT, RTE_SUBQUERY, RTE_TABLEFUNC, RTE_VALUES, and WALK.

◆ range_table_mutator_impl()

List * range_table_mutator_impl ( List rtable,
tree_mutator_callback  mutator,
void context,
int  flags 
)
extern

Definition at line 3939 of file nodeFuncs.c.

3943{
3944 List *newrt = NIL;
3945 ListCell *rt;
3946
3947 foreach(rt, rtable)
3948 {
3951
3953 switch (rte->rtekind)
3954 {
3955 case RTE_RELATION:
3956 MUTATE(newrte->tablesample, rte->tablesample,
3958 /* we don't bother to copy eref, aliases, etc; OK? */
3959 break;
3960 case RTE_SUBQUERY:
3961 if (!(flags & QTW_IGNORE_RT_SUBQUERIES))
3962 MUTATE(newrte->subquery, rte->subquery, Query *);
3963 else
3964 {
3965 /* else, copy RT subqueries as-is */
3966 newrte->subquery = copyObject(rte->subquery);
3967 }
3968 break;
3969 case RTE_JOIN:
3970 if (!(flags & QTW_IGNORE_JOINALIASES))
3971 MUTATE(newrte->joinaliasvars, rte->joinaliasvars, List *);
3972 else
3973 {
3974 /* else, copy join aliases as-is */
3975 newrte->joinaliasvars = copyObject(rte->joinaliasvars);
3976 }
3977 break;
3978 case RTE_FUNCTION:
3979 MUTATE(newrte->functions, rte->functions, List *);
3980 break;
3981 case RTE_TABLEFUNC:
3982 MUTATE(newrte->tablefunc, rte->tablefunc, TableFunc *);
3983 break;
3984 case RTE_VALUES:
3985 MUTATE(newrte->values_lists, rte->values_lists, List *);
3986 break;
3987 case RTE_GRAPH_TABLE:
3988 MUTATE(newrte->graph_pattern, rte->graph_pattern, GraphPattern *);
3989 MUTATE(newrte->graph_table_columns, rte->graph_table_columns, List *);
3990 break;
3991 case RTE_CTE:
3993 case RTE_RESULT:
3994 /* nothing to do */
3995 break;
3996 case RTE_GROUP:
3997 if (!(flags & QTW_IGNORE_GROUPEXPRS))
3998 MUTATE(newrte->groupexprs, rte->groupexprs, List *);
3999 else
4000 {
4001 /* else, copy grouping exprs as-is */
4002 newrte->groupexprs = copyObject(rte->groupexprs);
4003 }
4004 break;
4005 }
4006 MUTATE(newrte->securityQuals, rte->securityQuals, List *);
4008 }
4009 return newrt;
4010}

References copyObject, fb(), FLATCOPY, lappend(), lfirst, MUTATE, NIL, QTW_IGNORE_GROUPEXPRS, QTW_IGNORE_JOINALIASES, QTW_IGNORE_RT_SUBQUERIES, RTE_CTE, RTE_FUNCTION, RTE_GRAPH_TABLE, RTE_GROUP, RTE_JOIN, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_RESULT, RTE_SUBQUERY, RTE_TABLEFUNC, and RTE_VALUES.

◆ range_table_walker_impl()

bool range_table_walker_impl ( List rtable,
tree_walker_callback  walker,
void context,
int  flags 
)
extern

Definition at line 2849 of file nodeFuncs.c.

2853{
2854 ListCell *rt;
2855
2856 foreach(rt, rtable)
2857 {
2859
2860 if (range_table_entry_walker(rte, walker, context, flags))
2861 return true;
2862 }
2863 return false;
2864}
#define range_table_entry_walker(r, w, c, f)
Definition nodeFuncs.h:168

References fb(), lfirst_node, and range_table_entry_walker.

◆ raw_expression_tree_walker_impl()

bool raw_expression_tree_walker_impl ( Node node,
tree_walker_callback  walker,
void context 
)
extern

Definition at line 4075 of file nodeFuncs.c.

4078{
4079 ListCell *temp;
4080
4081 /*
4082 * The walker has already visited the current node, and so we need only
4083 * recurse into any sub-nodes it has.
4084 */
4085 if (node == NULL)
4086 return false;
4087
4088 /* Guard against stack overflow due to overly complex expressions */
4090
4091 switch (nodeTag(node))
4092 {
4093 case T_JsonFormat:
4094 case T_SetToDefault:
4095 case T_CurrentOfExpr:
4096 case T_SQLValueFunction:
4097 case T_Integer:
4098 case T_Float:
4099 case T_Boolean:
4100 case T_String:
4101 case T_BitString:
4102 case T_ParamRef:
4103 case T_A_Const:
4104 case T_A_Star:
4105 case T_MergeSupportFunc:
4106 case T_ReturningOption:
4107 /* primitive node types with no subnodes */
4108 break;
4109 case T_Alias:
4110 /* we assume the colnames list isn't interesting */
4111 break;
4112 case T_RangeVar:
4113 return WALK(((RangeVar *) node)->alias);
4114 case T_GroupingFunc:
4115 return WALK(((GroupingFunc *) node)->args);
4116 case T_SubLink:
4117 {
4118 SubLink *sublink = (SubLink *) node;
4119
4120 if (WALK(sublink->testexpr))
4121 return true;
4122 /* we assume the operName is not interesting */
4123 if (WALK(sublink->subselect))
4124 return true;
4125 }
4126 break;
4127 case T_CaseExpr:
4128 {
4129 CaseExpr *caseexpr = (CaseExpr *) node;
4130
4131 if (WALK(caseexpr->arg))
4132 return true;
4133 /* we assume walker doesn't care about CaseWhens, either */
4134 foreach(temp, caseexpr->args)
4135 {
4137
4138 if (WALK(when->expr))
4139 return true;
4140 if (WALK(when->result))
4141 return true;
4142 }
4143 if (WALK(caseexpr->defresult))
4144 return true;
4145 }
4146 break;
4147 case T_RowExpr:
4148 /* Assume colnames isn't interesting */
4149 return WALK(((RowExpr *) node)->args);
4150 case T_CoalesceExpr:
4151 return WALK(((CoalesceExpr *) node)->args);
4152 case T_MinMaxExpr:
4153 return WALK(((MinMaxExpr *) node)->args);
4154 case T_XmlExpr:
4155 {
4156 XmlExpr *xexpr = (XmlExpr *) node;
4157
4158 if (WALK(xexpr->named_args))
4159 return true;
4160 /* we assume walker doesn't care about arg_names */
4161 if (WALK(xexpr->args))
4162 return true;
4163 }
4164 break;
4165 case T_JsonReturning:
4166 return WALK(((JsonReturning *) node)->format);
4167 case T_JsonValueExpr:
4168 {
4169 JsonValueExpr *jve = (JsonValueExpr *) node;
4170
4171 if (WALK(jve->raw_expr))
4172 return true;
4173 if (WALK(jve->formatted_expr))
4174 return true;
4175 if (WALK(jve->format))
4176 return true;
4177 }
4178 break;
4179 case T_JsonParseExpr:
4180 {
4181 JsonParseExpr *jpe = (JsonParseExpr *) node;
4182
4183 if (WALK(jpe->expr))
4184 return true;
4185 if (WALK(jpe->output))
4186 return true;
4187 }
4188 break;
4189 case T_JsonScalarExpr:
4190 {
4191 JsonScalarExpr *jse = (JsonScalarExpr *) node;
4192
4193 if (WALK(jse->expr))
4194 return true;
4195 if (WALK(jse->output))
4196 return true;
4197 }
4198 break;
4200 {
4202
4203 if (WALK(jse->expr))
4204 return true;
4205 if (WALK(jse->output))
4206 return true;
4207 }
4208 break;
4210 {
4212
4213 if (WALK(ctor->args))
4214 return true;
4215 if (WALK(ctor->func))
4216 return true;
4217 if (WALK(ctor->coercion))
4218 return true;
4219 if (WALK(ctor->returning))
4220 return true;
4221 }
4222 break;
4223 case T_JsonIsPredicate:
4224 return WALK(((JsonIsPredicate *) node)->expr);
4225 case T_JsonArgument:
4226 return WALK(((JsonArgument *) node)->val);
4227 case T_JsonFuncExpr:
4228 {
4229 JsonFuncExpr *jfe = (JsonFuncExpr *) node;
4230
4231 if (WALK(jfe->context_item))
4232 return true;
4233 if (WALK(jfe->pathspec))
4234 return true;
4235 if (WALK(jfe->passing))
4236 return true;
4237 if (WALK(jfe->output))
4238 return true;
4239 if (WALK(jfe->on_empty))
4240 return true;
4241 if (WALK(jfe->on_error))
4242 return true;
4243 }
4244 break;
4245 case T_JsonBehavior:
4246 {
4247 JsonBehavior *jb = (JsonBehavior *) node;
4248
4249 if (WALK(jb->expr))
4250 return true;
4251 }
4252 break;
4253 case T_JsonTable:
4254 {
4255 JsonTable *jt = (JsonTable *) node;
4256
4257 if (WALK(jt->context_item))
4258 return true;
4259 if (WALK(jt->pathspec))
4260 return true;
4261 if (WALK(jt->passing))
4262 return true;
4263 if (WALK(jt->columns))
4264 return true;
4265 if (WALK(jt->on_error))
4266 return true;
4267 }
4268 break;
4269 case T_JsonTableColumn:
4270 {
4272
4273 if (WALK(jtc->typeName))
4274 return true;
4275 if (WALK(jtc->on_empty))
4276 return true;
4277 if (WALK(jtc->on_error))
4278 return true;
4279 if (WALK(jtc->columns))
4280 return true;
4281 }
4282 break;
4284 return WALK(((JsonTablePathSpec *) node)->string);
4285 case T_NullTest:
4286 return WALK(((NullTest *) node)->arg);
4287 case T_BooleanTest:
4288 return WALK(((BooleanTest *) node)->arg);
4289 case T_JoinExpr:
4290 {
4291 JoinExpr *join = (JoinExpr *) node;
4292
4293 if (WALK(join->larg))
4294 return true;
4295 if (WALK(join->rarg))
4296 return true;
4297 if (WALK(join->quals))
4298 return true;
4299 if (WALK(join->alias))
4300 return true;
4301 /* using list is deemed uninteresting */
4302 }
4303 break;
4304 case T_IntoClause:
4305 {
4306 IntoClause *into = (IntoClause *) node;
4307
4308 if (WALK(into->rel))
4309 return true;
4310 /* colNames, options are deemed uninteresting */
4311 /* viewQuery should be null in raw parsetree, but check it */
4312 if (WALK(into->viewQuery))
4313 return true;
4314 }
4315 break;
4316 case T_List:
4317 foreach(temp, (List *) node)
4318 {
4319 if (WALK((Node *) lfirst(temp)))
4320 return true;
4321 }
4322 break;
4323 case T_InsertStmt:
4324 {
4325 InsertStmt *stmt = (InsertStmt *) node;
4326
4327 if (WALK(stmt->relation))
4328 return true;
4329 if (WALK(stmt->cols))
4330 return true;
4331 if (WALK(stmt->selectStmt))
4332 return true;
4333 if (WALK(stmt->onConflictClause))
4334 return true;
4335 if (WALK(stmt->returningClause))
4336 return true;
4337 if (WALK(stmt->withClause))
4338 return true;
4339 }
4340 break;
4341 case T_DeleteStmt:
4342 {
4343 DeleteStmt *stmt = (DeleteStmt *) node;
4344
4345 if (WALK(stmt->relation))
4346 return true;
4347 if (WALK(stmt->usingClause))
4348 return true;
4349 if (WALK(stmt->whereClause))
4350 return true;
4351 if (WALK(stmt->returningClause))
4352 return true;
4353 if (WALK(stmt->withClause))
4354 return true;
4355 }
4356 break;
4357 case T_UpdateStmt:
4358 {
4359 UpdateStmt *stmt = (UpdateStmt *) node;
4360
4361 if (WALK(stmt->relation))
4362 return true;
4363 if (WALK(stmt->targetList))
4364 return true;
4365 if (WALK(stmt->whereClause))
4366 return true;
4367 if (WALK(stmt->fromClause))
4368 return true;
4369 if (WALK(stmt->returningClause))
4370 return true;
4371 if (WALK(stmt->withClause))
4372 return true;
4373 }
4374 break;
4375 case T_MergeStmt:
4376 {
4377 MergeStmt *stmt = (MergeStmt *) node;
4378
4379 if (WALK(stmt->relation))
4380 return true;
4381 if (WALK(stmt->sourceRelation))
4382 return true;
4383 if (WALK(stmt->joinCondition))
4384 return true;
4385 if (WALK(stmt->mergeWhenClauses))
4386 return true;
4387 if (WALK(stmt->returningClause))
4388 return true;
4389 if (WALK(stmt->withClause))
4390 return true;
4391 }
4392 break;
4393 case T_MergeWhenClause:
4394 {
4396
4397 if (WALK(mergeWhenClause->condition))
4398 return true;
4399 if (WALK(mergeWhenClause->targetList))
4400 return true;
4401 if (WALK(mergeWhenClause->values))
4402 return true;
4403 }
4404 break;
4405 case T_ReturningClause:
4406 {
4407 ReturningClause *returning = (ReturningClause *) node;
4408
4409 if (WALK(returning->options))
4410 return true;
4411 if (WALK(returning->exprs))
4412 return true;
4413 }
4414 break;
4415 case T_SelectStmt:
4416 {
4417 SelectStmt *stmt = (SelectStmt *) node;
4418
4419 if (WALK(stmt->distinctClause))
4420 return true;
4421 if (WALK(stmt->intoClause))
4422 return true;
4423 if (WALK(stmt->targetList))
4424 return true;
4425 if (WALK(stmt->fromClause))
4426 return true;
4427 if (WALK(stmt->whereClause))
4428 return true;
4429 if (WALK(stmt->groupClause))
4430 return true;
4431 if (WALK(stmt->havingClause))
4432 return true;
4433 if (WALK(stmt->windowClause))
4434 return true;
4435 if (WALK(stmt->valuesLists))
4436 return true;
4437 if (WALK(stmt->sortClause))
4438 return true;
4439 if (WALK(stmt->limitOffset))
4440 return true;
4441 if (WALK(stmt->limitCount))
4442 return true;
4443 if (WALK(stmt->lockingClause))
4444 return true;
4445 if (WALK(stmt->withClause))
4446 return true;
4447 if (WALK(stmt->larg))
4448 return true;
4449 if (WALK(stmt->rarg))
4450 return true;
4451 }
4452 break;
4453 case T_PLAssignStmt:
4454 {
4455 PLAssignStmt *stmt = (PLAssignStmt *) node;
4456
4457 if (WALK(stmt->indirection))
4458 return true;
4459 if (WALK(stmt->val))
4460 return true;
4461 }
4462 break;
4463 case T_A_Expr:
4464 {
4465 A_Expr *expr = (A_Expr *) node;
4466
4467 if (WALK(expr->lexpr))
4468 return true;
4469 if (WALK(expr->rexpr))
4470 return true;
4471 /* operator name is deemed uninteresting */
4472 }
4473 break;
4474 case T_BoolExpr:
4475 {
4476 BoolExpr *expr = (BoolExpr *) node;
4477
4478 if (WALK(expr->args))
4479 return true;
4480 }
4481 break;
4482 case T_ColumnRef:
4483 /* we assume the fields contain nothing interesting */
4484 break;
4485 case T_FuncCall:
4486 {
4487 FuncCall *fcall = (FuncCall *) node;
4488
4489 if (WALK(fcall->args))
4490 return true;
4491 if (WALK(fcall->agg_order))
4492 return true;
4493 if (WALK(fcall->agg_filter))
4494 return true;
4495 if (WALK(fcall->over))
4496 return true;
4497 /* function name is deemed uninteresting */
4498 }
4499 break;
4500 case T_NamedArgExpr:
4501 return WALK(((NamedArgExpr *) node)->arg);
4502 case T_A_Indices:
4503 {
4504 A_Indices *indices = (A_Indices *) node;
4505
4506 if (WALK(indices->lidx))
4507 return true;
4508 if (WALK(indices->uidx))
4509 return true;
4510 }
4511 break;
4512 case T_A_Indirection:
4513 {
4514 A_Indirection *indir = (A_Indirection *) node;
4515
4516 if (WALK(indir->arg))
4517 return true;
4518 if (WALK(indir->indirection))
4519 return true;
4520 }
4521 break;
4522 case T_A_ArrayExpr:
4523 return WALK(((A_ArrayExpr *) node)->elements);
4524 case T_ResTarget:
4525 {
4526 ResTarget *rt = (ResTarget *) node;
4527
4528 if (WALK(rt->indirection))
4529 return true;
4530 if (WALK(rt->val))
4531 return true;
4532 }
4533 break;
4534 case T_MultiAssignRef:
4535 return WALK(((MultiAssignRef *) node)->source);
4536 case T_TypeCast:
4537 {
4538 TypeCast *tc = (TypeCast *) node;
4539
4540 if (WALK(tc->arg))
4541 return true;
4542 if (WALK(tc->typeName))
4543 return true;
4544 }
4545 break;
4546 case T_CollateClause:
4547 return WALK(((CollateClause *) node)->arg);
4548 case T_SortBy:
4549 return WALK(((SortBy *) node)->node);
4550 case T_WindowDef:
4551 {
4552 WindowDef *wd = (WindowDef *) node;
4553
4554 if (WALK(wd->partitionClause))
4555 return true;
4556 if (WALK(wd->orderClause))
4557 return true;
4558 if (WALK(wd->startOffset))
4559 return true;
4560 if (WALK(wd->endOffset))
4561 return true;
4562 }
4563 break;
4564 case T_RangeSubselect:
4565 {
4566 RangeSubselect *rs = (RangeSubselect *) node;
4567
4568 if (WALK(rs->subquery))
4569 return true;
4570 if (WALK(rs->alias))
4571 return true;
4572 }
4573 break;
4574 case T_RangeFunction:
4575 {
4576 RangeFunction *rf = (RangeFunction *) node;
4577
4578 if (WALK(rf->functions))
4579 return true;
4580 if (WALK(rf->alias))
4581 return true;
4582 if (WALK(rf->coldeflist))
4583 return true;
4584 }
4585 break;
4586 case T_RangeTableSample:
4587 {
4589
4590 if (WALK(rts->relation))
4591 return true;
4592 /* method name is deemed uninteresting */
4593 if (WALK(rts->args))
4594 return true;
4595 if (WALK(rts->repeatable))
4596 return true;
4597 }
4598 break;
4599 case T_RangeTableFunc:
4600 {
4601 RangeTableFunc *rtf = (RangeTableFunc *) node;
4602
4603 if (WALK(rtf->docexpr))
4604 return true;
4605 if (WALK(rtf->rowexpr))
4606 return true;
4607 if (WALK(rtf->namespaces))
4608 return true;
4609 if (WALK(rtf->columns))
4610 return true;
4611 if (WALK(rtf->alias))
4612 return true;
4613 }
4614 break;
4616 {
4618
4619 if (WALK(rtfc->colexpr))
4620 return true;
4621 if (WALK(rtfc->coldefexpr))
4622 return true;
4623 }
4624 break;
4625 case T_RangeGraphTable:
4626 {
4628
4629 if (WALK(rgt->graph_pattern))
4630 return true;
4631 if (WALK(rgt->columns))
4632 return true;
4633 if (WALK(rgt->alias))
4634 return true;
4635 }
4636 break;
4637 case T_TypeName:
4638 {
4639 TypeName *tn = (TypeName *) node;
4640
4641 if (WALK(tn->typmods))
4642 return true;
4643 if (WALK(tn->arrayBounds))
4644 return true;
4645 /* type name itself is deemed uninteresting */
4646 }
4647 break;
4648 case T_ColumnDef:
4649 {
4650 ColumnDef *coldef = (ColumnDef *) node;
4651
4652 if (WALK(coldef->typeName))
4653 return true;
4654 if (WALK(coldef->raw_default))
4655 return true;
4656 if (WALK(coldef->collClause))
4657 return true;
4658 /* for now, constraints are ignored */
4659 }
4660 break;
4661 case T_IndexElem:
4662 {
4663 IndexElem *indelem = (IndexElem *) node;
4664
4665 if (WALK(indelem->expr))
4666 return true;
4667 /* collation and opclass names are deemed uninteresting */
4668 }
4669 break;
4670 case T_GroupingSet:
4671 return WALK(((GroupingSet *) node)->content);
4672 case T_LockingClause:
4673 return WALK(((LockingClause *) node)->lockedRels);
4674 case T_XmlSerialize:
4675 {
4676 XmlSerialize *xs = (XmlSerialize *) node;
4677
4678 if (WALK(xs->expr))
4679 return true;
4680 if (WALK(xs->typeName))
4681 return true;
4682 }
4683 break;
4684 case T_WithClause:
4685 return WALK(((WithClause *) node)->ctes);
4686 case T_InferClause:
4687 {
4688 InferClause *stmt = (InferClause *) node;
4689
4690 if (WALK(stmt->indexElems))
4691 return true;
4692 if (WALK(stmt->whereClause))
4693 return true;
4694 }
4695 break;
4696 case T_OnConflictClause:
4697 {
4699
4700 if (WALK(stmt->infer))
4701 return true;
4702 if (WALK(stmt->targetList))
4703 return true;
4704 if (WALK(stmt->whereClause))
4705 return true;
4706 }
4707 break;
4708 case T_CommonTableExpr:
4709 /* search_clause and cycle_clause are not interesting here */
4710 return WALK(((CommonTableExpr *) node)->ctequery);
4711 case T_JsonOutput:
4712 {
4713 JsonOutput *out = (JsonOutput *) node;
4714
4715 if (WALK(out->typeName))
4716 return true;
4717 if (WALK(out->returning))
4718 return true;
4719 }
4720 break;
4721 case T_JsonKeyValue:
4722 {
4723 JsonKeyValue *jkv = (JsonKeyValue *) node;
4724
4725 if (WALK(jkv->key))
4726 return true;
4727 if (WALK(jkv->value))
4728 return true;
4729 }
4730 break;
4732 {
4734
4735 if (WALK(joc->output))
4736 return true;
4737 if (WALK(joc->exprs))
4738 return true;
4739 }
4740 break;
4742 {
4744
4745 if (WALK(jac->output))
4746 return true;
4747 if (WALK(jac->exprs))
4748 return true;
4749 }
4750 break;
4752 {
4754
4755 if (WALK(ctor->output))
4756 return true;
4757 if (WALK(ctor->agg_order))
4758 return true;
4759 if (WALK(ctor->agg_filter))
4760 return true;
4761 if (WALK(ctor->over))
4762 return true;
4763 }
4764 break;
4765 case T_JsonObjectAgg:
4766 {
4767 JsonObjectAgg *joa = (JsonObjectAgg *) node;
4768
4769 if (WALK(joa->constructor))
4770 return true;
4771 if (WALK(joa->arg))
4772 return true;
4773 }
4774 break;
4775 case T_JsonArrayAgg:
4776 {
4777 JsonArrayAgg *jaa = (JsonArrayAgg *) node;
4778
4779 if (WALK(jaa->constructor))
4780 return true;
4781 if (WALK(jaa->arg))
4782 return true;
4783 }
4784 break;
4786 {
4788
4789 if (WALK(jaqc->output))
4790 return true;
4791 if (WALK(jaqc->query))
4792 return true;
4793 }
4794 break;
4796 {
4798
4799 if (WALK(gep->subexpr))
4800 return true;
4801 if (WALK(gep->whereClause))
4802 return true;
4803 }
4804 break;
4805 case T_GraphPattern:
4806 {
4807 GraphPattern *gp = (GraphPattern *) node;
4808
4809 if (WALK(gp->path_pattern_list))
4810 return true;
4811 if (WALK(gp->whereClause))
4812 return true;
4813 }
4814 break;
4815 default:
4816 elog(ERROR, "unrecognized node type: %d",
4817 (int) nodeTag(node));
4818 break;
4819 }
4820 return false;
4821}
#define stmt
long val
Definition informix.c:689
static char format
Node * lexpr
Definition parsenodes.h:356
Node * rexpr
Definition parsenodes.h:357
Node * uidx
Definition parsenodes.h:490
Node * lidx
Definition parsenodes.h:489
Node * agg_filter
Definition parsenodes.h:457
List * agg_order
Definition parsenodes.h:456
List * args
Definition parsenodes.h:455
struct WindowDef * over
Definition parsenodes.h:458
RangeVar * rel
Definition primnodes.h:164
JsonReturning * returning
TypeName * typeName
JsonBehavior * on_error
List * columns
JsonTablePathSpec * pathspec
List * passing
JsonValueExpr * context_item

References FuncCall::agg_filter, FuncCall::agg_order, RangeSubselect::alias, arg, FuncCall::args, BoolExpr::args, XmlExpr::args, check_stack_depth(), JsonTable::columns, JsonTable::context_item, elog, ERROR, ReturningClause::exprs, fb(), format, JoinExpr::larg, A_Expr::lexpr, lfirst, lfirst_node, A_Indices::lidx, XmlExpr::named_args, nodeTag, JsonTable::on_error, ReturningClause::options, FuncCall::over, JsonTable::passing, JsonTable::pathspec, JoinExpr::quals, JoinExpr::rarg, IntoClause::rel, JsonOutput::returning, A_Expr::rexpr, source, stmt, RangeSubselect::subquery, JsonOutput::typeName, A_Indices::uidx, val, and WALK.

◆ relabel_to_typmod()

Node * relabel_to_typmod ( Node expr,
int32  typmod 
)
extern

Definition at line 694 of file nodeFuncs.c.

695{
696 return applyRelabelType(expr, exprType(expr), typmod, exprCollation(expr),
697 COERCE_EXPLICIT_CAST, -1, false);
698}
Node * applyRelabelType(Node *arg, Oid rtype, int32 rtypmod, Oid rcollid, CoercionForm rformat, int rlocation, bool overwrite_ok)
Definition nodeFuncs.c:641

References applyRelabelType(), COERCE_EXPLICIT_CAST, exprCollation(), and exprType().

Referenced by interval_support(), numeric_support(), TemporalSimplify(), varbit_support(), and varchar_support().

◆ set_opfuncid()

◆ set_sa_opfuncid()

void set_sa_opfuncid ( ScalarArrayOpExpr opexpr)
extern

Definition at line 1890 of file nodeFuncs.c.

1891{
1892 if (opexpr->opfuncid == InvalidOid)
1893 opexpr->opfuncid = get_opcode(opexpr->opno);
1894}

References get_opcode(), InvalidOid, and ScalarArrayOpExpr::opno.

Referenced by check_functions_in_node(), cost_qual_eval_walker(), eval_const_expressions_mutator(), fix_expr_common(), fix_opfuncids_walker(), and is_strict_saop().

◆ strip_implicit_coercions()

Node * strip_implicit_coercions ( Node node)
extern

Definition at line 710 of file nodeFuncs.c.

711{
712 if (node == NULL)
713 return NULL;
714 if (IsA(node, FuncExpr))
715 {
716 FuncExpr *f = (FuncExpr *) node;
717
718 if (f->funcformat == COERCE_IMPLICIT_CAST)
720 }
721 else if (IsA(node, RelabelType))
722 {
723 RelabelType *r = (RelabelType *) node;
724
725 if (r->relabelformat == COERCE_IMPLICIT_CAST)
726 return strip_implicit_coercions((Node *) r->arg);
727 }
728 else if (IsA(node, CoerceViaIO))
729 {
730 CoerceViaIO *c = (CoerceViaIO *) node;
731
732 if (c->coerceformat == COERCE_IMPLICIT_CAST)
733 return strip_implicit_coercions((Node *) c->arg);
734 }
735 else if (IsA(node, ArrayCoerceExpr))
736 {
738
739 if (c->coerceformat == COERCE_IMPLICIT_CAST)
740 return strip_implicit_coercions((Node *) c->arg);
741 }
742 else if (IsA(node, ConvertRowtypeExpr))
743 {
745
746 if (c->convertformat == COERCE_IMPLICIT_CAST)
747 return strip_implicit_coercions((Node *) c->arg);
748 }
749 else if (IsA(node, CoerceToDomain))
750 {
751 CoerceToDomain *c = (CoerceToDomain *) node;
752
753 if (c->coercionformat == COERCE_IMPLICIT_CAST)
754 return strip_implicit_coercions((Node *) c->arg);
755 }
756 return node;
757}
Node * strip_implicit_coercions(Node *node)
Definition nodeFuncs.c:710
char * c

References RelabelType::arg, FuncExpr::args, COERCE_IMPLICIT_CAST, fb(), IsA, linitial, and strip_implicit_coercions().

Referenced by AcquireRewriteLocks(), ATExecAlterColumnType(), findTargetlistEntrySQL99(), foreign_expr_walker(), get_rule_expr(), get_update_query_targetlist_def(), and strip_implicit_coercions().