33 bool (*walker) (),
void *context);
51 type = ((
const Var *) expr)->vartype;
54 type = ((
const Const *) expr)->consttype;
57 type = ((
const Param *) expr)->paramtype;
60 type = ((
const Aggref *) expr)->aggtype;
80 type = ((
const FuncExpr *) expr)->funcresulttype;
86 type = ((
const OpExpr *) expr)->opresulttype;
92 type = ((
const NullIfExpr *) expr)->opresulttype;
112 elog(
ERROR,
"cannot get type for untransformed sublink");
122 (
errcode(ERRCODE_UNDEFINED_OBJECT),
123 errmsg(
"could not find array type for data type %s",
153 (
errcode(ERRCODE_UNDEFINED_OBJECT),
154 errmsg(
"could not find array type for data type %s",
182 type = ((
const FieldStore *) expr)->resulttype;
200 type = ((
const CaseExpr *) expr)->casetype;
206 type = ((
const ArrayExpr *) expr)->array_typeid;
209 type = ((
const RowExpr *) expr)->row_typeid;
218 type = ((
const MinMaxExpr *) expr)->minmaxtype;
278 return ((
const Var *) expr)->vartypmod;
280 return ((
const Const *) expr)->consttypmod;
282 return ((
const Param *) expr)->paramtypmod;
285 return ((
const ArrayRef *) expr)->reftypmod;
292 return coercedTypmod;
320 elog(
ERROR,
"cannot get type for untransformed sublink");
378 foreach(arg, cexpr->
args)
509 if (coercedTypmod !=
NULL)
535 if (nargs < 2 || nargs > 3)
547 if (coercedTypmod !=
NULL)
564 if (coercedTypmod !=
NULL)
750 coll = ((
const Var *) expr)->varcollid;
753 coll = ((
const Const *) expr)->constcollid;
756 coll = ((
const Param *) expr)->paramcollid;
759 coll = ((
const Aggref *) expr)->aggcollid;
765 coll = ((
const WindowFunc *) expr)->wincollid;
768 coll = ((
const ArrayRef *) expr)->refcollid;
771 coll = ((
const FuncExpr *) expr)->funccollid;
777 coll = ((
const OpExpr *) expr)->opcollid;
803 elog(
ERROR,
"cannot get collation for untransformed sublink");
865 coll = ((
const CaseExpr *) expr)->casecollid;
871 coll = ((
const ArrayExpr *) expr)->array_collid;
883 coll = ((
const MinMaxExpr *) expr)->minmaxcollid;
946 coll = ((
const Aggref *) expr)->inputcollid;
949 coll = ((
const WindowFunc *) expr)->inputcollid;
952 coll = ((
const FuncExpr *) expr)->inputcollid;
955 coll = ((
const OpExpr *) expr)->inputcollid;
961 coll = ((
const NullIfExpr *) expr)->inputcollid;
967 coll = ((
const MinMaxExpr *) expr)->inputcollid;
989 ((
Var *) expr)->varcollid = collation;
992 ((
Const *) expr)->constcollid = collation;
995 ((
Param *) expr)->paramcollid = collation;
998 ((
Aggref *) expr)->aggcollid = collation;
1004 ((
WindowFunc *) expr)->wincollid = collation;
1007 ((
ArrayRef *) expr)->refcollid = collation;
1010 ((
FuncExpr *) expr)->funccollid = collation;
1016 ((
OpExpr *) expr)->opcollid = collation;
1031 #ifdef USE_ASSERT_CHECKING
1043 elog(
ERROR,
"cannot set collation for untransformed sublink");
1076 ((
CaseExpr *) expr)->casecollid = collation;
1079 ((
ArrayExpr *) expr)->array_collid = collation;
1091 ((
MinMaxExpr *) expr)->minmaxcollid = collation;
1136 ((
Aggref *) expr)->inputcollid = inputcollation;
1139 ((
WindowFunc *) expr)->inputcollid = inputcollation;
1142 ((
FuncExpr *) expr)->inputcollid = inputcollation;
1145 ((
OpExpr *) expr)->inputcollid = inputcollation;
1151 ((
NullIfExpr *) expr)->inputcollid = inputcollation;
1157 ((
MinMaxExpr *) expr)->inputcollid = inputcollation;
1204 loc = ((
const RangeVar *) expr)->location;
1207 loc = ((
const Var *) expr)->location;
1210 loc = ((
const Const *) expr)->location;
1213 loc = ((
const Param *) expr)->location;
1217 loc = ((
const Aggref *) expr)->location;
1340 loc = ((
const CaseExpr *) expr)->location;
1344 loc = ((
const CaseWhen *) expr)->location;
1348 loc = ((
const ArrayExpr *) expr)->location;
1352 loc = ((
const RowExpr *) expr)->location;
1422 foreach(lc, (
const List *) expr)
1441 loc = ((
const ColumnRef *) expr)->location;
1444 loc = ((
const ParamRef *) expr)->location;
1447 loc = ((
const A_Const *) expr)->location;
1465 loc = ((
const ResTarget *) expr)->location;
1492 loc = ((
const WindowDef *) expr)->location;
1498 loc = ((
const TypeName *) expr)->location;
1501 loc = ((
const ColumnDef *) expr)->location;
1558 return Min(loc1, loc2);
1744 if (walker(aref->
refexpr, context))
1794 if (walker(sublink->
testexpr, context))
1801 return walker(sublink->
subselect, context);
1809 if (walker(subplan->
testexpr, context))
1825 if (walker(fstore->
arg, context))
1827 if (walker(fstore->
newvals, context))
1845 if (walker(caseexpr->
arg, context))
1848 foreach(temp, caseexpr->
args)
1853 if (walker(when->
expr, context))
1855 if (walker(when->
result, context))
1858 if (walker(caseexpr->
defresult, context))
1863 return walker(((
ArrayExpr *) node)->elements, context);
1866 return walker(((
RowExpr *) node)->args, context);
1871 if (walker(rcexpr->
largs, context))
1873 if (walker(rcexpr->
rargs, context))
1880 return walker(((
MinMaxExpr *) node)->args, context);
1888 if (walker(xexpr->
args, context))
1899 return walker(((
TargetEntry *) node)->expr, context);
1925 return walker(cte->
ctequery, context);
1929 foreach(temp, (
List *) node)
1939 if (walker(from->
fromlist, context))
1941 if (walker(from->
quals, context))
1965 if (walker(join->
larg, context))
1967 if (walker(join->
rarg, context))
1969 if (walker(join->
quals, context))
1981 if (walker(setop->
larg, context))
1983 if (walker(setop->
rarg, context))
2018 elog(
ERROR,
"unrecognized node type: %d",
2098 if (walker(rte, context))
2112 if (walker(rte->
subquery, context))
2201 Node *(*mutator) (),
2209 #define FLATCOPY(newnode, node, nodetype) \
2210 ( (newnode) = (nodetype *) palloc(sizeof(nodetype)), \
2211 memcpy((newnode), (node), sizeof(nodetype)) )
2213 #define CHECKFLATCOPY(newnode, node, nodetype) \
2214 ( AssertMacro(IsA((node), nodetype)), \
2215 (newnode) = (nodetype *) palloc(sizeof(nodetype)), \
2216 memcpy((newnode), (node), sizeof(nodetype)) )
2218 #define MUTATE(newfield, oldfield, fieldtype) \
2219 ( (newfield) = (fieldtype) mutator((Node *) (oldfield), context) )
2240 return (
Node *) newnode;
2250 return (
Node *) newnode;
2268 return (
Node *) newnode;
2281 return (
Node *) newnode;
2304 return (
Node *) newnode;
2315 return (
Node *) newnode;
2332 return (
Node *) newnode;
2342 return (
Node *) newnode;
2352 return (
Node *) newnode;
2362 return (
Node *) newnode;
2372 return (
Node *) newnode;
2382 return (
Node *) newnode;
2392 return (
Node *) newnode;
2402 return (
Node *) newnode;
2418 return (
Node *) newnode;
2432 return (
Node *) newnode;
2442 return (
Node *) newnode;
2452 return (
Node *) newnode;
2464 return (
Node *) newnode;
2474 return (
Node *) newnode;
2484 return (
Node *) newnode;
2494 return (
Node *) newnode;
2504 return (
Node *) newnode;
2514 return (
Node *) newnode;
2526 return (
Node *) newnode;
2537 return (
Node *) newnode;
2547 return (
Node *) newnode;
2558 return (
Node *) newnode;
2569 return (
Node *) newnode;
2579 return (
Node *) newnode;
2589 return (
Node *) newnode;
2601 return (
Node *) newnode;
2611 return (
Node *) newnode;
2621 return (
Node *) newnode;
2631 return (
Node *) newnode;
2641 return (
Node *) newnode;
2657 return (
Node *) newnode;
2672 return (
Node *) newnode;
2686 foreach(temp, (
List *) node)
2688 resultlist =
lappend(resultlist,
2692 return (
Node *) resultlist;
2703 return (
Node *) newnode;
2718 return (
Node *) newnode;
2731 return (
Node *) newnode;
2743 return (
Node *) newnode;
2754 return (
Node *) newnode;
2764 return (
Node *) newnode;
2774 return (
Node *) newnode;
2785 return (
Node *) newnode;
2796 return (
Node *) newnode;
2807 return (
Node *) newnode;
2811 elog(
ERROR,
"unrecognized node type: %d",
2841 Node *(*mutator) (),
2869 mutator, context, flags);
2880 Node *(*mutator) (),
2932 newrt =
lappend(newrt, newrte);
2957 return walker(node, context);
2970 Node *(*mutator) (),
2980 return mutator(node, context);
3032 return walker(((
RangeVar *) node)->alias, context);
3039 if (walker(sublink->
testexpr, context))
3042 if (walker(sublink->
subselect, context))
3050 if (walker(caseexpr->
arg, context))
3053 foreach(temp, caseexpr->
args)
3058 if (walker(when->
expr, context))
3060 if (walker(when->
result, context))
3063 if (walker(caseexpr->
defresult, context))
3069 return walker(((
RowExpr *) node)->args, context);
3073 return walker(((
MinMaxExpr *) node)->args, context);
3081 if (walker(xexpr->
args, context))
3093 if (walker(join->
larg, context))
3095 if (walker(join->
rarg, context))
3097 if (walker(join->
quals, context))
3099 if (walker(join->
alias, context))
3108 if (walker(into->
rel, context))
3117 foreach(temp, (
List *) node)
3127 if (walker(stmt->
relation, context))
3129 if (walker(stmt->
cols, context))
3145 if (walker(stmt->
relation, context))
3161 if (walker(stmt->
relation, context))
3207 if (walker(stmt->
larg, context))
3209 if (walker(stmt->
rarg, context))
3217 if (walker(expr->
lexpr, context))
3219 if (walker(expr->
rexpr, context))
3228 if (walker(expr->
args, context))
3239 if (walker(fcall->
args, context))
3245 if (walker(fcall->
over, context))
3256 if (walker(indices->
lidx, context))
3258 if (walker(indices->
uidx, context))
3266 if (walker(indir->
arg, context))
3273 return walker(((
A_ArrayExpr *) node)->elements, context);
3280 if (walker(rt->
val, context))
3290 if (walker(tc->
arg, context))
3299 return walker(((
SortBy *) node)->node, context);
3320 if (walker(rs->
alias, context))
3330 if (walker(rf->
alias, context))
3340 if (walker(rts->
relation, context))
3343 if (walker(rts->
args, context))
3353 if (walker(tn->
typmods, context))
3364 if (walker(coldef->
typeName, context))
3374 return walker(((
GroupingSet *) node)->content, context);
3376 return walker(((
LockingClause *) node)->lockedRels, context);
3381 if (walker(xs->
expr, context))
3388 return walker(((
WithClause *) node)->ctes, context);
3403 if (walker(stmt->
infer, context))
3414 elog(
ERROR,
"unrecognized node type: %d",
3535 bool (*walker) (),
void *context)
3540 for (j = 0; j < nplans; j++)
3542 if (walker(planstates[j], context))
bool query_tree_walker(Query *query, bool(*walker)(), void *context, int flags)
#define IsA(nodeptr, _type_)
Node * expression_tree_mutator(Node *node, Node *(*mutator)(), void *context)
#define CHECKFLATCOPY(newnode, node, nodetype)
int exprLocation(const Node *expr)
OnConflictExpr * onConflict
int32 exprTypmod(const Node *expr)
static int leftmostLoc(int loc1, int loc2)
static bool expression_returns_set_walker(Node *node, void *context)
bool expression_returns_set(Node *clause)
List * list_copy(const List *oldlist)
#define QTW_DONT_COPY_QUERY
CoercionForm coercionformat
int errcode(int sqlerrcode)
bool exprIsLengthCoercion(const Node *expr, int32 *coercedTypmod)
static int fc(const char *x)
#define OidIsValid(objectId)
OnConflictClause * onConflictClause
void * copyObject(const void *from)
#define QTW_IGNORE_CTE_SUBQUERIES
struct PlanState * planstate
bool raw_expression_tree_walker(Node *node, bool(*walker)(), void *context)
#define outerPlanState(node)
RelabelType * makeRelabelType(Expr *arg, Oid rtype, int32 rtypmod, Oid rcollid, CoercionForm rformat)
#define DEFAULT_COLLATION_OID
void check_stack_depth(void)
static ListCell * list_head(const List *l)
#define ereport(elevel, rest)
static bool planstate_walk_subplans(List *plans, bool(*walker)(), void *context)
List * lappend(List *list, void *datum)
bool query_or_expression_tree_walker(Node *node, bool(*walker)(), void *context, int flags)
Oid get_promoted_array_type(Oid typid)
CoercionForm coerceformat
void exprSetInputCollation(Node *expr, Oid inputcollation)
CoercionForm convertformat
#define FLATCOPY(newnode, node, nodetype)
Oid exprInputCollation(const Node *expr)
#define Assert(condition)
Node * query_or_expression_tree_mutator(Node *node, Node *(*mutator)(), void *context, int flags)
bool range_table_walker(List *rtable, bool(*walker)(), void *context, int flags)
Oid exprType(const Node *expr)
bool expression_tree_walker(Node *node, bool(*walker)(), void *context)
static int list_length(const List *l)
Oid exprCollation(const Node *expr)
#define for_each_cell(cell, initcell)
CollateClause * collClause
CoercionForm coerceformat
#define QTW_IGNORE_RT_SUBQUERIES
void exprSetCollation(Node *expr, Oid collation)
static bool planstate_walk_members(List *plans, PlanState **planstates, bool(*walker)(), void *context)
int errmsg(const char *fmt,...)
#define QTW_IGNORE_RANGE_TABLE
List * range_table_mutator(List *rtable, Node *(*mutator)(), void *context, int flags)
#define innerPlanState(node)
CoercionForm relabelformat
bool planstate_tree_walker(PlanState *planstate, bool(*walker)(), void *context)
struct TableSampleClause * tablesample
Node * relabel_to_typmod(Node *expr, int32 typmod)
#define MUTATE(newfield, oldfield, fieldtype)
Query * query_tree_mutator(Query *query, Node *(*mutator)(), void *context, int flags)
#define QTW_IGNORE_JOINALIASES
Node * strip_implicit_coercions(Node *node)