52 type = ((
const Var *) expr)->vartype;
69 case T_MergeSupportFunc:
72 case T_SubscriptingRef:
90 case T_ScalarArrayOpExpr:
108 elog(
ERROR,
"cannot get type for untransformed sublink");
117 (
errcode(ERRCODE_UNDEFINED_OBJECT),
118 errmsg(
"could not find array type for data type %s",
148 (
errcode(ERRCODE_UNDEFINED_OBJECT),
149 errmsg(
"could not find array type for data type %s",
165 case T_AlternativeSubPlan:
185 case T_ArrayCoerceExpr:
188 case T_ConvertRowtypeExpr:
206 case T_RowCompareExpr:
215 case T_SQLValueFunction:
226 case T_JsonValueExpr:
233 case T_JsonConstructorExpr:
236 case T_JsonIsPredicate:
245 case T_CoerceToDomain:
248 case T_CoerceToDomainValue:
254 case T_CurrentOfExpr:
257 case T_NextValueExpr:
260 case T_InferenceElem:
267 case T_PlaceHolderVar:
292 return ((
const Var *) expr)->vartypmod;
294 return ((
const Const *) expr)->consttypmod;
296 return ((
const Param *) expr)->paramtypmod;
297 case T_SubscriptingRef:
305 return coercedTypmod;
333 elog(
ERROR,
"cannot get type for untransformed sublink");
356 case T_AlternativeSubPlan:
368 case T_ArrayCoerceExpr:
379 Oid casetype = cexpr->casetype;
420 if (arrayexpr->multidims)
421 commontype = arrayexpr->array_typeid;
423 commontype = arrayexpr->element_typeid;
443 Oid coalescetype = cexpr->coalescetype;
471 Oid minmaxtype = mexpr->minmaxtype;
492 case T_SQLValueFunction:
494 case T_JsonValueExpr:
496 case T_JsonConstructorExpr:
498 case T_CoerceToDomain:
500 case T_CoerceToDomainValue:
504 case T_PlaceHolderVar:
526 if (coercedTypmod != NULL)
552 if (nargs < 2 || nargs > 3)
558 second_arg->constisnull)
564 if (coercedTypmod != NULL)
575 if (acoerce->resulttypmod < 0)
581 if (coercedTypmod != NULL)
582 *coercedTypmod = acoerce->resulttypmod;
622 con->consttypmod = rtypmod;
623 con->constcollid = rcollid;
641 newrelabel->resulttypmod = rtypmod;
642 newrelabel->resultcollid = rcollid;
643 newrelabel->relabelformat = rformat;
645 return (
Node *) newrelabel;
744 if (expr->funcretset)
798 coll = ((
const Var *) expr)->varcollid;
801 coll = ((
const Const *) expr)->constcollid;
804 coll = ((
const Param *) expr)->paramcollid;
807 coll = ((
const Aggref *) expr)->aggcollid;
813 coll = ((
const WindowFunc *) expr)->wincollid;
815 case T_MergeSupportFunc:
818 case T_SubscriptingRef:
822 coll = ((
const FuncExpr *) expr)->funccollid;
828 coll = ((
const OpExpr *) expr)->opcollid;
836 case T_ScalarArrayOpExpr:
856 elog(
ERROR,
"cannot get collation for untransformed sublink");
887 case T_AlternativeSubPlan:
908 case T_ArrayCoerceExpr:
911 case T_ConvertRowtypeExpr:
919 coll = ((
const CaseExpr *) expr)->casecollid;
925 coll = ((
const ArrayExpr *) expr)->array_collid;
931 case T_RowCompareExpr:
939 coll = ((
const MinMaxExpr *) expr)->minmaxcollid;
941 case T_SQLValueFunction:
944 coll = C_COLLATION_OID;
956 coll = DEFAULT_COLLATION_OID;
960 case T_JsonValueExpr:
963 case T_JsonConstructorExpr:
973 case T_JsonIsPredicate:
985 case T_CoerceToDomain:
988 case T_CoerceToDomainValue:
994 case T_CurrentOfExpr:
998 case T_NextValueExpr:
1002 case T_InferenceElem:
1005 case T_PlaceHolderVar:
1033 coll = ((
const Aggref *) expr)->inputcollid;
1036 coll = ((
const WindowFunc *) expr)->inputcollid;
1039 coll = ((
const FuncExpr *) expr)->inputcollid;
1042 coll = ((
const OpExpr *) expr)->inputcollid;
1044 case T_DistinctExpr:
1048 coll = ((
const NullIfExpr *) expr)->inputcollid;
1050 case T_ScalarArrayOpExpr:
1054 coll = ((
const MinMaxExpr *) expr)->inputcollid;
1076 ((
Var *) expr)->varcollid = collation;
1079 ((
Const *) expr)->constcollid = collation;
1082 ((
Param *) expr)->paramcollid = collation;
1085 ((
Aggref *) expr)->aggcollid = collation;
1087 case T_GroupingFunc:
1091 ((
WindowFunc *) expr)->wincollid = collation;
1093 case T_MergeSupportFunc:
1096 case T_SubscriptingRef:
1100 ((
FuncExpr *) expr)->funccollid = collation;
1102 case T_NamedArgExpr:
1106 ((
OpExpr *) expr)->opcollid = collation;
1108 case T_DistinctExpr:
1114 case T_ScalarArrayOpExpr:
1123 #ifdef USE_ASSERT_CHECKING
1135 elog(
ERROR,
"cannot set collation for untransformed sublink");
1161 case T_ArrayCoerceExpr:
1164 case T_ConvertRowtypeExpr:
1169 ((
CaseExpr *) expr)->casecollid = collation;
1172 ((
ArrayExpr *) expr)->array_collid = collation;
1178 case T_RowCompareExpr:
1182 case T_CoalesceExpr:
1186 ((
MinMaxExpr *) expr)->minmaxcollid = collation;
1188 case T_SQLValueFunction:
1190 (collation == C_COLLATION_OID) :
1195 (collation == DEFAULT_COLLATION_OID) :
1198 case T_JsonValueExpr:
1202 case T_JsonConstructorExpr:
1213 case T_JsonIsPredicate:
1224 case T_CoerceToDomain:
1227 case T_CoerceToDomainValue:
1230 case T_SetToDefault:
1233 case T_CurrentOfExpr:
1237 case T_NextValueExpr:
1261 ((
Aggref *) expr)->inputcollid = inputcollation;
1264 ((
WindowFunc *) expr)->inputcollid = inputcollation;
1267 ((
FuncExpr *) expr)->inputcollid = inputcollation;
1270 ((
OpExpr *) expr)->inputcollid = inputcollation;
1272 case T_DistinctExpr:
1276 ((
NullIfExpr *) expr)->inputcollid = inputcollation;
1278 case T_ScalarArrayOpExpr:
1282 ((
MinMaxExpr *) expr)->inputcollid = inputcollation;
1329 loc = ((
const RangeVar *) expr)->location;
1332 loc = ((
const TableFunc *) expr)->location;
1335 loc = ((
const Var *) expr)->location;
1338 loc = ((
const Const *) expr)->location;
1341 loc = ((
const Param *) expr)->location;
1345 loc = ((
const Aggref *) expr)->location;
1347 case T_GroupingFunc:
1354 case T_MergeSupportFunc:
1357 case T_SubscriptingRef:
1370 case T_NamedArgExpr:
1380 case T_DistinctExpr:
1390 case T_ScalarArrayOpExpr:
1447 case T_ArrayCoerceExpr:
1456 case T_ConvertRowtypeExpr:
1471 loc = ((
const CaseExpr *) expr)->location;
1475 loc = ((
const CaseWhen *) expr)->location;
1479 loc = ((
const ArrayExpr *) expr)->location;
1483 loc = ((
const RowExpr *) expr)->location;
1485 case T_RowCompareExpr:
1489 case T_CoalesceExpr:
1497 case T_SQLValueFunction:
1513 case T_JsonValueExpr:
1516 case T_JsonConstructorExpr:
1519 case T_JsonIsPredicate:
1540 case T_CoerceToDomain:
1549 case T_CoerceToDomainValue:
1552 case T_SetToDefault:
1569 foreach(lc, (
const List *) expr)
1588 loc = ((
const ColumnRef *) expr)->location;
1591 loc = ((
const ParamRef *) expr)->location;
1594 loc = ((
const A_Const *) expr)->location;
1612 loc = ((
const ResTarget *) expr)->location;
1614 case T_MultiAssignRef:
1630 case T_CollateClause:
1639 loc = ((
const WindowDef *) expr)->location;
1641 case T_RangeTableSample:
1645 loc = ((
const TypeName *) expr)->location;
1648 loc = ((
const ColumnDef *) expr)->location;
1653 case T_FunctionParameter:
1657 case T_XmlSerialize:
1670 case T_OnConflictClause:
1673 case T_CTESearchClause:
1676 case T_CTECycleClause:
1679 case T_CommonTableExpr:
1682 case T_JsonKeyValue:
1686 case T_JsonObjectConstructor:
1689 case T_JsonArrayConstructor:
1692 case T_JsonArrayQueryConstructor:
1695 case T_JsonAggConstructor:
1698 case T_JsonObjectAgg:
1701 case T_JsonArrayAgg:
1704 case T_PlaceHolderVar:
1708 case T_InferenceElem:
1712 case T_PartitionElem:
1715 case T_PartitionSpec:
1718 case T_PartitionBoundSpec:
1721 case T_PartitionRangeDatum:
1745 return Min(loc1, loc2);
1837 if (checker(expr->
aggfnoid, context))
1845 if (checker(expr->
winfnoid, context))
1853 if (checker(expr->
funcid, context))
1858 case T_DistinctExpr:
1865 if (checker(expr->opfuncid, context))
1869 case T_ScalarArrayOpExpr:
1874 if (checker(expr->opfuncid, context))
1887 &iofunc, &typioparam);
1888 if (checker(iofunc, context))
1892 &iofunc, &typisvarlena);
1893 if (checker(iofunc, context))
1897 case T_RowCompareExpr:
1902 foreach(opid, rcexpr->opnos)
1906 if (checker(opfuncid, context))
2025 #define WALK(n) walker((Node *) (n), context)
2027 #define LIST_WALK(l) expression_tree_walker_impl((Node *) (l), walker, context)
2040 case T_CaseTestExpr:
2041 case T_SQLValueFunction:
2042 case T_CoerceToDomainValue:
2043 case T_SetToDefault:
2044 case T_CurrentOfExpr:
2045 case T_NextValueExpr:
2047 case T_SortGroupClause:
2048 case T_CTESearchClause:
2049 case T_MergeSupportFunc:
2052 case T_WithCheckOption:
2071 case T_GroupingFunc:
2090 case T_SubscriptingRef:
2115 case T_NamedArgExpr:
2118 case T_DistinctExpr:
2127 case T_ScalarArrayOpExpr:
2169 case T_AlternativeSubPlan:
2187 case T_ArrayCoerceExpr:
2197 case T_ConvertRowtypeExpr:
2208 foreach(temp, caseexpr->
args)
2226 case T_RowCompareExpr:
2236 case T_CoalesceExpr:
2251 case T_JsonValueExpr:
2261 case T_JsonConstructorExpr:
2273 case T_JsonIsPredicate:
2279 case T_CoerceToDomain:
2286 case T_WindowClause:
2298 if (
WALK(wc->runCondition))
2302 case T_CTECycleClause:
2312 case T_CommonTableExpr:
2323 if (
WALK(cte->search_clause))
2325 if (
WALK(cte->cycle_clause))
2329 case T_JsonKeyValue:
2339 case T_JsonObjectConstructor:
2347 case T_JsonArrayConstructor:
2355 case T_JsonArrayQueryConstructor:
2363 case T_JsonAggConstructor:
2375 case T_JsonObjectAgg:
2385 case T_JsonArrayAgg:
2396 case T_PartitionBoundSpec:
2408 case T_PartitionRangeDatum:
2417 foreach(temp, (
List *) node)
2433 case T_OnConflictExpr:
2459 case T_PartitionPruneStepOp:
2467 case T_PartitionPruneStepCombine:
2486 case T_SetOperationStmt:
2508 case T_PlaceHolderVar:
2510 case T_InferenceElem:
2512 case T_AppendRelInfo:
2520 case T_PlaceHolderInfo:
2522 case T_RangeTblFunction:
2524 case T_TableSampleClause:
2538 if (
WALK(tf->ns_uris))
2546 if (
WALK(tf->coldefexprs))
2551 elog(
ERROR,
"unrecognized node type: %d",
2593 if (
WALK(query->withCheckOptions))
2644 if (
WALK(wc->runCondition))
2833 #define FLATCOPY(newnode, node, nodetype) \
2834 ( (newnode) = (nodetype *) palloc(sizeof(nodetype)), \
2835 memcpy((newnode), (node), sizeof(nodetype)) )
2837 #define MUTATE(newfield, oldfield, fieldtype) \
2838 ( (newfield) = (fieldtype) mutator((Node *) (oldfield), context) )
2860 return (
Node *) newnode;
2870 return (
Node *) newnode;
2874 case T_CaseTestExpr:
2875 case T_SQLValueFunction:
2877 case T_CoerceToDomainValue:
2878 case T_SetToDefault:
2879 case T_CurrentOfExpr:
2880 case T_NextValueExpr:
2882 case T_SortGroupClause:
2883 case T_CTESearchClause:
2884 case T_MergeSupportFunc:
2886 case T_WithCheckOption:
2893 return (
Node *) newnode;
2902 newnode->aggargtypes =
list_copy(aggref->aggargtypes);
2908 return (
Node *) newnode;
2911 case T_GroupingFunc:
2917 MUTATE(newnode->args, grouping->args,
List *);
2928 newnode->refs =
list_copy(grouping->refs);
2929 newnode->cols =
list_copy(grouping->cols);
2931 return (
Node *) newnode;
2942 return (
Node *) newnode;
2945 case T_SubscriptingRef:
2960 return (
Node *) newnode;
2970 return (
Node *) newnode;
2973 case T_NamedArgExpr:
2980 return (
Node *) newnode;
2990 return (
Node *) newnode;
2993 case T_DistinctExpr:
3000 return (
Node *) newnode;
3010 return (
Node *) newnode;
3013 case T_ScalarArrayOpExpr:
3020 return (
Node *) newnode;
3030 return (
Node *) newnode;
3046 return (
Node *) newnode;
3060 return (
Node *) newnode;
3063 case T_AlternativeSubPlan:
3070 return (
Node *) newnode;
3080 return (
Node *) newnode;
3091 newnode->fieldnums =
list_copy(fstore->fieldnums);
3092 return (
Node *) newnode;
3102 return (
Node *) newnode;
3112 return (
Node *) newnode;
3115 case T_ArrayCoerceExpr:
3123 return (
Node *) newnode;
3126 case T_ConvertRowtypeExpr:
3133 return (
Node *) newnode;
3143 return (
Node *) newnode;
3155 return (
Node *) newnode;
3166 return (
Node *) newnode;
3176 return (
Node *) newnode;
3187 return (
Node *) newnode;
3190 case T_RowCompareExpr:
3198 return (
Node *) newnode;
3201 case T_CoalesceExpr:
3208 return (
Node *) newnode;
3218 return (
Node *) newnode;
3230 return (
Node *) newnode;
3233 case T_JsonReturning:
3241 return (
Node *) newnode;
3243 case T_JsonValueExpr:
3253 return (
Node *) newnode;
3255 case T_JsonConstructorExpr:
3266 return (
Node *) newnode;
3268 case T_JsonIsPredicate:
3277 return (
Node *) newnode;
3286 return (
Node *) newnode;
3296 return (
Node *) newnode;
3299 case T_CoerceToDomain:
3306 return (
Node *) newnode;
3316 return (
Node *) newnode;
3322 case T_WindowClause:
3332 MUTATE(newnode->runCondition, wc->runCondition,
List *);
3333 return (
Node *) newnode;
3336 case T_CTECycleClause:
3344 return (
Node *) newnode;
3347 case T_CommonTableExpr:
3363 return (
Node *) newnode;
3366 case T_PartitionBoundSpec:
3375 return (
Node *) newnode;
3378 case T_PartitionRangeDatum:
3385 return (
Node *) newnode;
3399 foreach(temp, (
List *) node)
3401 resultlist =
lappend(resultlist,
3405 return (
Node *) resultlist;
3416 return (
Node *) newnode;
3419 case T_OnConflictExpr:
3431 return (
Node *) newnode;
3443 return (
Node *) newnode;
3446 case T_PartitionPruneStepOp:
3454 return (
Node *) newnode;
3457 case T_PartitionPruneStepCombine:
3470 return (
Node *) newnode;
3473 case T_SetOperationStmt:
3482 return (
Node *) newnode;
3493 return (
Node *) newnode;
3496 case T_PlaceHolderVar:
3502 MUTATE(newnode->phexpr, phv->phexpr,
Expr *);
3504 return (
Node *) newnode;
3507 case T_InferenceElem:
3514 return (
Node *) newnode;
3517 case T_AppendRelInfo:
3525 return (
Node *) newnode;
3528 case T_PlaceHolderInfo:
3536 return (
Node *) newnode;
3539 case T_RangeTblFunction:
3547 return (
Node *) newnode;
3550 case T_TableSampleClause:
3558 return (
Node *) newnode;
3567 MUTATE(newnode->ns_uris, tf->ns_uris,
List *);
3571 MUTATE(newnode->coldefexprs, tf->coldefexprs,
List *);
3572 return (
Node *) newnode;
3576 elog(
ERROR,
"unrecognized node type: %d",
3621 MUTATE(query->withCheckOptions, query->withCheckOptions,
List *);
3662 MUTATE(newnode->runCondition, wc->runCondition,
List *);
3664 resultlist =
lappend(resultlist, (
Node *) newnode);
3686 mutator, context, flags);
3751 newrt =
lappend(newrt, newrte);
3799 return mutator(node, context);
3838 case T_SetToDefault:
3839 case T_CurrentOfExpr:
3840 case T_SQLValueFunction:
3849 case T_MergeSupportFunc:
3857 case T_GroupingFunc:
3877 foreach(temp, caseexpr->
args)
3893 case T_CoalesceExpr:
3908 case T_JsonReturning:
3910 case T_JsonValueExpr:
3922 case T_JsonParseExpr:
3932 case T_JsonScalarExpr:
3942 case T_JsonSerializeExpr:
3952 case T_JsonConstructorExpr:
3966 case T_JsonIsPredicate:
3982 if (
WALK(join->alias))
3995 if (
WALK(into->viewQuery))
4000 foreach(temp, (
List *) node)
4076 case T_MergeWhenClause:
4126 case T_PLAssignStmt:
4173 case T_NamedArgExpr:
4185 case T_A_Indirection:
4207 case T_MultiAssignRef:
4219 case T_CollateClause:
4237 case T_RangeSubselect:
4247 case T_RangeFunction:
4259 case T_RangeTableSample:
4272 case T_RangeTableFunc:
4288 case T_RangeTableFuncCol:
4333 case T_LockingClause:
4335 case T_XmlSerialize:
4357 case T_OnConflictClause:
4369 case T_CommonTableExpr:
4382 case T_JsonKeyValue:
4392 case T_JsonObjectConstructor:
4402 case T_JsonArrayConstructor:
4412 case T_JsonAggConstructor:
4426 case T_JsonObjectAgg:
4436 case T_JsonArrayAgg:
4446 case T_JsonArrayQueryConstructor:
4457 elog(
ERROR,
"unrecognized node type: %d",
4479 #define PSWALK(n) walker(n, context)
4529 case T_SubqueryScan:
4583 for (
j = 0;
j < nplans;
j++)
#define OidIsValid(objectId)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define outerPlanState(node)
#define innerPlanState(node)
if(TABLE==NULL||TABLE_index==NULL)
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lappend(List *list, void *datum)
List * list_copy(const List *oldlist)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
RegProcedure get_opcode(Oid opno)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
Oid get_promoted_array_type(Oid typid)
bool query_tree_walker_impl(Query *query, tree_walker_callback walker, void *context, int flags)
#define FLATCOPY(newnode, node, nodetype)
bool raw_expression_tree_walker_impl(Node *node, tree_walker_callback walker, void *context)
Node * query_or_expression_tree_mutator_impl(Node *node, tree_mutator_callback mutator, void *context, int flags)
Oid exprType(const Node *expr)
bool range_table_entry_walker_impl(RangeTblEntry *rte, tree_walker_callback walker, void *context, int flags)
Query * query_tree_mutator_impl(Query *query, tree_mutator_callback mutator, void *context, int flags)
bool exprIsLengthCoercion(const Node *expr, int32 *coercedTypmod)
void exprSetCollation(Node *expr, Oid collation)
Oid exprInputCollation(const Node *expr)
Node * expression_tree_mutator_impl(Node *node, tree_mutator_callback mutator, void *context)
int32 exprTypmod(const Node *expr)
static bool planstate_walk_subplans(List *plans, planstate_tree_walker_callback walker, void *context)
bool check_functions_in_node(Node *node, check_function_callback checker, void *context)
Oid exprCollation(const Node *expr)
static bool fix_opfuncids_walker(Node *node, void *context)
void exprSetInputCollation(Node *expr, Oid inputcollation)
bool query_or_expression_tree_walker_impl(Node *node, tree_walker_callback walker, void *context, int flags)
List * range_table_mutator_impl(List *rtable, tree_mutator_callback mutator, void *context, int flags)
Node * applyRelabelType(Node *arg, Oid rtype, int32 rtypmod, Oid rcollid, CoercionForm rformat, int rlocation, bool overwrite_ok)
bool expression_tree_walker_impl(Node *node, tree_walker_callback walker, void *context)
bool range_table_walker_impl(List *rtable, tree_walker_callback walker, void *context, int flags)
#define MUTATE(newfield, oldfield, fieldtype)
static int leftmostLoc(int loc1, int loc2)
Node * relabel_to_typmod(Node *expr, int32 typmod)
int exprLocation(const Node *expr)
Node * strip_implicit_coercions(Node *node)
bool expression_returns_set(Node *clause)
bool planstate_tree_walker_impl(PlanState *planstate, planstate_tree_walker_callback walker, void *context)
void fix_opfuncids(Node *node)
static bool expression_returns_set_walker(Node *node, void *context)
void set_sa_opfuncid(ScalarArrayOpExpr *opexpr)
static bool planstate_walk_members(PlanState **planstates, int nplans, planstate_tree_walker_callback walker, void *context)
void set_opfuncid(OpExpr *opexpr)
#define QTW_DONT_COPY_QUERY
#define QTW_IGNORE_CTE_SUBQUERIES
#define QTW_IGNORE_RT_SUBQUERIES
#define range_table_walker(rt, w, c, f)
bool(* planstate_tree_walker_callback)(struct PlanState *planstate, void *context)
#define query_tree_walker(q, w, c, f)
#define range_table_entry_walker(r, w, c, f)
#define QTW_EXAMINE_RTES_AFTER
#define QTW_EXAMINE_SORTGROUP
bool(* tree_walker_callback)(Node *node, void *context)
Node *(* tree_mutator_callback)(Node *node, void *context)
#define expression_tree_walker(n, w, c)
#define query_tree_mutator(q, m, c, f)
bool(* check_function_callback)(Oid func_id, void *context)
#define QTW_EXAMINE_RTES_BEFORE
#define range_table_mutator(rt, m, c, f)
#define QTW_IGNORE_RANGE_TABLE
#define QTW_IGNORE_JOINALIASES
#define IsA(nodeptr, _type_)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define linitial_node(type, l)
#define for_each_from(cell, lst, N)
static rewind_source * source
void check_stack_depth(void)
static int32 DatumGetInt32(Datum X)
static int fc(const char *x)
Node * cycle_mark_default
CollateClause * collClause
struct RestrictInfo * rinfo
JsonAggConstructor * constructor
JsonReturning * returning
JsonAggConstructor * constructor
JsonReturning * returning
OnConflictExpr * onConflict
struct TableSampleClause * tablesample
struct PlanState * planstate