PostgreSQL Source Code git master
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

typedef struct PlanState 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 
)

Definition at line 636 of file nodeFuncs.c.

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

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

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 
)

Definition at line 1909 of file nodeFuncs.c.

1911{
1912 switch (nodeTag(node))
1913 {
1914 case T_Aggref:
1915 {
1916 Aggref *expr = (Aggref *) node;
1917
1918 if (checker(expr->aggfnoid, context))
1919 return true;
1920 }
1921 break;
1922 case T_WindowFunc:
1923 {
1924 WindowFunc *expr = (WindowFunc *) node;
1925
1926 if (checker(expr->winfnoid, context))
1927 return true;
1928 }
1929 break;
1930 case T_FuncExpr:
1931 {
1932 FuncExpr *expr = (FuncExpr *) node;
1933
1934 if (checker(expr->funcid, context))
1935 return true;
1936 }
1937 break;
1938 case T_OpExpr:
1939 case T_DistinctExpr: /* struct-equivalent to OpExpr */
1940 case T_NullIfExpr: /* struct-equivalent to OpExpr */
1941 {
1942 OpExpr *expr = (OpExpr *) node;
1943
1944 /* Set opfuncid if it wasn't set already */
1945 set_opfuncid(expr);
1946 if (checker(expr->opfuncid, context))
1947 return true;
1948 }
1949 break;
1950 case T_ScalarArrayOpExpr:
1951 {
1952 ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node;
1953
1954 set_sa_opfuncid(expr);
1955 if (checker(expr->opfuncid, context))
1956 return true;
1957 }
1958 break;
1959 case T_CoerceViaIO:
1960 {
1961 CoerceViaIO *expr = (CoerceViaIO *) node;
1962 Oid iofunc;
1963 Oid typioparam;
1964 bool typisvarlena;
1965
1966 /* check the result type's input function */
1968 &iofunc, &typioparam);
1969 if (checker(iofunc, context))
1970 return true;
1971 /* check the input type's output function */
1973 &iofunc, &typisvarlena);
1974 if (checker(iofunc, context))
1975 return true;
1976 }
1977 break;
1978 case T_RowCompareExpr:
1979 {
1980 RowCompareExpr *rcexpr = (RowCompareExpr *) node;
1981 ListCell *opid;
1982
1983 foreach(opid, rcexpr->opnos)
1984 {
1985 Oid opfuncid = get_opcode(lfirst_oid(opid));
1986
1987 if (checker(opfuncid, context))
1988 return true;
1989 }
1990 }
1991 break;
1992 default:
1993 break;
1994 }
1995 return false;
1996}
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
Definition: lsyscache.c:3057
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1435
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
Definition: lsyscache.c:3024
void set_sa_opfuncid(ScalarArrayOpExpr *opexpr)
Definition: nodeFuncs.c:1882
void set_opfuncid(OpExpr *opexpr)
Definition: nodeFuncs.c:1871
#define nodeTag(nodeptr)
Definition: nodes.h:139
#define lfirst_oid(lc)
Definition: pg_list.h:174
unsigned int Oid
Definition: postgres_ext.h:32
Oid aggfnoid
Definition: primnodes.h:463
Expr * arg
Definition: primnodes.h:1240
Oid resulttype
Definition: primnodes.h:1241
Oid funcid
Definition: primnodes.h:782
Oid winfnoid
Definition: primnodes.h:597

References Aggref::aggfnoid, CoerceViaIO::arg, exprType(), 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)

Definition at line 821 of file nodeFuncs.c.

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

References arg, ARRAY_SUBLINK, Assert(), JsonConstructorExpr::coercion, JsonExpr::collation, elog, ERROR, JsonBehavior::expr, EXPR_SUBLINK, exprCollation(), SubPlan::firstColCollation, if(), InvalidOid, IS_XMLSERIALIZE, IsA, linitial, linitial_node, nodeTag, SubLink::subLinkType, SubPlan::subLinkType, AlternativeSubPlan::subplans, SubLink::subselect, Query::targetList, and type.

Referenced by addRangeTableEntryForFunction(), 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_limit_plan(), create_memoize_plan(), create_windowagg_plan(), DefineVirtualRelation(), eval_const_expressions_mutator(), examine_attribute(), examine_expression(), ExecInitFunctionScan(), ExecInitIndexScan(), ExecTypeFromExprList(), ExecTypeFromTLInternal(), expandRecordVariable(), expandRTE(), exprCollation(), exprSetCollation(), extract_grouping_collations(), fix_indexqual_operand(), 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(), inline_function(), 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 
)

Definition at line 2949 of file nodeFuncs.c.

2952{
2953 /*
2954 * The mutator has already decided not to modify the current node, but we
2955 * must call the mutator for any sub-nodes.
2956 */
2957
2958#define FLATCOPY(newnode, node, nodetype) \
2959 ( (newnode) = palloc_object(nodetype), \
2960 memcpy((newnode), (node), sizeof(nodetype)) )
2961
2962#define MUTATE(newfield, oldfield, fieldtype) \
2963 ( (newfield) = (fieldtype) mutator((Node *) (oldfield), context) )
2964
2965 if (node == NULL)
2966 return NULL;
2967
2968 /* Guard against stack overflow due to overly complex expressions */
2970
2971 switch (nodeTag(node))
2972 {
2973 /*
2974 * Primitive node types with no expression subnodes. Var and
2975 * Const are frequent enough to deserve special cases, the others
2976 * we just use copyObject for.
2977 */
2978 case T_Var:
2979 {
2980 Var *var = (Var *) node;
2981 Var *newnode;
2982
2983 FLATCOPY(newnode, var, Var);
2984 /* Assume we need not copy the varnullingrels bitmapset */
2985 return (Node *) newnode;
2986 }
2987 break;
2988 case T_Const:
2989 {
2990 Const *oldnode = (Const *) node;
2991 Const *newnode;
2992
2993 FLATCOPY(newnode, oldnode, Const);
2994 /* XXX we don't bother with datumCopy; should we? */
2995 return (Node *) newnode;
2996 }
2997 break;
2998 case T_Param:
2999 case T_CaseTestExpr:
3000 case T_SQLValueFunction:
3001 case T_JsonFormat:
3002 case T_CoerceToDomainValue:
3003 case T_SetToDefault:
3004 case T_CurrentOfExpr:
3005 case T_NextValueExpr:
3006 case T_RangeTblRef:
3007 case T_SortGroupClause:
3008 case T_CTESearchClause:
3009 case T_MergeSupportFunc:
3010 return copyObject(node);
3011 case T_WithCheckOption:
3012 {
3013 WithCheckOption *wco = (WithCheckOption *) node;
3014 WithCheckOption *newnode;
3015
3016 FLATCOPY(newnode, wco, WithCheckOption);
3017 MUTATE(newnode->qual, wco->qual, Node *);
3018 return (Node *) newnode;
3019 }
3020 case T_Aggref:
3021 {
3022 Aggref *aggref = (Aggref *) node;
3023 Aggref *newnode;
3024
3025 FLATCOPY(newnode, aggref, Aggref);
3026 /* assume mutation doesn't change types of arguments */
3027 newnode->aggargtypes = list_copy(aggref->aggargtypes);
3028 MUTATE(newnode->aggdirectargs, aggref->aggdirectargs, List *);
3029 MUTATE(newnode->args, aggref->args, List *);
3030 MUTATE(newnode->aggorder, aggref->aggorder, List *);
3031 MUTATE(newnode->aggdistinct, aggref->aggdistinct, List *);
3032 MUTATE(newnode->aggfilter, aggref->aggfilter, Expr *);
3033 return (Node *) newnode;
3034 }
3035 break;
3036 case T_GroupingFunc:
3037 {
3038 GroupingFunc *grouping = (GroupingFunc *) node;
3039 GroupingFunc *newnode;
3040
3041 FLATCOPY(newnode, grouping, GroupingFunc);
3042 MUTATE(newnode->args, grouping->args, List *);
3043
3044 /*
3045 * We assume here that mutating the arguments does not change
3046 * the semantics, i.e. that the arguments are not mutated in a
3047 * way that makes them semantically different from their
3048 * previously matching expressions in the GROUP BY clause.
3049 *
3050 * If a mutator somehow wanted to do this, it would have to
3051 * handle the refs and cols lists itself as appropriate.
3052 */
3053 newnode->refs = list_copy(grouping->refs);
3054 newnode->cols = list_copy(grouping->cols);
3055
3056 return (Node *) newnode;
3057 }
3058 break;
3059 case T_WindowFunc:
3060 {
3061 WindowFunc *wfunc = (WindowFunc *) node;
3062 WindowFunc *newnode;
3063
3064 FLATCOPY(newnode, wfunc, WindowFunc);
3065 MUTATE(newnode->args, wfunc->args, List *);
3066 MUTATE(newnode->aggfilter, wfunc->aggfilter, Expr *);
3067 return (Node *) newnode;
3068 }
3069 break;
3070 case T_WindowFuncRunCondition:
3071 {
3073 WindowFuncRunCondition *newnode;
3074
3075 FLATCOPY(newnode, wfuncrc, WindowFuncRunCondition);
3076 MUTATE(newnode->arg, wfuncrc->arg, Expr *);
3077 return (Node *) newnode;
3078 }
3079 break;
3080 case T_SubscriptingRef:
3081 {
3082 SubscriptingRef *sbsref = (SubscriptingRef *) node;
3083 SubscriptingRef *newnode;
3084
3085 FLATCOPY(newnode, sbsref, SubscriptingRef);
3086 MUTATE(newnode->refupperindexpr, sbsref->refupperindexpr,
3087 List *);
3088 MUTATE(newnode->reflowerindexpr, sbsref->reflowerindexpr,
3089 List *);
3090 MUTATE(newnode->refexpr, sbsref->refexpr,
3091 Expr *);
3092 MUTATE(newnode->refassgnexpr, sbsref->refassgnexpr,
3093 Expr *);
3094
3095 return (Node *) newnode;
3096 }
3097 break;
3098 case T_FuncExpr:
3099 {
3100 FuncExpr *expr = (FuncExpr *) node;
3101 FuncExpr *newnode;
3102
3103 FLATCOPY(newnode, expr, FuncExpr);
3104 MUTATE(newnode->args, expr->args, List *);
3105 return (Node *) newnode;
3106 }
3107 break;
3108 case T_NamedArgExpr:
3109 {
3110 NamedArgExpr *nexpr = (NamedArgExpr *) node;
3111 NamedArgExpr *newnode;
3112
3113 FLATCOPY(newnode, nexpr, NamedArgExpr);
3114 MUTATE(newnode->arg, nexpr->arg, Expr *);
3115 return (Node *) newnode;
3116 }
3117 break;
3118 case T_OpExpr:
3119 {
3120 OpExpr *expr = (OpExpr *) node;
3121 OpExpr *newnode;
3122
3123 FLATCOPY(newnode, expr, OpExpr);
3124 MUTATE(newnode->args, expr->args, List *);
3125 return (Node *) newnode;
3126 }
3127 break;
3128 case T_DistinctExpr:
3129 {
3130 DistinctExpr *expr = (DistinctExpr *) node;
3131 DistinctExpr *newnode;
3132
3133 FLATCOPY(newnode, expr, DistinctExpr);
3134 MUTATE(newnode->args, expr->args, List *);
3135 return (Node *) newnode;
3136 }
3137 break;
3138 case T_NullIfExpr:
3139 {
3140 NullIfExpr *expr = (NullIfExpr *) node;
3141 NullIfExpr *newnode;
3142
3143 FLATCOPY(newnode, expr, NullIfExpr);
3144 MUTATE(newnode->args, expr->args, List *);
3145 return (Node *) newnode;
3146 }
3147 break;
3148 case T_ScalarArrayOpExpr:
3149 {
3150 ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node;
3151 ScalarArrayOpExpr *newnode;
3152
3153 FLATCOPY(newnode, expr, ScalarArrayOpExpr);
3154 MUTATE(newnode->args, expr->args, List *);
3155 return (Node *) newnode;
3156 }
3157 break;
3158 case T_BoolExpr:
3159 {
3160 BoolExpr *expr = (BoolExpr *) node;
3161 BoolExpr *newnode;
3162
3163 FLATCOPY(newnode, expr, BoolExpr);
3164 MUTATE(newnode->args, expr->args, List *);
3165 return (Node *) newnode;
3166 }
3167 break;
3168 case T_SubLink:
3169 {
3170 SubLink *sublink = (SubLink *) node;
3171 SubLink *newnode;
3172
3173 FLATCOPY(newnode, sublink, SubLink);
3174 MUTATE(newnode->testexpr, sublink->testexpr, Node *);
3175
3176 /*
3177 * Also invoke the mutator on the sublink's Query node, so it
3178 * can recurse into the sub-query if it wants to.
3179 */
3180 MUTATE(newnode->subselect, sublink->subselect, Node *);
3181 return (Node *) newnode;
3182 }
3183 break;
3184 case T_SubPlan:
3185 {
3186 SubPlan *subplan = (SubPlan *) node;
3187 SubPlan *newnode;
3188
3189 FLATCOPY(newnode, subplan, SubPlan);
3190 /* transform testexpr */
3191 MUTATE(newnode->testexpr, subplan->testexpr, Node *);
3192 /* transform args list (params to be passed to subplan) */
3193 MUTATE(newnode->args, subplan->args, List *);
3194 /* but not the sub-Plan itself, which is referenced as-is */
3195 return (Node *) newnode;
3196 }
3197 break;
3198 case T_AlternativeSubPlan:
3199 {
3200 AlternativeSubPlan *asplan = (AlternativeSubPlan *) node;
3201 AlternativeSubPlan *newnode;
3202
3203 FLATCOPY(newnode, asplan, AlternativeSubPlan);
3204 MUTATE(newnode->subplans, asplan->subplans, List *);
3205 return (Node *) newnode;
3206 }
3207 break;
3208 case T_FieldSelect:
3209 {
3210 FieldSelect *fselect = (FieldSelect *) node;
3211 FieldSelect *newnode;
3212
3213 FLATCOPY(newnode, fselect, FieldSelect);
3214 MUTATE(newnode->arg, fselect->arg, Expr *);
3215 return (Node *) newnode;
3216 }
3217 break;
3218 case T_FieldStore:
3219 {
3220 FieldStore *fstore = (FieldStore *) node;
3221 FieldStore *newnode;
3222
3223 FLATCOPY(newnode, fstore, FieldStore);
3224 MUTATE(newnode->arg, fstore->arg, Expr *);
3225 MUTATE(newnode->newvals, fstore->newvals, List *);
3226 newnode->fieldnums = list_copy(fstore->fieldnums);
3227 return (Node *) newnode;
3228 }
3229 break;
3230 case T_RelabelType:
3231 {
3232 RelabelType *relabel = (RelabelType *) node;
3233 RelabelType *newnode;
3234
3235 FLATCOPY(newnode, relabel, RelabelType);
3236 MUTATE(newnode->arg, relabel->arg, Expr *);
3237 return (Node *) newnode;
3238 }
3239 break;
3240 case T_CoerceViaIO:
3241 {
3242 CoerceViaIO *iocoerce = (CoerceViaIO *) node;
3243 CoerceViaIO *newnode;
3244
3245 FLATCOPY(newnode, iocoerce, CoerceViaIO);
3246 MUTATE(newnode->arg, iocoerce->arg, Expr *);
3247 return (Node *) newnode;
3248 }
3249 break;
3250 case T_ArrayCoerceExpr:
3251 {
3252 ArrayCoerceExpr *acoerce = (ArrayCoerceExpr *) node;
3253 ArrayCoerceExpr *newnode;
3254
3255 FLATCOPY(newnode, acoerce, ArrayCoerceExpr);
3256 MUTATE(newnode->arg, acoerce->arg, Expr *);
3257 MUTATE(newnode->elemexpr, acoerce->elemexpr, Expr *);
3258 return (Node *) newnode;
3259 }
3260 break;
3261 case T_ConvertRowtypeExpr:
3262 {
3263 ConvertRowtypeExpr *convexpr = (ConvertRowtypeExpr *) node;
3264 ConvertRowtypeExpr *newnode;
3265
3266 FLATCOPY(newnode, convexpr, ConvertRowtypeExpr);
3267 MUTATE(newnode->arg, convexpr->arg, Expr *);
3268 return (Node *) newnode;
3269 }
3270 break;
3271 case T_CollateExpr:
3272 {
3273 CollateExpr *collate = (CollateExpr *) node;
3274 CollateExpr *newnode;
3275
3276 FLATCOPY(newnode, collate, CollateExpr);
3277 MUTATE(newnode->arg, collate->arg, Expr *);
3278 return (Node *) newnode;
3279 }
3280 break;
3281 case T_CaseExpr:
3282 {
3283 CaseExpr *caseexpr = (CaseExpr *) node;
3284 CaseExpr *newnode;
3285
3286 FLATCOPY(newnode, caseexpr, CaseExpr);
3287 MUTATE(newnode->arg, caseexpr->arg, Expr *);
3288 MUTATE(newnode->args, caseexpr->args, List *);
3289 MUTATE(newnode->defresult, caseexpr->defresult, Expr *);
3290 return (Node *) newnode;
3291 }
3292 break;
3293 case T_CaseWhen:
3294 {
3295 CaseWhen *casewhen = (CaseWhen *) node;
3296 CaseWhen *newnode;
3297
3298 FLATCOPY(newnode, casewhen, CaseWhen);
3299 MUTATE(newnode->expr, casewhen->expr, Expr *);
3300 MUTATE(newnode->result, casewhen->result, Expr *);
3301 return (Node *) newnode;
3302 }
3303 break;
3304 case T_ArrayExpr:
3305 {
3306 ArrayExpr *arrayexpr = (ArrayExpr *) node;
3307 ArrayExpr *newnode;
3308
3309 FLATCOPY(newnode, arrayexpr, ArrayExpr);
3310 MUTATE(newnode->elements, arrayexpr->elements, List *);
3311 return (Node *) newnode;
3312 }
3313 break;
3314 case T_RowExpr:
3315 {
3316 RowExpr *rowexpr = (RowExpr *) node;
3317 RowExpr *newnode;
3318
3319 FLATCOPY(newnode, rowexpr, RowExpr);
3320 MUTATE(newnode->args, rowexpr->args, List *);
3321 /* Assume colnames needn't be duplicated */
3322 return (Node *) newnode;
3323 }
3324 break;
3325 case T_RowCompareExpr:
3326 {
3327 RowCompareExpr *rcexpr = (RowCompareExpr *) node;
3328 RowCompareExpr *newnode;
3329
3330 FLATCOPY(newnode, rcexpr, RowCompareExpr);
3331 MUTATE(newnode->largs, rcexpr->largs, List *);
3332 MUTATE(newnode->rargs, rcexpr->rargs, List *);
3333 return (Node *) newnode;
3334 }
3335 break;
3336 case T_CoalesceExpr:
3337 {
3338 CoalesceExpr *coalesceexpr = (CoalesceExpr *) node;
3339 CoalesceExpr *newnode;
3340
3341 FLATCOPY(newnode, coalesceexpr, CoalesceExpr);
3342 MUTATE(newnode->args, coalesceexpr->args, List *);
3343 return (Node *) newnode;
3344 }
3345 break;
3346 case T_MinMaxExpr:
3347 {
3348 MinMaxExpr *minmaxexpr = (MinMaxExpr *) node;
3349 MinMaxExpr *newnode;
3350
3351 FLATCOPY(newnode, minmaxexpr, MinMaxExpr);
3352 MUTATE(newnode->args, minmaxexpr->args, List *);
3353 return (Node *) newnode;
3354 }
3355 break;
3356 case T_XmlExpr:
3357 {
3358 XmlExpr *xexpr = (XmlExpr *) node;
3359 XmlExpr *newnode;
3360
3361 FLATCOPY(newnode, xexpr, XmlExpr);
3362 MUTATE(newnode->named_args, xexpr->named_args, List *);
3363 /* assume mutator does not care about arg_names */
3364 MUTATE(newnode->args, xexpr->args, List *);
3365 return (Node *) newnode;
3366 }
3367 break;
3368 case T_JsonReturning:
3369 {
3370 JsonReturning *jr = (JsonReturning *) node;
3371 JsonReturning *newnode;
3372
3373 FLATCOPY(newnode, jr, JsonReturning);
3374 MUTATE(newnode->format, jr->format, JsonFormat *);
3375
3376 return (Node *) newnode;
3377 }
3378 case T_JsonValueExpr:
3379 {
3380 JsonValueExpr *jve = (JsonValueExpr *) node;
3381 JsonValueExpr *newnode;
3382
3383 FLATCOPY(newnode, jve, JsonValueExpr);
3384 MUTATE(newnode->raw_expr, jve->raw_expr, Expr *);
3385 MUTATE(newnode->formatted_expr, jve->formatted_expr, Expr *);
3386 MUTATE(newnode->format, jve->format, JsonFormat *);
3387
3388 return (Node *) newnode;
3389 }
3390 case T_JsonConstructorExpr:
3391 {
3393 JsonConstructorExpr *newnode;
3394
3395 FLATCOPY(newnode, jce, JsonConstructorExpr);
3396 MUTATE(newnode->args, jce->args, List *);
3397 MUTATE(newnode->func, jce->func, Expr *);
3398 MUTATE(newnode->coercion, jce->coercion, Expr *);
3399 MUTATE(newnode->returning, jce->returning, JsonReturning *);
3400
3401 return (Node *) newnode;
3402 }
3403 case T_JsonIsPredicate:
3404 {
3405 JsonIsPredicate *pred = (JsonIsPredicate *) node;
3406 JsonIsPredicate *newnode;
3407
3408 FLATCOPY(newnode, pred, JsonIsPredicate);
3409 MUTATE(newnode->expr, pred->expr, Node *);
3410 MUTATE(newnode->format, pred->format, JsonFormat *);
3411
3412 return (Node *) newnode;
3413 }
3414 case T_JsonExpr:
3415 {
3416 JsonExpr *jexpr = (JsonExpr *) node;
3417 JsonExpr *newnode;
3418
3419 FLATCOPY(newnode, jexpr, JsonExpr);
3420 MUTATE(newnode->formatted_expr, jexpr->formatted_expr, Node *);
3421 MUTATE(newnode->path_spec, jexpr->path_spec, Node *);
3422 MUTATE(newnode->passing_values, jexpr->passing_values, List *);
3423 /* assume mutator does not care about passing_names */
3424 MUTATE(newnode->on_empty, jexpr->on_empty, JsonBehavior *);
3425 MUTATE(newnode->on_error, jexpr->on_error, JsonBehavior *);
3426 return (Node *) newnode;
3427 }
3428 break;
3429 case T_JsonBehavior:
3430 {
3431 JsonBehavior *behavior = (JsonBehavior *) node;
3432 JsonBehavior *newnode;
3433
3434 FLATCOPY(newnode, behavior, JsonBehavior);
3435 MUTATE(newnode->expr, behavior->expr, Node *);
3436 return (Node *) newnode;
3437 }
3438 break;
3439 case T_NullTest:
3440 {
3441 NullTest *ntest = (NullTest *) node;
3442 NullTest *newnode;
3443
3444 FLATCOPY(newnode, ntest, NullTest);
3445 MUTATE(newnode->arg, ntest->arg, Expr *);
3446 return (Node *) newnode;
3447 }
3448 break;
3449 case T_BooleanTest:
3450 {
3451 BooleanTest *btest = (BooleanTest *) node;
3452 BooleanTest *newnode;
3453
3454 FLATCOPY(newnode, btest, BooleanTest);
3455 MUTATE(newnode->arg, btest->arg, Expr *);
3456 return (Node *) newnode;
3457 }
3458 break;
3459 case T_CoerceToDomain:
3460 {
3461 CoerceToDomain *ctest = (CoerceToDomain *) node;
3462 CoerceToDomain *newnode;
3463
3464 FLATCOPY(newnode, ctest, CoerceToDomain);
3465 MUTATE(newnode->arg, ctest->arg, Expr *);
3466 return (Node *) newnode;
3467 }
3468 break;
3469 case T_ReturningExpr:
3470 {
3471 ReturningExpr *rexpr = (ReturningExpr *) node;
3472 ReturningExpr *newnode;
3473
3474 FLATCOPY(newnode, rexpr, ReturningExpr);
3475 MUTATE(newnode->retexpr, rexpr->retexpr, Expr *);
3476 return (Node *) newnode;
3477 }
3478 break;
3479 case T_TargetEntry:
3480 {
3481 TargetEntry *targetentry = (TargetEntry *) node;
3482 TargetEntry *newnode;
3483
3484 FLATCOPY(newnode, targetentry, TargetEntry);
3485 MUTATE(newnode->expr, targetentry->expr, Expr *);
3486 return (Node *) newnode;
3487 }
3488 break;
3489 case T_Query:
3490 /* Do nothing with a sub-Query, per discussion above */
3491 return node;
3492 case T_WindowClause:
3493 {
3494 WindowClause *wc = (WindowClause *) node;
3495 WindowClause *newnode;
3496
3497 FLATCOPY(newnode, wc, WindowClause);
3498 MUTATE(newnode->partitionClause, wc->partitionClause, List *);
3499 MUTATE(newnode->orderClause, wc->orderClause, List *);
3500 MUTATE(newnode->startOffset, wc->startOffset, Node *);
3501 MUTATE(newnode->endOffset, wc->endOffset, Node *);
3502 return (Node *) newnode;
3503 }
3504 break;
3505 case T_CTECycleClause:
3506 {
3507 CTECycleClause *cc = (CTECycleClause *) node;
3508 CTECycleClause *newnode;
3509
3510 FLATCOPY(newnode, cc, CTECycleClause);
3511 MUTATE(newnode->cycle_mark_value, cc->cycle_mark_value, Node *);
3513 return (Node *) newnode;
3514 }
3515 break;
3516 case T_CommonTableExpr:
3517 {
3518 CommonTableExpr *cte = (CommonTableExpr *) node;
3519 CommonTableExpr *newnode;
3520
3521 FLATCOPY(newnode, cte, CommonTableExpr);
3522
3523 /*
3524 * Also invoke the mutator on the CTE's Query node, so it can
3525 * recurse into the sub-query if it wants to.
3526 */
3527 MUTATE(newnode->ctequery, cte->ctequery, Node *);
3528
3529 MUTATE(newnode->search_clause, cte->search_clause, CTESearchClause *);
3530 MUTATE(newnode->cycle_clause, cte->cycle_clause, CTECycleClause *);
3531
3532 return (Node *) newnode;
3533 }
3534 break;
3535 case T_PartitionBoundSpec:
3536 {
3537 PartitionBoundSpec *pbs = (PartitionBoundSpec *) node;
3538 PartitionBoundSpec *newnode;
3539
3540 FLATCOPY(newnode, pbs, PartitionBoundSpec);
3541 MUTATE(newnode->listdatums, pbs->listdatums, List *);
3542 MUTATE(newnode->lowerdatums, pbs->lowerdatums, List *);
3543 MUTATE(newnode->upperdatums, pbs->upperdatums, List *);
3544 return (Node *) newnode;
3545 }
3546 break;
3547 case T_PartitionRangeDatum:
3548 {
3550 PartitionRangeDatum *newnode;
3551
3552 FLATCOPY(newnode, prd, PartitionRangeDatum);
3553 MUTATE(newnode->value, prd->value, Node *);
3554 return (Node *) newnode;
3555 }
3556 break;
3557 case T_List:
3558 {
3559 /*
3560 * We assume the mutator isn't interested in the list nodes
3561 * per se, so just invoke it on each list element. NOTE: this
3562 * would fail badly on a list with integer elements!
3563 */
3564 List *resultlist;
3565 ListCell *temp;
3566
3567 resultlist = NIL;
3568 foreach(temp, (List *) node)
3569 {
3570 resultlist = lappend(resultlist,
3571 mutator((Node *) lfirst(temp),
3572 context));
3573 }
3574 return (Node *) resultlist;
3575 }
3576 break;
3577 case T_FromExpr:
3578 {
3579 FromExpr *from = (FromExpr *) node;
3580 FromExpr *newnode;
3581
3582 FLATCOPY(newnode, from, FromExpr);
3583 MUTATE(newnode->fromlist, from->fromlist, List *);
3584 MUTATE(newnode->quals, from->quals, Node *);
3585 return (Node *) newnode;
3586 }
3587 break;
3588 case T_OnConflictExpr:
3589 {
3590 OnConflictExpr *oc = (OnConflictExpr *) node;
3591 OnConflictExpr *newnode;
3592
3593 FLATCOPY(newnode, oc, OnConflictExpr);
3594 MUTATE(newnode->arbiterElems, oc->arbiterElems, List *);
3595 MUTATE(newnode->arbiterWhere, oc->arbiterWhere, Node *);
3596 MUTATE(newnode->onConflictSet, oc->onConflictSet, List *);
3597 MUTATE(newnode->onConflictWhere, oc->onConflictWhere, Node *);
3598 MUTATE(newnode->exclRelTlist, oc->exclRelTlist, List *);
3599
3600 return (Node *) newnode;
3601 }
3602 break;
3603 case T_MergeAction:
3604 {
3605 MergeAction *action = (MergeAction *) node;
3606 MergeAction *newnode;
3607
3608 FLATCOPY(newnode, action, MergeAction);
3609 MUTATE(newnode->qual, action->qual, Node *);
3610 MUTATE(newnode->targetList, action->targetList, List *);
3611
3612 return (Node *) newnode;
3613 }
3614 break;
3615 case T_PartitionPruneStepOp:
3616 {
3617 PartitionPruneStepOp *opstep = (PartitionPruneStepOp *) node;
3618 PartitionPruneStepOp *newnode;
3619
3620 FLATCOPY(newnode, opstep, PartitionPruneStepOp);
3621 MUTATE(newnode->exprs, opstep->exprs, List *);
3622
3623 return (Node *) newnode;
3624 }
3625 break;
3626 case T_PartitionPruneStepCombine:
3627 /* no expression sub-nodes */
3628 return copyObject(node);
3629 case T_JoinExpr:
3630 {
3631 JoinExpr *join = (JoinExpr *) node;
3632 JoinExpr *newnode;
3633
3634 FLATCOPY(newnode, join, JoinExpr);
3635 MUTATE(newnode->larg, join->larg, Node *);
3636 MUTATE(newnode->rarg, join->rarg, Node *);
3637 MUTATE(newnode->quals, join->quals, Node *);
3638 /* We do not mutate alias or using by default */
3639 return (Node *) newnode;
3640 }
3641 break;
3642 case T_SetOperationStmt:
3643 {
3644 SetOperationStmt *setop = (SetOperationStmt *) node;
3645 SetOperationStmt *newnode;
3646
3647 FLATCOPY(newnode, setop, SetOperationStmt);
3648 MUTATE(newnode->larg, setop->larg, Node *);
3649 MUTATE(newnode->rarg, setop->rarg, Node *);
3650 /* We do not mutate groupClauses by default */
3651 return (Node *) newnode;
3652 }
3653 break;
3654 case T_IndexClause:
3655 {
3656 IndexClause *iclause = (IndexClause *) node;
3657 IndexClause *newnode;
3658
3659 FLATCOPY(newnode, iclause, IndexClause);
3660 MUTATE(newnode->rinfo, iclause->rinfo, RestrictInfo *);
3661 MUTATE(newnode->indexquals, iclause->indexquals, List *);
3662 return (Node *) newnode;
3663 }
3664 break;
3665 case T_PlaceHolderVar:
3666 {
3667 PlaceHolderVar *phv = (PlaceHolderVar *) node;
3668 PlaceHolderVar *newnode;
3669
3670 FLATCOPY(newnode, phv, PlaceHolderVar);
3671 MUTATE(newnode->phexpr, phv->phexpr, Expr *);
3672 /* Assume we need not copy the relids bitmapsets */
3673 return (Node *) newnode;
3674 }
3675 break;
3676 case T_InferenceElem:
3677 {
3678 InferenceElem *inferenceelemdexpr = (InferenceElem *) node;
3679 InferenceElem *newnode;
3680
3681 FLATCOPY(newnode, inferenceelemdexpr, InferenceElem);
3682 MUTATE(newnode->expr, newnode->expr, Node *);
3683 return (Node *) newnode;
3684 }
3685 break;
3686 case T_AppendRelInfo:
3687 {
3688 AppendRelInfo *appinfo = (AppendRelInfo *) node;
3689 AppendRelInfo *newnode;
3690
3691 FLATCOPY(newnode, appinfo, AppendRelInfo);
3692 MUTATE(newnode->translated_vars, appinfo->translated_vars, List *);
3693 /* Assume nothing need be done with parent_colnos[] */
3694 return (Node *) newnode;
3695 }
3696 break;
3697 case T_PlaceHolderInfo:
3698 {
3699 PlaceHolderInfo *phinfo = (PlaceHolderInfo *) node;
3700 PlaceHolderInfo *newnode;
3701
3702 FLATCOPY(newnode, phinfo, PlaceHolderInfo);
3703 MUTATE(newnode->ph_var, phinfo->ph_var, PlaceHolderVar *);
3704 /* Assume we need not copy the relids bitmapsets */
3705 return (Node *) newnode;
3706 }
3707 break;
3708 case T_RangeTblFunction:
3709 {
3710 RangeTblFunction *rtfunc = (RangeTblFunction *) node;
3711 RangeTblFunction *newnode;
3712
3713 FLATCOPY(newnode, rtfunc, RangeTblFunction);
3714 MUTATE(newnode->funcexpr, rtfunc->funcexpr, Node *);
3715 /* Assume we need not copy the coldef info lists */
3716 return (Node *) newnode;
3717 }
3718 break;
3719 case T_TableSampleClause:
3720 {
3721 TableSampleClause *tsc = (TableSampleClause *) node;
3722 TableSampleClause *newnode;
3723
3724 FLATCOPY(newnode, tsc, TableSampleClause);
3725 MUTATE(newnode->args, tsc->args, List *);
3726 MUTATE(newnode->repeatable, tsc->repeatable, Expr *);
3727 return (Node *) newnode;
3728 }
3729 break;
3730 case T_TableFunc:
3731 {
3732 TableFunc *tf = (TableFunc *) node;
3733 TableFunc *newnode;
3734
3735 FLATCOPY(newnode, tf, TableFunc);
3736 MUTATE(newnode->ns_uris, tf->ns_uris, List *);
3737 MUTATE(newnode->docexpr, tf->docexpr, Node *);
3738 MUTATE(newnode->rowexpr, tf->rowexpr, Node *);
3739 MUTATE(newnode->colexprs, tf->colexprs, List *);
3740 MUTATE(newnode->coldefexprs, tf->coldefexprs, List *);
3741 MUTATE(newnode->colvalexprs, tf->colvalexprs, List *);
3742 MUTATE(newnode->passingvalexprs, tf->passingvalexprs, List *);
3743 return (Node *) newnode;
3744 }
3745 break;
3746 default:
3747 elog(ERROR, "unrecognized node type: %d",
3748 (int) nodeTag(node));
3749 break;
3750 }
3751 /* can't get here, but keep compiler happy */
3752 return NULL;
3753}
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:493
List * aggdirectargs
Definition: primnodes.h:484
List * args
Definition: primnodes.h:487
Expr * aggfilter
Definition: primnodes.h:496
List * aggorder
Definition: primnodes.h:490
List * translated_vars
Definition: pathnodes.h:3220
List * args
Definition: primnodes.h:972
Expr * arg
Definition: primnodes.h:2007
Node * cycle_mark_default
Definition: parsenodes.h:1716
Node * cycle_mark_value
Definition: parsenodes.h:1715
Expr * arg
Definition: primnodes.h:1346
Expr * defresult
Definition: primnodes.h:1348
List * args
Definition: primnodes.h:1347
Expr * result
Definition: primnodes.h:1359
Expr * expr
Definition: primnodes.h:1358
List * args
Definition: primnodes.h:1517
Expr * arg
Definition: primnodes.h:1312
Expr * arg
Definition: primnodes.h:1161
List * newvals
Definition: primnodes.h:1193
Expr * arg
Definition: primnodes.h:1192
Node * quals
Definition: primnodes.h:2358
List * fromlist
Definition: primnodes.h:2357
List * args
Definition: primnodes.h:800
List * indexquals
Definition: pathnodes.h:2007
struct RestrictInfo * rinfo
Definition: pathnodes.h:2006
Node * quals
Definition: primnodes.h:2338
Node * larg
Definition: primnodes.h:2331
Node * rarg
Definition: primnodes.h:2332
JsonReturning * returning
Definition: primnodes.h:1735
Node * formatted_expr
Definition: primnodes.h:1848
List * passing_values
Definition: primnodes.h:1861
JsonBehavior * on_empty
Definition: primnodes.h:1864
Node * path_spec
Definition: primnodes.h:1854
JsonBehavior * on_error
Definition: primnodes.h:1865
JsonFormat * format
Definition: primnodes.h:1761
JsonFormat * format
Definition: primnodes.h:1688
Expr * formatted_expr
Definition: primnodes.h:1709
JsonFormat * format
Definition: primnodes.h:1710
Expr * raw_expr
Definition: primnodes.h:1708
Definition: pg_list.h:54
Node * qual
Definition: primnodes.h:2035
List * targetList
Definition: primnodes.h:2036
List * args
Definition: primnodes.h:1543
Expr * arg
Definition: primnodes.h:823
Expr * arg
Definition: primnodes.h:1983
List * arbiterElems
Definition: primnodes.h:2376
List * onConflictSet
Definition: primnodes.h:2382
List * exclRelTlist
Definition: primnodes.h:2385
Node * onConflictWhere
Definition: primnodes.h:2383
Node * arbiterWhere
Definition: primnodes.h:2378
List * args
Definition: primnodes.h:868
PlaceHolderVar * ph_var
Definition: pathnodes.h:3308
Expr * retexpr
Definition: primnodes.h:2177
List * args
Definition: primnodes.h:1448
List * args
Definition: primnodes.h:1124
Node * testexpr
Definition: primnodes.h:1099
Expr * refassgnexpr
Definition: primnodes.h:735
List * refupperindexpr
Definition: primnodes.h:725
Expr * refexpr
Definition: primnodes.h:733
List * reflowerindexpr
Definition: primnodes.h:731
Node * docexpr
Definition: primnodes.h:120
Node * rowexpr
Definition: primnodes.h:122
List * colexprs
Definition: primnodes.h:132
Expr * expr
Definition: primnodes.h:2239
Node * startOffset
Definition: parsenodes.h:1605
List * partitionClause
Definition: parsenodes.h:1601
Node * endOffset
Definition: parsenodes.h:1606
List * orderClause
Definition: parsenodes.h:1603
List * args
Definition: primnodes.h:605
Expr * aggfilter
Definition: primnodes.h:607
List * args
Definition: primnodes.h:1633
List * named_args
Definition: primnodes.h:1629

References generate_unaccent_rules::action, Aggref::aggdirectargs, Aggref::aggdistinct, Aggref::aggfilter, WindowFunc::aggfilter, Aggref::aggorder, OnConflictExpr::arbiterElems, OnConflictExpr::arbiterWhere, WindowFuncRunCondition::arg, NamedArgExpr::arg, FieldSelect::arg, FieldStore::arg, RelabelType::arg, CoerceViaIO::arg, ArrayCoerceExpr::arg, ConvertRowtypeExpr::arg, CollateExpr::arg, CaseExpr::arg, NullTest::arg, BooleanTest::arg, CoerceToDomain::arg, TableSampleClause::args, Aggref::args, WindowFunc::args, FuncExpr::args, OpExpr::args, ScalarArrayOpExpr::args, BoolExpr::args, SubPlan::args, CaseExpr::args, RowExpr::args, CoalesceExpr::args, MinMaxExpr::args, XmlExpr::args, JsonConstructorExpr::args, check_stack_depth(), JsonConstructorExpr::coercion, TableFunc::colexprs, copyObject, CommonTableExpr::ctequery, CTECycleClause::cycle_mark_default, CTECycleClause::cycle_mark_value, CaseExpr::defresult, TableFunc::docexpr, ArrayCoerceExpr::elemexpr, elog, WindowClause::endOffset, ERROR, OnConflictExpr::exclRelTlist, CaseWhen::expr, JsonIsPredicate::expr, JsonBehavior::expr, InferenceElem::expr, TargetEntry::expr, PartitionPruneStepOp::exprs, FLATCOPY, JsonReturning::format, JsonValueExpr::format, JsonIsPredicate::format, JsonValueExpr::formatted_expr, JsonExpr::formatted_expr, FromExpr::fromlist, JsonConstructorExpr::func, RangeTblFunction::funcexpr, IndexClause::indexquals, lappend(), SetOperationStmt::larg, JoinExpr::larg, RowCompareExpr::largs, lfirst, list_copy(), PartitionBoundSpec::listdatums, PartitionBoundSpec::lowerdatums, MUTATE, XmlExpr::named_args, FieldStore::newvals, NIL, nodeTag, JsonExpr::on_empty, JsonExpr::on_error, OnConflictExpr::onConflictSet, OnConflictExpr::onConflictWhere, WindowClause::orderClause, WindowClause::partitionClause, JsonExpr::passing_values, JsonExpr::path_spec, PlaceHolderInfo::ph_var, WithCheckOption::qual, MergeAction::qual, JoinExpr::quals, FromExpr::quals, SetOperationStmt::rarg, JoinExpr::rarg, RowCompareExpr::rargs, JsonValueExpr::raw_expr, SubscriptingRef::refassgnexpr, SubscriptingRef::refexpr, SubscriptingRef::reflowerindexpr, SubscriptingRef::refupperindexpr, TableSampleClause::repeatable, CaseWhen::result, ReturningExpr::retexpr, JsonConstructorExpr::returning, IndexClause::rinfo, TableFunc::rowexpr, WindowClause::startOffset, AlternativeSubPlan::subplans, SubLink::subselect, MergeAction::targetList, SubLink::testexpr, SubPlan::testexpr, AppendRelInfo::translated_vars, PartitionBoundSpec::upperdatums, and PartitionRangeDatum::value.

◆ expression_tree_walker_impl()

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

Definition at line 2092 of file nodeFuncs.c.

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

References generate_unaccent_rules::action, JsonAggConstructor::agg_filter, JsonAggConstructor::agg_order, Aggref::aggdirectargs, Aggref::aggdistinct, Aggref::aggfilter, WindowFunc::aggfilter, Aggref::aggorder, OnConflictExpr::arbiterElems, OnConflictExpr::arbiterWhere, arg, JsonObjectAgg::arg, JsonArrayAgg::arg, WindowFuncRunCondition::arg, FieldStore::arg, ArrayCoerceExpr::arg, CaseExpr::arg, generate_unaccent_rules::args, TableSampleClause::args, Aggref::args, WindowFunc::args, FuncExpr::args, OpExpr::args, ScalarArrayOpExpr::args, BoolExpr::args, SubPlan::args, CaseExpr::args, XmlExpr::args, JsonConstructorExpr::args, check_stack_depth(), JsonConstructorExpr::coercion, TableFunc::colexprs, JsonObjectAgg::constructor, JsonArrayAgg::constructor, CommonTableExpr::ctequery, CTECycleClause::cycle_mark_default, CTECycleClause::cycle_mark_value, CaseExpr::defresult, TableFunc::docexpr, ArrayCoerceExpr::elemexpr, elog, WindowClause::endOffset, ERROR, OnConflictExpr::exclRelTlist, JsonBehavior::expr, JsonObjectConstructor::exprs, JsonArrayConstructor::exprs, PartitionPruneStepOp::exprs, JsonValueExpr::formatted_expr, JsonExpr::formatted_expr, FromExpr::fromlist, JsonConstructorExpr::func, IndexClause::indexquals, JsonKeyValue::key, SetOperationStmt::larg, JoinExpr::larg, RowCompareExpr::largs, lfirst, lfirst_node, LIST_WALK, PartitionBoundSpec::listdatums, PartitionBoundSpec::lowerdatums, XmlExpr::named_args, FieldStore::newvals, nodeTag, JsonExpr::on_empty, JsonExpr::on_error, OnConflictExpr::onConflictSet, OnConflictExpr::onConflictWhere, WindowClause::orderClause, JsonAggConstructor::over, WindowClause::partitionClause, JsonExpr::passing_values, JsonExpr::path_spec, JoinExpr::quals, FromExpr::quals, JsonArrayQueryConstructor::query, SetOperationStmt::rarg, JoinExpr::rarg, RowCompareExpr::rargs, JsonValueExpr::raw_expr, SubscriptingRef::refassgnexpr, SubscriptingRef::refexpr, SubscriptingRef::reflowerindexpr, SubscriptingRef::refupperindexpr, TableSampleClause::repeatable, IndexClause::rinfo, TableFunc::rowexpr, WindowClause::startOffset, SubLink::subselect, SubLink::testexpr, SubPlan::testexpr, AppendRelInfo::translated_vars, PartitionBoundSpec::upperdatums, PartitionRangeDatum::value, JsonKeyValue::value, and WALK.

◆ exprInputCollation()

Oid exprInputCollation ( const Node expr)

Definition at line 1076 of file nodeFuncs.c.

1077{
1078 Oid coll;
1079
1080 if (!expr)
1081 return InvalidOid;
1082
1083 switch (nodeTag(expr))
1084 {
1085 case T_Aggref:
1086 coll = ((const Aggref *) expr)->inputcollid;
1087 break;
1088 case T_WindowFunc:
1089 coll = ((const WindowFunc *) expr)->inputcollid;
1090 break;
1091 case T_FuncExpr:
1092 coll = ((const FuncExpr *) expr)->inputcollid;
1093 break;
1094 case T_OpExpr:
1095 coll = ((const OpExpr *) expr)->inputcollid;
1096 break;
1097 case T_DistinctExpr:
1098 coll = ((const DistinctExpr *) expr)->inputcollid;
1099 break;
1100 case T_NullIfExpr:
1101 coll = ((const NullIfExpr *) expr)->inputcollid;
1102 break;
1103 case T_ScalarArrayOpExpr:
1104 coll = ((const ScalarArrayOpExpr *) expr)->inputcollid;
1105 break;
1106 case T_MinMaxExpr:
1107 coll = ((const MinMaxExpr *) expr)->inputcollid;
1108 break;
1109 default:
1110 coll = InvalidOid;
1111 break;
1112 }
1113 return coll;
1114}

References InvalidOid, and nodeTag.

Referenced by check_simple_rowfilter_expr_walker(), and resolve_polymorphic_tupdesc().

◆ exprIsLengthCoercion()

bool exprIsLengthCoercion ( const Node expr,
int32 coercedTypmod 
)

Definition at line 557 of file nodeFuncs.c.

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

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

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

◆ exprLocation()

int exprLocation ( const Node expr)

Definition at line 1384 of file nodeFuncs.c.

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

References arg, TypeCast::arg, NamedArgExpr::arg, RelabelType::arg, CoerceViaIO::arg, ArrayCoerceExpr::arg, ConvertRowtypeExpr::arg, NullTest::arg, BooleanTest::arg, CoerceToDomain::arg, FuncExpr::args, OpExpr::args, ScalarArrayOpExpr::args, BoolExpr::args, XmlExpr::args, exprLocation(), fc(), JsonExpr::formatted_expr, sort-test::key, leftmostLoc(), A_Expr::lexpr, lfirst, TypeName::location, A_Expr::location, TypeCast::location, FuncExpr::location, NamedArgExpr::location, OpExpr::location, ScalarArrayOpExpr::location, BoolExpr::location, SubLink::location, RelabelType::location, CoerceViaIO::location, ArrayCoerceExpr::location, ConvertRowtypeExpr::location, XmlExpr::location, JsonExpr::location, NullTest::location, BooleanTest::location, CoerceToDomain::location, nodeTag, source, SubLink::testexpr, and TypeCast::typeName.

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(), EvaluateParams(), ExecInitFunc(), ExecInitSubscriptingRef(), exprLocation(), finalize_grouping_exprs_walker(), 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(), transformFrameOffset(), transformFromClauseItem(), transformGroupClause(), transformGroupClauseExpr(), transformGroupingSet(), transformIndirection(), transformInsertRow(), transformInsertStmt(), transformJsonBehavior(), transformJsonFuncExpr(), transformJsonParseArg(), transformJsonValueExpr(), transformMultiAssignRef(), transformOnConflictArbiter(), transformPartitionBound(), transformPartitionBoundValue(), transformPartitionRangeBounds(), transformPLAssignStmtTarget(), transformRangeFunction(), transformReturningClause(), transformSelectStmt(), transformSetOperationStmt(), transformSetOperationTree(), transformValuesClause(), and validateInfiniteBounds().

◆ exprSetCollation()

void exprSetCollation ( Node expr,
Oid  collation 
)

Definition at line 1124 of file nodeFuncs.c.

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

References arg, ARRAY_SUBLINK, Assert(), JsonConstructorExpr::coercion, JsonExpr::collation, elog, ERROR, EXPR_SUBLINK, exprCollation(), exprSetCollation(), if(), InvalidOid, IS_XMLSERIALIZE, IsA, linitial_node, nodeTag, OidIsValid, SubLink::subLinkType, SubLink::subselect, Query::targetList, and type.

Referenced by assign_collations_walker(), and exprSetCollation().

◆ exprSetInputCollation()

void exprSetInputCollation ( Node expr,
Oid  inputcollation 
)

Definition at line 1320 of file nodeFuncs.c.

1321{
1322 switch (nodeTag(expr))
1323 {
1324 case T_Aggref:
1325 ((Aggref *) expr)->inputcollid = inputcollation;
1326 break;
1327 case T_WindowFunc:
1328 ((WindowFunc *) expr)->inputcollid = inputcollation;
1329 break;
1330 case T_FuncExpr:
1331 ((FuncExpr *) expr)->inputcollid = inputcollation;
1332 break;
1333 case T_OpExpr:
1334 ((OpExpr *) expr)->inputcollid = inputcollation;
1335 break;
1336 case T_DistinctExpr:
1337 ((DistinctExpr *) expr)->inputcollid = inputcollation;
1338 break;
1339 case T_NullIfExpr:
1340 ((NullIfExpr *) expr)->inputcollid = inputcollation;
1341 break;
1342 case T_ScalarArrayOpExpr:
1343 ((ScalarArrayOpExpr *) expr)->inputcollid = inputcollation;
1344 break;
1345 case T_MinMaxExpr:
1346 ((MinMaxExpr *) expr)->inputcollid = inputcollation;
1347 break;
1348 default:
1349 break;
1350 }
1351}

References nodeTag.

Referenced by assign_collations_walker().

◆ exprType()

Oid exprType ( const Node expr)

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;
69 case T_MergeSupportFunc:
70 type = ((const MergeSupportFunc *) expr)->msftype;
71 break;
72 case T_SubscriptingRef:
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;
90 case T_ScalarArrayOpExpr:
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;
105 TargetEntry *tent;
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))
117 (errcode(ERRCODE_UNDEFINED_OBJECT),
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))
148 (errcode(ERRCODE_UNDEFINED_OBJECT),
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;
165 case T_AlternativeSubPlan:
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;
185 case T_ArrayCoerceExpr:
186 type = ((const ArrayCoerceExpr *) expr)->resulttype;
187 break;
188 case T_ConvertRowtypeExpr:
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;
215 case T_SQLValueFunction:
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;
233 case T_JsonConstructorExpr:
234 type = ((const JsonConstructorExpr *) expr)->returning->typid;
235 break;
236 case T_JsonIsPredicate:
237 type = BOOLOID;
238 break;
239 case T_JsonExpr:
240 {
241 const JsonExpr *jexpr = (const JsonExpr *) expr;
242
243 type = jexpr->returning->typid;
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;
262 case T_CoerceToDomainValue:
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;
287 default:
288 elog(ERROR, "unrecognized node type: %d", (int) nodeTag(expr));
289 type = InvalidOid; /* keep compiler quiet */
290 break;
291 }
292 return type;
293}
int errcode(int sqlerrcode)
Definition: elog.c:863
int errmsg(const char *fmt,...)
Definition: elog.c:1080
#define ereport(elevel,...)
Definition: elog.h:150
char * format_type_be(Oid type_oid)
Definition: format_type.c:343
Oid get_promoted_array_type(Oid typid)
Definition: lsyscache.c:2961
@ MULTIEXPR_SUBLINK
Definition: primnodes.h:1034
@ IS_DOCUMENT
Definition: primnodes.h:1612
JsonReturning * returning
Definition: primnodes.h:1857
Oid firstColType
Definition: primnodes.h:1106

References arg, ARRAY_SUBLINK, Assert(), elog, ereport, errcode(), errmsg(), ERROR, JsonBehavior::expr, InferenceElem::expr, EXPR_SUBLINK, exprType(), SubPlan::firstColType, format_type_be(), JsonValueExpr::formatted_expr, get_promoted_array_type(), if(), InvalidOid, IS_DOCUMENT, IS_XMLSERIALIZE, IsA, linitial, linitial_node, MULTIEXPR_SUBLINK, nodeTag, OidIsValid, JsonExpr::returning, SubLink::subLinkType, SubPlan::subLinkType, AlternativeSubPlan::subplans, SubLink::subselect, Query::targetList, type, and JsonReturning::typid.

Referenced by add_row_identity_var(), add_setop_child_rel_equivalences(), addRangeTableEntryForFunction(), 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_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(), 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_expression(), examine_variable(), exec_save_simple_expr(), ExecBuildProjectionInfo(), ExecBuildUpdateProjection(), ExecCheckPlanOutput(), ExecEvalJsonIsPredicate(), ExecEvalXmlExpr(), ExecInitExprRec(), ExecInitIndexScan(), ExecInitJsonExpr(), ExecInitSubPlanExpr(), ExecMakeTableFunctionResult(), ExecTypeFromExprList(), ExecTypeFromTLInternal(), expandRecordVariable(), expandRTE(), exprType(), exprTypmod(), find_expr_references_walker(), find_placeholder_info(), fix_indexqual_operand(), foreign_expr_walker(), generate_append_tlist(), generate_join_implied_equalities_normal(), 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(), 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(), transformFrameOffset(), transformFromClauseItem(), transformIndirection(), transformInsertStmt(), transformJsonBehavior(), transformJsonConstructorOutput(), transformJsonFuncExpr(), transformJsonParseArg(), transformJsonScalarExpr(), transformJsonTableColumns(), transformJsonValueExpr(), transformMultiAssignRef(), transformPartitionBoundValue(), transformPLAssignStmtTarget(), transformSetOperationTree(), transformSubLink(), transformTypeCast(), unknown_attribute(), verify_common_type(), and xmlelement().

◆ exprTypmod()

int32 exprTypmod ( const Node expr)

Definition at line 301 of file nodeFuncs.c.

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

References arg, OpExpr::args, CaseExpr::args, CoalesceExpr::args, MinMaxExpr::args, ARRAY_SUBLINK, Assert(), CaseExpr::defresult, elog, ERROR, JsonBehavior::expr, EXPR_SUBLINK, exprIsLengthCoercion(), exprType(), exprTypmod(), SubPlan::firstColTypmod, for_each_from, if(), IsA, lfirst, lfirst_node, linitial, linitial_node, NIL, nodeTag, CaseWhen::result, JsonExpr::returning, SubLink::subLinkType, SubPlan::subLinkType, AlternativeSubPlan::subplans, SubLink::subselect, Query::targetList, and JsonReturning::typmod.

Referenced by add_row_identity_var(), addRangeTableEntryForFunction(), 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_expression(), examine_variable(), exec_save_simple_expr(), ExecInitJsonExpr(), ExecTypeFromExprList(), ExecTypeFromTLInternal(), expandRecordVariable(), expandRTE(), exprTypmod(), find_placeholder_info(), generate_append_tlist(), generate_setop_tlist(), generate_subquery_params(), get_expr_result_type(), get_expr_width(), get_first_col_type(), get_rule_expr(), get_rule_expr_funccall(), 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(), transformJsonTableColumns(), transformMultiAssignRef(), transformPLAssignStmtTarget(), transformSubLink(), varbit_support(), and varchar_support().

◆ fix_opfuncids()

void fix_opfuncids ( Node node)

Definition at line 1840 of file nodeFuncs.c.

1841{
1842 /* This tree walk requires no special setup, so away we go... */
1843 fix_opfuncids_walker(node, NULL);
1844}
static bool fix_opfuncids_walker(Node *node, void *context)
Definition: nodeFuncs.c:1847

References fix_opfuncids_walker().

Referenced by evaluate_expr(), expression_planner(), expression_planner_with_deps(), 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 
)

Definition at line 4722 of file nodeFuncs.c.

4725{
4726 Plan *plan = planstate->plan;
4727 ListCell *lc;
4728
4729 /* We don't need implicit coercions to Node here */
4730#define PSWALK(n) walker(n, context)
4731
4732 /* Guard against stack overflow due to overly complex plan trees */
4734
4735 /* initPlan-s */
4736 if (planstate_walk_subplans(planstate->initPlan, walker, context))
4737 return true;
4738
4739 /* lefttree */
4740 if (outerPlanState(planstate))
4741 {
4742 if (PSWALK(outerPlanState(planstate)))
4743 return true;
4744 }
4745
4746 /* righttree */
4747 if (innerPlanState(planstate))
4748 {
4749 if (PSWALK(innerPlanState(planstate)))
4750 return true;
4751 }
4752
4753 /* special child plans */
4754 switch (nodeTag(plan))
4755 {
4756 case T_Append:
4757 if (planstate_walk_members(((AppendState *) planstate)->appendplans,
4758 ((AppendState *) planstate)->as_nplans,
4759 walker, context))
4760 return true;
4761 break;
4762 case T_MergeAppend:
4763 if (planstate_walk_members(((MergeAppendState *) planstate)->mergeplans,
4764 ((MergeAppendState *) planstate)->ms_nplans,
4765 walker, context))
4766 return true;
4767 break;
4768 case T_BitmapAnd:
4769 if (planstate_walk_members(((BitmapAndState *) planstate)->bitmapplans,
4770 ((BitmapAndState *) planstate)->nplans,
4771 walker, context))
4772 return true;
4773 break;
4774 case T_BitmapOr:
4775 if (planstate_walk_members(((BitmapOrState *) planstate)->bitmapplans,
4776 ((BitmapOrState *) planstate)->nplans,
4777 walker, context))
4778 return true;
4779 break;
4780 case T_SubqueryScan:
4781 if (PSWALK(((SubqueryScanState *) planstate)->subplan))
4782 return true;
4783 break;
4784 case T_CustomScan:
4785 foreach(lc, ((CustomScanState *) planstate)->custom_ps)
4786 {
4787 if (PSWALK(lfirst(lc)))
4788 return true;
4789 }
4790 break;
4791 default:
4792 break;
4793 }
4794
4795 /* subPlan-s */
4796 if (planstate_walk_subplans(planstate->subPlan, walker, context))
4797 return true;
4798
4799 return false;
4800}
#define outerPlanState(node)
Definition: execnodes.h:1261
#define innerPlanState(node)
Definition: execnodes.h:1260
static bool planstate_walk_subplans(List *plans, planstate_tree_walker_callback walker, void *context)
Definition: nodeFuncs.c:4806
#define PSWALK(n)
static bool planstate_walk_members(PlanState **planstates, int nplans, planstate_tree_walker_callback walker, void *context)
Definition: nodeFuncs.c:4828
#define plan(x)
Definition: pg_regress.c:161
Plan * plan
Definition: execnodes.h:1165
List * initPlan
Definition: execnodes.h:1190

References check_stack_depth(), 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 
)

Definition at line 3968 of file nodeFuncs.c.

3972{
3973 if (node && IsA(node, Query))
3974 return (Node *) query_tree_mutator((Query *) node,
3975 mutator,
3976 context,
3977 flags);
3978 else
3979 return mutator(node, context);
3980}
#define query_tree_mutator(q, m, c, f)
Definition: nodeFuncs.h:160

References 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 
)

Definition at line 3945 of file nodeFuncs.c.

3949{
3950 if (node && IsA(node, Query))
3951 return query_tree_walker((Query *) node,
3952 walker,
3953 context,
3954 flags);
3955 else
3956 return WALK(node);
3957}
#define query_tree_walker(q, w, c, f)
Definition: nodeFuncs.h:158

References 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 
)

Definition at line 3776 of file nodeFuncs.c.

3780{
3781 Assert(query != NULL && IsA(query, Query));
3782
3783 if (!(flags & QTW_DONT_COPY_QUERY))
3784 {
3785 Query *newquery;
3786
3787 FLATCOPY(newquery, query, Query);
3788 query = newquery;
3789 }
3790
3791 MUTATE(query->targetList, query->targetList, List *);
3792 MUTATE(query->withCheckOptions, query->withCheckOptions, List *);
3793 MUTATE(query->onConflict, query->onConflict, OnConflictExpr *);
3794 MUTATE(query->mergeActionList, query->mergeActionList, List *);
3796 MUTATE(query->returningList, query->returningList, List *);
3797 MUTATE(query->jointree, query->jointree, FromExpr *);
3798 MUTATE(query->setOperations, query->setOperations, Node *);
3799 MUTATE(query->havingQual, query->havingQual, Node *);
3800 MUTATE(query->limitOffset, query->limitOffset, Node *);
3801 MUTATE(query->limitCount, query->limitCount, Node *);
3802
3803 /*
3804 * Most callers aren't interested in SortGroupClause nodes since those
3805 * don't contain actual expressions. However they do contain OIDs, which
3806 * may be of interest to some mutators.
3807 */
3808
3809 if ((flags & QTW_EXAMINE_SORTGROUP))
3810 {
3811 MUTATE(query->groupClause, query->groupClause, List *);
3812 MUTATE(query->windowClause, query->windowClause, List *);
3813 MUTATE(query->sortClause, query->sortClause, List *);
3814 MUTATE(query->distinctClause, query->distinctClause, List *);
3815 }
3816 else
3817 {
3818 /*
3819 * But we need to mutate the expressions under WindowClause nodes even
3820 * if we're not interested in SortGroupClause nodes.
3821 */
3822 List *resultlist;
3823 ListCell *temp;
3824
3825 resultlist = NIL;
3826 foreach(temp, query->windowClause)
3827 {
3829 WindowClause *newnode;
3830
3831 FLATCOPY(newnode, wc, WindowClause);
3832 MUTATE(newnode->startOffset, wc->startOffset, Node *);
3833 MUTATE(newnode->endOffset, wc->endOffset, Node *);
3834
3835 resultlist = lappend(resultlist, (Node *) newnode);
3836 }
3837 query->windowClause = resultlist;
3838 }
3839
3840 /*
3841 * groupingSets and rowMarks are not mutated:
3842 *
3843 * groupingSets contain only ressortgroup refs (integers) which are
3844 * meaningless without the groupClause or tlist. Accordingly, any mutator
3845 * that needs to care about them needs to handle them itself in its Query
3846 * processing.
3847 *
3848 * rowMarks contains only rangetable indexes (and flags etc.) and
3849 * therefore should be handled at Query level similarly.
3850 */
3851
3852 if (!(flags & QTW_IGNORE_CTE_SUBQUERIES))
3853 MUTATE(query->cteList, query->cteList, List *);
3854 else /* else copy CTE list as-is */
3855 query->cteList = copyObject(query->cteList);
3856 query->rtable = range_table_mutator(query->rtable,
3857 mutator, context, flags);
3858 return query;
3859}
#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:196
Node * limitCount
Definition: parsenodes.h:231
FromExpr * jointree
Definition: parsenodes.h:182
List * returningList
Definition: parsenodes.h:214
Node * setOperations
Definition: parsenodes.h:236
List * cteList
Definition: parsenodes.h:173
OnConflictExpr * onConflict
Definition: parsenodes.h:203
List * groupClause
Definition: parsenodes.h:216
Node * havingQual
Definition: parsenodes.h:222
List * rtable
Definition: parsenodes.h:175
Node * limitOffset
Definition: parsenodes.h:230
List * mergeActionList
Definition: parsenodes.h:185
List * windowClause
Definition: parsenodes.h:224
List * distinctClause
Definition: parsenodes.h:226
List * sortClause
Definition: parsenodes.h:228

References Assert(), copyObject, Query::cteList, Query::distinctClause, WindowClause::endOffset, FLATCOPY, 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 
)

Definition at line 2697 of file nodeFuncs.c.

2701{
2702 Assert(query != NULL && IsA(query, Query));
2703
2704 /*
2705 * We don't walk any utilityStmt here. However, we can't easily assert
2706 * that it is absent, since there are at least two code paths by which
2707 * action statements from CREATE RULE end up here, and NOTIFY is allowed
2708 * in a rule action.
2709 */
2710
2711 if (WALK(query->targetList))
2712 return true;
2713 if (WALK(query->withCheckOptions))
2714 return true;
2715 if (WALK(query->onConflict))
2716 return true;
2717 if (WALK(query->mergeActionList))
2718 return true;
2719 if (WALK(query->mergeJoinCondition))
2720 return true;
2721 if (WALK(query->returningList))
2722 return true;
2723 if (WALK(query->jointree))
2724 return true;
2725 if (WALK(query->setOperations))
2726 return true;
2727 if (WALK(query->havingQual))
2728 return true;
2729 if (WALK(query->limitOffset))
2730 return true;
2731 if (WALK(query->limitCount))
2732 return true;
2733
2734 /*
2735 * Most callers aren't interested in SortGroupClause nodes since those
2736 * don't contain actual expressions. However they do contain OIDs which
2737 * may be needed by dependency walkers etc.
2738 */
2739 if ((flags & QTW_EXAMINE_SORTGROUP))
2740 {
2741 if (WALK(query->groupClause))
2742 return true;
2743 if (WALK(query->windowClause))
2744 return true;
2745 if (WALK(query->sortClause))
2746 return true;
2747 if (WALK(query->distinctClause))
2748 return true;
2749 }
2750 else
2751 {
2752 /*
2753 * But we need to walk the expressions under WindowClause nodes even
2754 * if we're not interested in SortGroupClause nodes.
2755 */
2756 ListCell *lc;
2757
2758 foreach(lc, query->windowClause)
2759 {
2761
2762 if (WALK(wc->startOffset))
2763 return true;
2764 if (WALK(wc->endOffset))
2765 return true;
2766 }
2767 }
2768
2769 /*
2770 * groupingSets and rowMarks are not walked:
2771 *
2772 * groupingSets contain only ressortgrouprefs (integers) which are
2773 * meaningless without the corresponding groupClause or tlist.
2774 * Accordingly, any walker that needs to care about them needs to handle
2775 * them itself in its Query processing.
2776 *
2777 * rowMarks is not walked because it contains only rangetable indexes (and
2778 * flags etc.) and therefore should be handled at Query level similarly.
2779 */
2780
2781 if (!(flags & QTW_IGNORE_CTE_SUBQUERIES))
2782 {
2783 if (WALK(query->cteList))
2784 return true;
2785 }
2786 if (!(flags & QTW_IGNORE_RANGE_TABLE))
2787 {
2788 if (range_table_walker(query->rtable, walker, context, flags))
2789 return true;
2790 }
2791 return false;
2792}
#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, 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 
)

Definition at line 2821 of file nodeFuncs.c.

2825{
2826 /*
2827 * Walkers might need to examine the RTE node itself either before or
2828 * after visiting its contents (or, conceivably, both). Note that if you
2829 * specify neither flag, the walker won't be called on the RTE at all.
2830 */
2831 if (flags & QTW_EXAMINE_RTES_BEFORE)
2832 if (WALK(rte))
2833 return true;
2834
2835 switch (rte->rtekind)
2836 {
2837 case RTE_RELATION:
2838 if (WALK(rte->tablesample))
2839 return true;
2840 break;
2841 case RTE_SUBQUERY:
2842 if (!(flags & QTW_IGNORE_RT_SUBQUERIES))
2843 if (WALK(rte->subquery))
2844 return true;
2845 break;
2846 case RTE_JOIN:
2847 if (!(flags & QTW_IGNORE_JOINALIASES))
2848 if (WALK(rte->joinaliasvars))
2849 return true;
2850 break;
2851 case RTE_FUNCTION:
2852 if (WALK(rte->functions))
2853 return true;
2854 break;
2855 case RTE_TABLEFUNC:
2856 if (WALK(rte->tablefunc))
2857 return true;
2858 break;
2859 case RTE_VALUES:
2860 if (WALK(rte->values_lists))
2861 return true;
2862 break;
2863 case RTE_CTE:
2865 case RTE_RESULT:
2866 /* nothing to do */
2867 break;
2868 case RTE_GROUP:
2869 if (!(flags & QTW_IGNORE_GROUPEXPRS))
2870 if (WALK(rte->groupexprs))
2871 return true;
2872 break;
2873 }
2874
2875 if (WALK(rte->securityQuals))
2876 return true;
2877
2878 if (flags & QTW_EXAMINE_RTES_AFTER)
2879 if (WALK(rte))
2880 return true;
2881
2882 return false;
2883}
#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
Definition: parsenodes.h:1072
@ RTE_CTE
Definition: parsenodes.h:1076
@ RTE_NAMEDTUPLESTORE
Definition: parsenodes.h:1077
@ RTE_VALUES
Definition: parsenodes.h:1075
@ RTE_SUBQUERY
Definition: parsenodes.h:1071
@ RTE_RESULT
Definition: parsenodes.h:1078
@ RTE_FUNCTION
Definition: parsenodes.h:1073
@ RTE_TABLEFUNC
Definition: parsenodes.h:1074
@ RTE_GROUP
Definition: parsenodes.h:1081
@ RTE_RELATION
Definition: parsenodes.h:1070
TableFunc * tablefunc
Definition: parsenodes.h:1242
struct TableSampleClause * tablesample
Definition: parsenodes.h:1156
Query * subquery
Definition: parsenodes.h:1162
List * values_lists
Definition: parsenodes.h:1248
List * functions
Definition: parsenodes.h:1235
RTEKind rtekind
Definition: parsenodes.h:1105

References RangeTblEntry::functions, QTW_EXAMINE_RTES_AFTER, QTW_EXAMINE_RTES_BEFORE, QTW_IGNORE_GROUPEXPRS, QTW_IGNORE_JOINALIASES, QTW_IGNORE_RT_SUBQUERIES, RTE_CTE, RTE_FUNCTION, RTE_GROUP, RTE_JOIN, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_RESULT, RTE_SUBQUERY, RTE_TABLEFUNC, RTE_VALUES, RangeTblEntry::rtekind, RangeTblEntry::subquery, RangeTblEntry::tablefunc, RangeTblEntry::tablesample, RangeTblEntry::values_lists, and WALK.

◆ range_table_mutator_impl()

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

Definition at line 3867 of file nodeFuncs.c.

3871{
3872 List *newrt = NIL;
3873 ListCell *rt;
3874
3875 foreach(rt, rtable)
3876 {
3877 RangeTblEntry *rte = (RangeTblEntry *) lfirst(rt);
3878 RangeTblEntry *newrte;
3879
3880 FLATCOPY(newrte, rte, RangeTblEntry);
3881 switch (rte->rtekind)
3882 {
3883 case RTE_RELATION:
3884 MUTATE(newrte->tablesample, rte->tablesample,
3886 /* we don't bother to copy eref, aliases, etc; OK? */
3887 break;
3888 case RTE_SUBQUERY:
3889 if (!(flags & QTW_IGNORE_RT_SUBQUERIES))
3890 MUTATE(newrte->subquery, rte->subquery, Query *);
3891 else
3892 {
3893 /* else, copy RT subqueries as-is */
3894 newrte->subquery = copyObject(rte->subquery);
3895 }
3896 break;
3897 case RTE_JOIN:
3898 if (!(flags & QTW_IGNORE_JOINALIASES))
3899 MUTATE(newrte->joinaliasvars, rte->joinaliasvars, List *);
3900 else
3901 {
3902 /* else, copy join aliases as-is */
3903 newrte->joinaliasvars = copyObject(rte->joinaliasvars);
3904 }
3905 break;
3906 case RTE_FUNCTION:
3907 MUTATE(newrte->functions, rte->functions, List *);
3908 break;
3909 case RTE_TABLEFUNC:
3910 MUTATE(newrte->tablefunc, rte->tablefunc, TableFunc *);
3911 break;
3912 case RTE_VALUES:
3913 MUTATE(newrte->values_lists, rte->values_lists, List *);
3914 break;
3915 case RTE_CTE:
3917 case RTE_RESULT:
3918 /* nothing to do */
3919 break;
3920 case RTE_GROUP:
3921 if (!(flags & QTW_IGNORE_GROUPEXPRS))
3922 MUTATE(newrte->groupexprs, rte->groupexprs, List *);
3923 else
3924 {
3925 /* else, copy grouping exprs as-is */
3926 newrte->groupexprs = copyObject(rte->groupexprs);
3927 }
3928 break;
3929 }
3930 MUTATE(newrte->securityQuals, rte->securityQuals, List *);
3931 newrt = lappend(newrt, newrte);
3932 }
3933 return newrt;
3934}

References copyObject, FLATCOPY, RangeTblEntry::functions, lappend(), lfirst, MUTATE, NIL, QTW_IGNORE_GROUPEXPRS, QTW_IGNORE_JOINALIASES, QTW_IGNORE_RT_SUBQUERIES, RTE_CTE, RTE_FUNCTION, RTE_GROUP, RTE_JOIN, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_RESULT, RTE_SUBQUERY, RTE_TABLEFUNC, RTE_VALUES, RangeTblEntry::rtekind, RangeTblEntry::subquery, RangeTblEntry::tablefunc, RangeTblEntry::tablesample, and RangeTblEntry::values_lists.

◆ range_table_walker_impl()

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

Definition at line 2800 of file nodeFuncs.c.

2804{
2805 ListCell *rt;
2806
2807 foreach(rt, rtable)
2808 {
2810
2811 if (range_table_entry_walker(rte, walker, context, flags))
2812 return true;
2813 }
2814 return false;
2815}
#define range_table_entry_walker(r, w, c, f)
Definition: nodeFuncs.h:168

References 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 
)

Definition at line 3999 of file nodeFuncs.c.

4002{
4003 ListCell *temp;
4004
4005 /*
4006 * The walker has already visited the current node, and so we need only
4007 * recurse into any sub-nodes it has.
4008 */
4009 if (node == NULL)
4010 return false;
4011
4012 /* Guard against stack overflow due to overly complex expressions */
4014
4015 switch (nodeTag(node))
4016 {
4017 case T_JsonFormat:
4018 case T_SetToDefault:
4019 case T_CurrentOfExpr:
4020 case T_SQLValueFunction:
4021 case T_Integer:
4022 case T_Float:
4023 case T_Boolean:
4024 case T_String:
4025 case T_BitString:
4026 case T_ParamRef:
4027 case T_A_Const:
4028 case T_A_Star:
4029 case T_MergeSupportFunc:
4030 case T_ReturningOption:
4031 /* primitive node types with no subnodes */
4032 break;
4033 case T_Alias:
4034 /* we assume the colnames list isn't interesting */
4035 break;
4036 case T_RangeVar:
4037 return WALK(((RangeVar *) node)->alias);
4038 case T_GroupingFunc:
4039 return WALK(((GroupingFunc *) node)->args);
4040 case T_SubLink:
4041 {
4042 SubLink *sublink = (SubLink *) node;
4043
4044 if (WALK(sublink->testexpr))
4045 return true;
4046 /* we assume the operName is not interesting */
4047 if (WALK(sublink->subselect))
4048 return true;
4049 }
4050 break;
4051 case T_CaseExpr:
4052 {
4053 CaseExpr *caseexpr = (CaseExpr *) node;
4054
4055 if (WALK(caseexpr->arg))
4056 return true;
4057 /* we assume walker doesn't care about CaseWhens, either */
4058 foreach(temp, caseexpr->args)
4059 {
4061
4062 if (WALK(when->expr))
4063 return true;
4064 if (WALK(when->result))
4065 return true;
4066 }
4067 if (WALK(caseexpr->defresult))
4068 return true;
4069 }
4070 break;
4071 case T_RowExpr:
4072 /* Assume colnames isn't interesting */
4073 return WALK(((RowExpr *) node)->args);
4074 case T_CoalesceExpr:
4075 return WALK(((CoalesceExpr *) node)->args);
4076 case T_MinMaxExpr:
4077 return WALK(((MinMaxExpr *) node)->args);
4078 case T_XmlExpr:
4079 {
4080 XmlExpr *xexpr = (XmlExpr *) node;
4081
4082 if (WALK(xexpr->named_args))
4083 return true;
4084 /* we assume walker doesn't care about arg_names */
4085 if (WALK(xexpr->args))
4086 return true;
4087 }
4088 break;
4089 case T_JsonReturning:
4090 return WALK(((JsonReturning *) node)->format);
4091 case T_JsonValueExpr:
4092 {
4093 JsonValueExpr *jve = (JsonValueExpr *) node;
4094
4095 if (WALK(jve->raw_expr))
4096 return true;
4097 if (WALK(jve->formatted_expr))
4098 return true;
4099 if (WALK(jve->format))
4100 return true;
4101 }
4102 break;
4103 case T_JsonParseExpr:
4104 {
4105 JsonParseExpr *jpe = (JsonParseExpr *) node;
4106
4107 if (WALK(jpe->expr))
4108 return true;
4109 if (WALK(jpe->output))
4110 return true;
4111 }
4112 break;
4113 case T_JsonScalarExpr:
4114 {
4115 JsonScalarExpr *jse = (JsonScalarExpr *) node;
4116
4117 if (WALK(jse->expr))
4118 return true;
4119 if (WALK(jse->output))
4120 return true;
4121 }
4122 break;
4123 case T_JsonSerializeExpr:
4124 {
4125 JsonSerializeExpr *jse = (JsonSerializeExpr *) node;
4126
4127 if (WALK(jse->expr))
4128 return true;
4129 if (WALK(jse->output))
4130 return true;
4131 }
4132 break;
4133 case T_JsonConstructorExpr:
4134 {
4136
4137 if (WALK(ctor->args))
4138 return true;
4139 if (WALK(ctor->func))
4140 return true;
4141 if (WALK(ctor->coercion))
4142 return true;
4143 if (WALK(ctor->returning))
4144 return true;
4145 }
4146 break;
4147 case T_JsonIsPredicate:
4148 return WALK(((JsonIsPredicate *) node)->expr);
4149 case T_JsonArgument:
4150 return WALK(((JsonArgument *) node)->val);
4151 case T_JsonFuncExpr:
4152 {
4153 JsonFuncExpr *jfe = (JsonFuncExpr *) node;
4154
4155 if (WALK(jfe->context_item))
4156 return true;
4157 if (WALK(jfe->pathspec))
4158 return true;
4159 if (WALK(jfe->passing))
4160 return true;
4161 if (WALK(jfe->output))
4162 return true;
4163 if (WALK(jfe->on_empty))
4164 return true;
4165 if (WALK(jfe->on_error))
4166 return true;
4167 }
4168 break;
4169 case T_JsonBehavior:
4170 {
4171 JsonBehavior *jb = (JsonBehavior *) node;
4172
4173 if (WALK(jb->expr))
4174 return true;
4175 }
4176 break;
4177 case T_JsonTable:
4178 {
4179 JsonTable *jt = (JsonTable *) node;
4180
4181 if (WALK(jt->context_item))
4182 return true;
4183 if (WALK(jt->pathspec))
4184 return true;
4185 if (WALK(jt->passing))
4186 return true;
4187 if (WALK(jt->columns))
4188 return true;
4189 if (WALK(jt->on_error))
4190 return true;
4191 }
4192 break;
4193 case T_JsonTableColumn:
4194 {
4195 JsonTableColumn *jtc = (JsonTableColumn *) node;
4196
4197 if (WALK(jtc->typeName))
4198 return true;
4199 if (WALK(jtc->on_empty))
4200 return true;
4201 if (WALK(jtc->on_error))
4202 return true;
4203 if (WALK(jtc->columns))
4204 return true;
4205 }
4206 break;
4207 case T_JsonTablePathSpec:
4208 return WALK(((JsonTablePathSpec *) node)->string);
4209 case T_NullTest:
4210 return WALK(((NullTest *) node)->arg);
4211 case T_BooleanTest:
4212 return WALK(((BooleanTest *) node)->arg);
4213 case T_JoinExpr:
4214 {
4215 JoinExpr *join = (JoinExpr *) node;
4216
4217 if (WALK(join->larg))
4218 return true;
4219 if (WALK(join->rarg))
4220 return true;
4221 if (WALK(join->quals))
4222 return true;
4223 if (WALK(join->alias))
4224 return true;
4225 /* using list is deemed uninteresting */
4226 }
4227 break;
4228 case T_IntoClause:
4229 {
4230 IntoClause *into = (IntoClause *) node;
4231
4232 if (WALK(into->rel))
4233 return true;
4234 /* colNames, options are deemed uninteresting */
4235 /* viewQuery should be null in raw parsetree, but check it */
4236 if (WALK(into->viewQuery))
4237 return true;
4238 }
4239 break;
4240 case T_List:
4241 foreach(temp, (List *) node)
4242 {
4243 if (WALK((Node *) lfirst(temp)))
4244 return true;
4245 }
4246 break;
4247 case T_InsertStmt:
4248 {
4249 InsertStmt *stmt = (InsertStmt *) node;
4250
4251 if (WALK(stmt->relation))
4252 return true;
4253 if (WALK(stmt->cols))
4254 return true;
4255 if (WALK(stmt->selectStmt))
4256 return true;
4257 if (WALK(stmt->onConflictClause))
4258 return true;
4259 if (WALK(stmt->returningClause))
4260 return true;
4261 if (WALK(stmt->withClause))
4262 return true;
4263 }
4264 break;
4265 case T_DeleteStmt:
4266 {
4267 DeleteStmt *stmt = (DeleteStmt *) node;
4268
4269 if (WALK(stmt->relation))
4270 return true;
4271 if (WALK(stmt->usingClause))
4272 return true;
4273 if (WALK(stmt->whereClause))
4274 return true;
4275 if (WALK(stmt->returningClause))
4276 return true;
4277 if (WALK(stmt->withClause))
4278 return true;
4279 }
4280 break;
4281 case T_UpdateStmt:
4282 {
4283 UpdateStmt *stmt = (UpdateStmt *) node;
4284
4285 if (WALK(stmt->relation))
4286 return true;
4287 if (WALK(stmt->targetList))
4288 return true;
4289 if (WALK(stmt->whereClause))
4290 return true;
4291 if (WALK(stmt->fromClause))
4292 return true;
4293 if (WALK(stmt->returningClause))
4294 return true;
4295 if (WALK(stmt->withClause))
4296 return true;
4297 }
4298 break;
4299 case T_MergeStmt:
4300 {
4301 MergeStmt *stmt = (MergeStmt *) node;
4302
4303 if (WALK(stmt->relation))
4304 return true;
4305 if (WALK(stmt->sourceRelation))
4306 return true;
4307 if (WALK(stmt->joinCondition))
4308 return true;
4309 if (WALK(stmt->mergeWhenClauses))
4310 return true;
4311 if (WALK(stmt->returningClause))
4312 return true;
4313 if (WALK(stmt->withClause))
4314 return true;
4315 }
4316 break;
4317 case T_MergeWhenClause:
4318 {
4319 MergeWhenClause *mergeWhenClause = (MergeWhenClause *) node;
4320
4321 if (WALK(mergeWhenClause->condition))
4322 return true;
4323 if (WALK(mergeWhenClause->targetList))
4324 return true;
4325 if (WALK(mergeWhenClause->values))
4326 return true;
4327 }
4328 break;
4329 case T_ReturningClause:
4330 {
4331 ReturningClause *returning = (ReturningClause *) node;
4332
4333 if (WALK(returning->options))
4334 return true;
4335 if (WALK(returning->exprs))
4336 return true;
4337 }
4338 break;
4339 case T_SelectStmt:
4340 {
4341 SelectStmt *stmt = (SelectStmt *) node;
4342
4343 if (WALK(stmt->distinctClause))
4344 return true;
4345 if (WALK(stmt->intoClause))
4346 return true;
4347 if (WALK(stmt->targetList))
4348 return true;
4349 if (WALK(stmt->fromClause))
4350 return true;
4351 if (WALK(stmt->whereClause))
4352 return true;
4353 if (WALK(stmt->groupClause))
4354 return true;
4355 if (WALK(stmt->havingClause))
4356 return true;
4357 if (WALK(stmt->windowClause))
4358 return true;
4359 if (WALK(stmt->valuesLists))
4360 return true;
4361 if (WALK(stmt->sortClause))
4362 return true;
4363 if (WALK(stmt->limitOffset))
4364 return true;
4365 if (WALK(stmt->limitCount))
4366 return true;
4367 if (WALK(stmt->lockingClause))
4368 return true;
4369 if (WALK(stmt->withClause))
4370 return true;
4371 if (WALK(stmt->larg))
4372 return true;
4373 if (WALK(stmt->rarg))
4374 return true;
4375 }
4376 break;
4377 case T_PLAssignStmt:
4378 {
4379 PLAssignStmt *stmt = (PLAssignStmt *) node;
4380
4381 if (WALK(stmt->indirection))
4382 return true;
4383 if (WALK(stmt->val))
4384 return true;
4385 }
4386 break;
4387 case T_A_Expr:
4388 {
4389 A_Expr *expr = (A_Expr *) node;
4390
4391 if (WALK(expr->lexpr))
4392 return true;
4393 if (WALK(expr->rexpr))
4394 return true;
4395 /* operator name is deemed uninteresting */
4396 }
4397 break;
4398 case T_BoolExpr:
4399 {
4400 BoolExpr *expr = (BoolExpr *) node;
4401
4402 if (WALK(expr->args))
4403 return true;
4404 }
4405 break;
4406 case T_ColumnRef:
4407 /* we assume the fields contain nothing interesting */
4408 break;
4409 case T_FuncCall:
4410 {
4411 FuncCall *fcall = (FuncCall *) node;
4412
4413 if (WALK(fcall->args))
4414 return true;
4415 if (WALK(fcall->agg_order))
4416 return true;
4417 if (WALK(fcall->agg_filter))
4418 return true;
4419 if (WALK(fcall->over))
4420 return true;
4421 /* function name is deemed uninteresting */
4422 }
4423 break;
4424 case T_NamedArgExpr:
4425 return WALK(((NamedArgExpr *) node)->arg);
4426 case T_A_Indices:
4427 {
4428 A_Indices *indices = (A_Indices *) node;
4429
4430 if (WALK(indices->lidx))
4431 return true;
4432 if (WALK(indices->uidx))
4433 return true;
4434 }
4435 break;
4436 case T_A_Indirection:
4437 {
4438 A_Indirection *indir = (A_Indirection *) node;
4439
4440 if (WALK(indir->arg))
4441 return true;
4442 if (WALK(indir->indirection))
4443 return true;
4444 }
4445 break;
4446 case T_A_ArrayExpr:
4447 return WALK(((A_ArrayExpr *) node)->elements);
4448 case T_ResTarget:
4449 {
4450 ResTarget *rt = (ResTarget *) node;
4451
4452 if (WALK(rt->indirection))
4453 return true;
4454 if (WALK(rt->val))
4455 return true;
4456 }
4457 break;
4458 case T_MultiAssignRef:
4459 return WALK(((MultiAssignRef *) node)->source);
4460 case T_TypeCast:
4461 {
4462 TypeCast *tc = (TypeCast *) node;
4463
4464 if (WALK(tc->arg))
4465 return true;
4466 if (WALK(tc->typeName))
4467 return true;
4468 }
4469 break;
4470 case T_CollateClause:
4471 return WALK(((CollateClause *) node)->arg);
4472 case T_SortBy:
4473 return WALK(((SortBy *) node)->node);
4474 case T_WindowDef:
4475 {
4476 WindowDef *wd = (WindowDef *) node;
4477
4478 if (WALK(wd->partitionClause))
4479 return true;
4480 if (WALK(wd->orderClause))
4481 return true;
4482 if (WALK(wd->startOffset))
4483 return true;
4484 if (WALK(wd->endOffset))
4485 return true;
4486 }
4487 break;
4488 case T_RangeSubselect:
4489 {
4490 RangeSubselect *rs = (RangeSubselect *) node;
4491
4492 if (WALK(rs->subquery))
4493 return true;
4494 if (WALK(rs->alias))
4495 return true;
4496 }
4497 break;
4498 case T_RangeFunction:
4499 {
4500 RangeFunction *rf = (RangeFunction *) node;
4501
4502 if (WALK(rf->functions))
4503 return true;
4504 if (WALK(rf->alias))
4505 return true;
4506 if (WALK(rf->coldeflist))
4507 return true;
4508 }
4509 break;
4510 case T_RangeTableSample:
4511 {
4512 RangeTableSample *rts = (RangeTableSample *) node;
4513
4514 if (WALK(rts->relation))
4515 return true;
4516 /* method name is deemed uninteresting */
4517 if (WALK(rts->args))
4518 return true;
4519 if (WALK(rts->repeatable))
4520 return true;
4521 }
4522 break;
4523 case T_RangeTableFunc:
4524 {
4525 RangeTableFunc *rtf = (RangeTableFunc *) node;
4526
4527 if (WALK(rtf->docexpr))
4528 return true;
4529 if (WALK(rtf->rowexpr))
4530 return true;
4531 if (WALK(rtf->namespaces))
4532 return true;
4533 if (WALK(rtf->columns))
4534 return true;
4535 if (WALK(rtf->alias))
4536 return true;
4537 }
4538 break;
4539 case T_RangeTableFuncCol:
4540 {
4541 RangeTableFuncCol *rtfc = (RangeTableFuncCol *) node;
4542
4543 if (WALK(rtfc->colexpr))
4544 return true;
4545 if (WALK(rtfc->coldefexpr))
4546 return true;
4547 }
4548 break;
4549 case T_TypeName:
4550 {
4551 TypeName *tn = (TypeName *) node;
4552
4553 if (WALK(tn->typmods))
4554 return true;
4555 if (WALK(tn->arrayBounds))
4556 return true;
4557 /* type name itself is deemed uninteresting */
4558 }
4559 break;
4560 case T_ColumnDef:
4561 {
4562 ColumnDef *coldef = (ColumnDef *) node;
4563
4564 if (WALK(coldef->typeName))
4565 return true;
4566 if (WALK(coldef->raw_default))
4567 return true;
4568 if (WALK(coldef->collClause))
4569 return true;
4570 /* for now, constraints are ignored */
4571 }
4572 break;
4573 case T_IndexElem:
4574 {
4575 IndexElem *indelem = (IndexElem *) node;
4576
4577 if (WALK(indelem->expr))
4578 return true;
4579 /* collation and opclass names are deemed uninteresting */
4580 }
4581 break;
4582 case T_GroupingSet:
4583 return WALK(((GroupingSet *) node)->content);
4584 case T_LockingClause:
4585 return WALK(((LockingClause *) node)->lockedRels);
4586 case T_XmlSerialize:
4587 {
4588 XmlSerialize *xs = (XmlSerialize *) node;
4589
4590 if (WALK(xs->expr))
4591 return true;
4592 if (WALK(xs->typeName))
4593 return true;
4594 }
4595 break;
4596 case T_WithClause:
4597 return WALK(((WithClause *) node)->ctes);
4598 case T_InferClause:
4599 {
4600 InferClause *stmt = (InferClause *) node;
4601
4602 if (WALK(stmt->indexElems))
4603 return true;
4604 if (WALK(stmt->whereClause))
4605 return true;
4606 }
4607 break;
4608 case T_OnConflictClause:
4609 {
4611
4612 if (WALK(stmt->infer))
4613 return true;
4614 if (WALK(stmt->targetList))
4615 return true;
4616 if (WALK(stmt->whereClause))
4617 return true;
4618 }
4619 break;
4620 case T_CommonTableExpr:
4621 /* search_clause and cycle_clause are not interesting here */
4622 return WALK(((CommonTableExpr *) node)->ctequery);
4623 case T_JsonOutput:
4624 {
4625 JsonOutput *out = (JsonOutput *) node;
4626
4627 if (WALK(out->typeName))
4628 return true;
4629 if (WALK(out->returning))
4630 return true;
4631 }
4632 break;
4633 case T_JsonKeyValue:
4634 {
4635 JsonKeyValue *jkv = (JsonKeyValue *) node;
4636
4637 if (WALK(jkv->key))
4638 return true;
4639 if (WALK(jkv->value))
4640 return true;
4641 }
4642 break;
4643 case T_JsonObjectConstructor:
4644 {
4646
4647 if (WALK(joc->output))
4648 return true;
4649 if (WALK(joc->exprs))
4650 return true;
4651 }
4652 break;
4653 case T_JsonArrayConstructor:
4654 {
4656
4657 if (WALK(jac->output))
4658 return true;
4659 if (WALK(jac->exprs))
4660 return true;
4661 }
4662 break;
4663 case T_JsonAggConstructor:
4664 {
4665 JsonAggConstructor *ctor = (JsonAggConstructor *) node;
4666
4667 if (WALK(ctor->output))
4668 return true;
4669 if (WALK(ctor->agg_order))
4670 return true;
4671 if (WALK(ctor->agg_filter))
4672 return true;
4673 if (WALK(ctor->over))
4674 return true;
4675 }
4676 break;
4677 case T_JsonObjectAgg:
4678 {
4679 JsonObjectAgg *joa = (JsonObjectAgg *) node;
4680
4681 if (WALK(joa->constructor))
4682 return true;
4683 if (WALK(joa->arg))
4684 return true;
4685 }
4686 break;
4687 case T_JsonArrayAgg:
4688 {
4689 JsonArrayAgg *jaa = (JsonArrayAgg *) node;
4690
4691 if (WALK(jaa->constructor))
4692 return true;
4693 if (WALK(jaa->arg))
4694 return true;
4695 }
4696 break;
4697 case T_JsonArrayQueryConstructor:
4698 {
4700
4701 if (WALK(jaqc->output))
4702 return true;
4703 if (WALK(jaqc->query))
4704 return true;
4705 }
4706 break;
4707 default:
4708 elog(ERROR, "unrecognized node type: %d",
4709 (int) nodeTag(node));
4710 break;
4711 }
4712 return false;
4713}
#define stmt
Definition: indent_codes.h:59
long val
Definition: informix.c:689
static char format
Node * rexpr
Definition: parsenodes.h:354
Node * uidx
Definition: parsenodes.h:487
Node * lidx
Definition: parsenodes.h:486
List * indirection
Definition: parsenodes.h:509
CollateClause * collClause
Definition: parsenodes.h:769
TypeName * typeName
Definition: parsenodes.h:755
Node * raw_default
Definition: parsenodes.h:763
Node * agg_filter
Definition: parsenodes.h:454
List * agg_order
Definition: parsenodes.h:453
List * args
Definition: parsenodes.h:452
struct WindowDef * over
Definition: parsenodes.h:455
Node * expr
Definition: parsenodes.h:812
RangeVar * rel
Definition: primnodes.h:163
JsonOutput * output
Definition: parsenodes.h:2058
JsonOutput * output
Definition: parsenodes.h:2031
JsonOutput * output
Definition: parsenodes.h:1887
List * passing
Definition: parsenodes.h:1886
JsonBehavior * on_empty
Definition: parsenodes.h:1888
Node * pathspec
Definition: parsenodes.h:1885
JsonBehavior * on_error
Definition: parsenodes.h:1889
JsonValueExpr * context_item
Definition: parsenodes.h:1884
JsonOutput * output
Definition: parsenodes.h:2017
JsonReturning * returning
Definition: parsenodes.h:1848
TypeName * typeName
Definition: parsenodes.h:1847
JsonValueExpr * expr
Definition: parsenodes.h:1979
JsonOutput * output
Definition: parsenodes.h:1980
JsonOutput * output
Definition: parsenodes.h:1993
JsonOutput * output
Definition: parsenodes.h:2005
JsonValueExpr * expr
Definition: parsenodes.h:2004
JsonBehavior * on_empty
Definition: parsenodes.h:1955
JsonBehavior * on_error
Definition: parsenodes.h:1956
TypeName * typeName
Definition: parsenodes.h:1949
JsonBehavior * on_error
Definition: parsenodes.h:1921
List * columns
Definition: parsenodes.h:1920
JsonTablePathSpec * pathspec
Definition: parsenodes.h:1918
List * passing
Definition: parsenodes.h:1919
JsonValueExpr * context_item
Definition: parsenodes.h:1917
Alias * alias
Definition: parsenodes.h:672
List * coldeflist
Definition: parsenodes.h:673
List * functions
Definition: parsenodes.h:671
Node * subquery
Definition: parsenodes.h:647
Alias * alias
Definition: parsenodes.h:648
List * namespaces
Definition: parsenodes.h:689
Node * docexpr
Definition: parsenodes.h:687
Node * rowexpr
Definition: parsenodes.h:688
List * columns
Definition: parsenodes.h:690
Alias * alias
Definition: parsenodes.h:691
Node * val
Definition: parsenodes.h:547
List * indirection
Definition: parsenodes.h:546
List * arrayBounds
Definition: parsenodes.h:291
List * typmods
Definition: parsenodes.h:289
List * orderClause
Definition: parsenodes.h:595
List * partitionClause
Definition: parsenodes.h:594
Node * startOffset
Definition: parsenodes.h:597
Node * endOffset
Definition: parsenodes.h:598
TypeName * typeName
Definition: parsenodes.h:876
Node * expr
Definition: parsenodes.h:875

References FuncCall::agg_filter, JsonAggConstructor::agg_filter, FuncCall::agg_order, JsonAggConstructor::agg_order, RangeSubselect::alias, RangeFunction::alias, RangeTableFunc::alias, arg, TypeCast::arg, A_Indirection::arg, JsonObjectAgg::arg, JsonArrayAgg::arg, CaseExpr::arg, generate_unaccent_rules::args, FuncCall::args, RangeTableSample::args, BoolExpr::args, CaseExpr::args, XmlExpr::args, JsonConstructorExpr::args, TypeName::arrayBounds, check_stack_depth(), JsonConstructorExpr::coercion, RangeTableFuncCol::coldefexpr, RangeFunction::coldeflist, RangeTableFuncCol::colexpr, ColumnDef::collClause, RangeTableFunc::columns, JsonTable::columns, JsonTableColumn::columns, MergeWhenClause::condition, JsonObjectAgg::constructor, JsonArrayAgg::constructor, JsonFuncExpr::context_item, JsonTable::context_item, CaseExpr::defresult, RangeTableFunc::docexpr, elog, WindowDef::endOffset, ERROR, IndexElem::expr, XmlSerialize::expr, JsonParseExpr::expr, JsonScalarExpr::expr, JsonSerializeExpr::expr, JsonBehavior::expr, ReturningClause::exprs, JsonObjectConstructor::exprs, JsonArrayConstructor::exprs, format, JsonValueExpr::format, JsonValueExpr::formatted_expr, JsonConstructorExpr::func, RangeFunction::functions, A_Indirection::indirection, ResTarget::indirection, JsonKeyValue::key, JoinExpr::larg, A_Expr::lexpr, lfirst, lfirst_node, A_Indices::lidx, XmlExpr::named_args, RangeTableFunc::namespaces, nodeTag, JsonFuncExpr::on_empty, JsonTableColumn::on_empty, JsonFuncExpr::on_error, JsonTable::on_error, JsonTableColumn::on_error, ReturningClause::options, WindowDef::orderClause, JsonFuncExpr::output, JsonParseExpr::output, JsonScalarExpr::output, JsonSerializeExpr::output, JsonObjectConstructor::output, JsonArrayConstructor::output, JsonArrayQueryConstructor::output, JsonAggConstructor::output, FuncCall::over, JsonAggConstructor::over, WindowDef::partitionClause, JsonFuncExpr::passing, JsonTable::passing, JsonFuncExpr::pathspec, JsonTable::pathspec, JoinExpr::quals, JsonArrayQueryConstructor::query, JoinExpr::rarg, ColumnDef::raw_default, JsonValueExpr::raw_expr, IntoClause::rel, RangeTableSample::relation, RangeTableSample::repeatable, JsonOutput::returning, JsonConstructorExpr::returning, A_Expr::rexpr, RangeTableFunc::rowexpr, source, WindowDef::startOffset, stmt, RangeSubselect::subquery, SubLink::subselect, MergeWhenClause::targetList, SubLink::testexpr, TypeCast::typeName, ColumnDef::typeName, XmlSerialize::typeName, JsonOutput::typeName, JsonTableColumn::typeName, TypeName::typmods, A_Indices::uidx, ResTarget::val, val, JsonKeyValue::value, MergeWhenClause::values, and WALK.

◆ relabel_to_typmod()

Node * relabel_to_typmod ( Node expr,
int32  typmod 
)

Definition at line 689 of file nodeFuncs.c.

690{
691 return applyRelabelType(expr, exprType(expr), typmod, exprCollation(expr),
692 COERCE_EXPLICIT_CAST, -1, false);
693}
Node * applyRelabelType(Node *arg, Oid rtype, int32 rtypmod, Oid rcollid, CoercionForm rformat, int rlocation, bool overwrite_ok)
Definition: nodeFuncs.c:636

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)

Definition at line 1882 of file nodeFuncs.c.

1883{
1884 if (opexpr->opfuncid == InvalidOid)
1885 opexpr->opfuncid = get_opcode(opexpr->opno);
1886}

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)

Definition at line 705 of file nodeFuncs.c.

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

References RelabelType::arg, FuncExpr::args, COERCE_IMPLICIT_CAST, 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().