55#include "utils/fmgroids.h"
124 bool *haveNull,
bool *forceTrue);
127 bool *haveNull,
bool *forceFalse);
130 Oid result_type,
int32 result_typmod,
131 Oid result_collid,
Oid input_collid,
List **args_p,
132 bool funcvariadic,
bool process_args,
bool allow_non_const,
262 elog(
ERROR,
"WindowFunc contains out-of-range winref %u",
309 if (expr->funcretset)
417 foreach(lc, ctor->
args)
441 if (cnst->constisnull)
693 return (func_id != F_NEXTVAL &&
777 if (
root->glob->maxParallelHazard == PROPARALLEL_SAFE &&
778 root->glob->paramExecTypes ==
NIL)
790 for (proot =
root; proot != NULL; proot = proot->parent_root)
810 case PROPARALLEL_SAFE:
813 case PROPARALLEL_RESTRICTED:
821 case PROPARALLEL_UNSAFE:
826 elog(
ERROR,
"unrecognized proparallel value \"%c\"", proparallel);
917 List *save_safe_param_ids;
1200#define CCDN_CASETESTEXPR_OK 0x0001
1220 int save_flags = *flags;
1235 *flags = save_flags;
1250 save_flags = *flags;
1254 *flags = save_flags;
1302 case T_NamedArgExpr:
1307 case T_CaseTestExpr:
1309 case T_SQLValueFunction:
1312 case T_NextValueExpr:
1313 case T_ReturningExpr:
1324 case T_DistinctExpr:
1326 case T_ScalarArrayOpExpr:
1328 case T_ArrayCoerceExpr:
1340 case T_SubscriptingRef:
1360 case T_RowCompareExpr:
1373 larg, rcexpr->
largs,
1374 rarg, rcexpr->
rargs)
1416 case T_CurrentOfExpr:
1502 foreach(l, (
List *) node)
1561 foreach(l, expr->
args)
1755 foreach(l, (
List *) node)
1819 foreach(l, expr->
args)
1954 foreach(l, (
List *) node)
2050 if (expr->
useOr && falseOK)
2055 if (rightop &&
IsA(rightop,
Const))
2057 Datum arraydatum = ((
Const *) rightop)->constvalue;
2058 bool arrayisnull = ((
Const *) rightop)->constisnull;
2073 if (arrayexpr->elements !=
NIL && !arrayexpr->multidims)
2170 elog(
ERROR,
"cannot commute non-binary-operator clause");
2175 elog(
ERROR,
"could not find commutator for operator %u",
2181 clause->
opno = opoid;
2202 Oid expectedtype,
int32 expectedtypmod,
2203 Oid expectedcollation)
2209 if (rowtypeid == RECORDOID)
2212 if (fieldnum <= 0 || fieldnum > tupdesc->
natts)
2218 if (attr->attisdropped ||
2219 attr->atttypid != expectedtype ||
2220 attr->atttypmod != expectedtypmod ||
2221 attr->attcollation != expectedcollation)
2285#define MIN_ARRAY_SIZE_FOR_HASHED_SAOP 9
2321 if (arrayarg &&
IsA(arrayarg,
Const) &&
2322 !((
Const *) arrayarg)->constisnull)
2327 lefthashfunc == righthashfunc)
2329 Datum arrdatum = ((
Const *) arrayarg)->constvalue;
2343 saop->hashfuncid = lefthashfunc;
2359 lefthashfunc == righthashfunc)
2361 Datum arrdatum = ((
Const *) arrayarg)->constvalue;
2375 saop->hashfuncid = lefthashfunc;
2417 context.
root = NULL;
2433#define ece_generic_processing(node) \
2434 expression_tree_mutator((Node *) (node), eval_const_expressions_mutator, \
2442#define ece_all_arguments_const(node) \
2443 (!expression_tree_walker((Node *) (node), contain_non_const_walker, NULL))
2446#define ece_evaluate_expr(node) \
2447 ((Node *) evaluate_expr((Expr *) (node), \
2448 exprType((Node *) (node)), \
2449 exprTypmod((Node *) (node)), \
2450 exprCollation((Node *) (node))))
2517 &typLen, &typByVal);
2518 if (prm->
isnull || typByVal)
2530 return (
Node *) con;
2559 elog(
ERROR,
"cache lookup failed for function %u", funcid);
2562 false, expr->wintype,
2573 aggfilter = (
Expr *)
2580 newexpr->wintype = expr->wintype;
2581 newexpr->wincollid = expr->wincollid;
2582 newexpr->inputcollid = expr->inputcollid;
2585 newexpr->runCondition = expr->runCondition;
2587 newexpr->winstar = expr->winstar;
2588 newexpr->winagg = expr->winagg;
2592 return (
Node *) newexpr;
2609 expr->funcresulttype,
2619 return (
Node *) simple;
2629 newexpr->funcresulttype = expr->funcresulttype;
2630 newexpr->funcretset = expr->funcretset;
2631 newexpr->funcvariadic = expr->funcvariadic;
2632 newexpr->funcformat = expr->funcformat;
2633 newexpr->funccollid = expr->funccollid;
2634 newexpr->inputcollid = expr->inputcollid;
2637 return (
Node *) newexpr;
2641 if (context->
root != NULL)
2662 expr->opresulttype, -1,
2671 return (
Node *) simple;
2678 if (expr->
opno == BooleanEqualOperator ||
2679 expr->
opno == BooleanNotEqualOperator)
2684 return (
Node *) simple;
2694 newexpr->opfuncid = expr->opfuncid;
2695 newexpr->opresulttype = expr->opresulttype;
2696 newexpr->opretset = expr->opretset;
2697 newexpr->opcollid = expr->opcollid;
2698 newexpr->inputcollid = expr->inputcollid;
2701 return (
Node *) newexpr;
2703 case T_DistinctExpr:
2708 bool has_null_input =
false;
2709 bool all_null_input =
true;
2710 bool has_nonconst_input =
false;
2737 has_nonconst_input =
true;
2741 if (!has_nonconst_input)
2766 expr->opresulttype, -1,
2782 csimple->constvalue =
2784 return (
Node *) csimple;
2795 newexpr->opfuncid = expr->opfuncid;
2796 newexpr->opresulttype = expr->opresulttype;
2797 newexpr->opretset = expr->opretset;
2798 newexpr->opcollid = expr->opcollid;
2799 newexpr->inputcollid = expr->inputcollid;
2802 return (
Node *) newexpr;
2808 bool has_nonconst_input =
false;
2817 has_nonconst_input =
true;
2828 if (!has_nonconst_input &&
2832 return (
Node *) expr;
2834 case T_ScalarArrayOpExpr:
2851 return (
Node *) saop;
2862 bool haveNull =
false;
2863 bool forceTrue =
false;
2890 bool haveNull =
false;
2891 bool forceFalse =
false;
2937 case T_JsonValueExpr:
2951 if (formatted_expr &&
IsA(formatted_expr,
Const))
2952 return formatted_expr;
2957 (
Expr *) formatted_expr,
2962 case T_AlternativeSubPlan:
2982 relabel->resulttypmod,
2983 relabel->resultcollid,
2984 relabel->relabelformat,
2993 bool outtypisvarlena;
3012 &outfunc, &outtypisvarlena);
3014 &infunc, &intypioparam);
3058 return (
Node *) simple;
3069 newexpr->resultcollid = expr->resultcollid;
3070 newexpr->coerceformat = expr->coerceformat;
3072 return (
Node *) newexpr;
3074 case T_ArrayCoerceExpr:
3077 Node *save_case_val;
3175 Node *save_case_val;
3178 bool const_true_cond;
3179 Node *defresult = NULL;
3198 const_true_cond =
false;
3214 if (casecond &&
IsA(casecond,
Const))
3218 if (const_input->constisnull ||
3222 const_true_cond =
true;
3230 if (!const_true_cond)
3234 newcasewhen->
expr = (
Expr *) casecond;
3237 newargs =
lappend(newargs, newcasewhen);
3246 defresult = caseresult;
3251 if (!const_true_cond)
3265 newcase->casetype = caseexpr->casetype;
3266 newcase->casecollid = caseexpr->casecollid;
3267 newcase->
arg = (
Expr *) newarg;
3268 newcase->
args = newargs;
3271 return (
Node *) newcase;
3273 case T_CaseTestExpr:
3285 case T_SubscriptingRef:
3312 case T_CoalesceExpr:
3320 foreach(
arg, coalesceexpr->
args)
3337 if (((
Const *)
e)->constisnull)
3354 coalesceexpr->coalescecollid);
3364 newcoalesce->coalescetype = coalesceexpr->coalescetype;
3365 newcoalesce->coalescecollid = coalesceexpr->coalescecollid;
3366 newcoalesce->
args = newargs;
3368 return (
Node *) newcoalesce;
3370 case T_SQLValueFunction:
3421 ((
Var *)
arg)->varlevelsup == 0)
3425 fselect->resulttype,
3426 fselect->resulttypmod,
3427 fselect->resultcollid))
3433 fselect->resulttype,
3434 fselect->resulttypmod,
3435 fselect->resultcollid,
3436 ((
Var *)
arg)->varlevelsup);
3440 newvar->varnullingrels = ((
Var *)
arg)->varnullingrels;
3441 return (
Node *) newvar;
3456 fselect->resulttype,
3457 fselect->resulttypmod,
3458 fselect->resultcollid) &&
3459 fselect->resulttype ==
exprType(fld) &&
3468 newfselect->resulttype = fselect->resulttype;
3469 newfselect->resulttypmod = fselect->resulttypmod;
3470 newfselect->resultcollid = fselect->resultcollid;
3477 newfselect->resulttype,
3478 newfselect->resulttypmod,
3479 newfselect->resultcollid))
3482 return (
Node *) newfselect;
3504 foreach(l, rarg->
args)
3516 if (carg->constisnull ?
3530 newntest->
arg = (
Expr *) relem;
3532 newntest->argisrow =
false;
3534 newargs =
lappend(newargs, newntest);
3553 result = carg->constisnull;
3556 result = !carg->constisnull;
3559 elog(
ERROR,
"unrecognized nulltesttype: %d",
3583 elog(
ERROR,
"unrecognized nulltesttype: %d",
3596 newntest->argisrow = ntest->argisrow;
3598 return (
Node *) newntest;
3623 result = (!carg->constisnull &&
3627 result = (carg->constisnull ||
3631 result = (!carg->constisnull &&
3635 result = (carg->constisnull ||
3639 result = carg->constisnull;
3642 result = !carg->constisnull;
3645 elog(
ERROR,
"unrecognized booltesttype: %d",
3658 return (
Node *) newbtest;
3660 case T_CoerceToDomain:
3689 cdomain->resulttypmod,
3690 cdomain->resultcollid,
3691 cdomain->coercionformat,
3699 newcdomain->resulttypmod = cdomain->resulttypmod;
3700 newcdomain->resultcollid = cdomain->resultcollid;
3701 newcdomain->coercionformat = cdomain->coercionformat;
3703 return (
Node *) newcdomain;
3705 case T_PlaceHolderVar:
3722 case T_ConvertRowtypeExpr:
3733 newcre->convertformat = cre->convertformat;
3759 newcre->convertformat = argcre->convertformat;
3766 return (
Node *) newcre;
3819 if (provolatile == PROVOLATILE_IMMUTABLE)
3821 if (context->
estimate && provolatile == PROVOLATILE_STABLE)
3848 bool *haveNull,
bool *forceTrue)
3851 List *unprocessed_args;
3865 while (unprocessed_args)
3875 List *oldlist = unprocessed_args;
3908 if (const_input->constisnull)
3954 bool *haveNull,
bool *forceFalse)
3957 List *unprocessed_args;
3961 while (unprocessed_args)
3971 List *oldlist = unprocessed_args;
4004 if (const_input->constisnull)
4057 if (opno == BooleanEqualOperator)
4072 if (rightop &&
IsA(rightop,
Const))
4075 if (opno == BooleanEqualOperator)
4116 Oid result_collid,
Oid input_collid,
List **args_p,
4117 bool funcvariadic,
bool process_args,
bool allow_non_const,
4139 elog(
ERROR,
"cache lookup failed for function %u", funcid);
4161 result_collid, input_collid,
4163 func_tuple, context);
4165 if (!newexpr && allow_non_const &&
OidIsValid(func_form->prosupport))
4177 fexpr.
xpr.type = T_FuncExpr;
4179 fexpr.funcresulttype = result_type;
4180 fexpr.funcretset = func_form->proretset;
4181 fexpr.funcvariadic = funcvariadic;
4183 fexpr.funccollid = result_collid;
4184 fexpr.inputcollid = input_collid;
4188 req.
type = T_SupportRequestSimplify;
4200 if (!newexpr && allow_non_const)
4202 input_collid,
args, funcvariadic,
4203 func_tuple, context);
4234 req.
type = T_SupportRequestSimplifyAggref;
4245 Assert(newnode != (
Node *) aggref || newnode == NULL);
4247 if (newnode != NULL)
4251 return (
Node *) aggref;
4302 if (rte->
inh && rte->relkind != RELKIND_PARTITIONED_TABLE)
4364 Oid *proargtypes = funcform->proargtypes.values;
4366 bool has_named_args =
false;
4377 if (include_out_arguments)
4379 Datum proallargtypes;
4383 Anum_pg_proc_proallargtypes,
4394 elog(
ERROR,
"proallargtypes is not a 1-D Oid array or it contains nulls");
4407 has_named_args =
true;
4451 elog(
ERROR,
"too many function arguments");
4464 argarray[
i++] =
arg;
4484 i =
pronargs - funcform->pronargdefaults;
4485 foreach(lc, defaults)
4487 if (argarray[
i] == NULL)
4523 elog(
ERROR,
"not enough default arguments");
4538 Datum proargdefaults;
4542 Anum_pg_proc_proargdefaults);
4577 elog(
ERROR,
"too many function arguments");
4584 memcpy(declared_arg_types, proargtypes,
pronargs *
sizeof(
Oid));
4588 funcform->prorettype,
4591 if (rettype != result_type)
4592 elog(
ERROR,
"function's resolved result type changed during planning");
4617 bool has_nonconst_input =
false;
4618 bool has_null_input =
false;
4625 if (funcform->proretset)
4638 if (funcform->prorettype == RECORDOID)
4649 has_nonconst_input =
true;
4658 if (funcform->proisstrict && has_null_input)
4667 if (has_nonconst_input)
4677 if (funcform->provolatile == PROVOLATILE_IMMUTABLE)
4679 else if (context->
estimate && funcform->provolatile == PROVOLATILE_STABLE)
4690 newexpr->
funcid = funcid;
4691 newexpr->funcresulttype = result_type;
4692 newexpr->funcretset =
false;
4693 newexpr->funcvariadic = funcvariadic;
4695 newexpr->funccollid = result_collid;
4696 newexpr->inputcollid = input_collid;
4754 List *raw_parsetree_list;
4755 List *querytree_list;
4766 if (funcform->prolang != SQLlanguageId ||
4767 funcform->prokind != PROKIND_FUNCTION ||
4768 funcform->prosecdef ||
4769 funcform->proretset ||
4770 funcform->prorettype == RECORDOID ||
4803 fexpr->funcresulttype = result_type;
4804 fexpr->funcretset =
false;
4805 fexpr->funcvariadic = funcvariadic;
4807 fexpr->funccollid = result_collid;
4808 fexpr->inputcollid = input_collid;
4821 callback_arg.
prosrc = src;
4824 sqlerrcontext.
arg = &callback_arg;
4831 Anum_pg_proc_prosqlbody,
4926 result_type, rettupdesc,
4949 if (
exprType(newexpr) != result_type)
4960 if (funcform->provolatile == PROVOLATILE_IMMUTABLE &&
4963 else if (funcform->provolatile == PROVOLATILE_STABLE &&
4967 if (funcform->proisstrict &&
4984 usecounts = (
int *)
palloc0(funcform->pronargs *
sizeof(
int));
4994 if (usecounts[
i] == 0)
4997 if (funcform->proisstrict)
5000 else if (usecounts[
i] != 1)
5048 if (
OidIsValid(exprcoll) && exprcoll != result_collid)
5052 newnode->
arg = (
Expr *) newexpr;
5053 newnode->
collOid = result_collid;
5056 newexpr = (
Node *) newnode;
5077 return (
Expr *) newexpr;
5097 context.
nargs = nargs;
5136 int syntaxerrposition;
5140 if (syntaxerrposition > 0)
5158 Oid result_collation)
5166 bool resultTypByVal;
5213 if (resultTypLen == -1)
5216 const_val =
datumCopy(const_val, resultTypByVal, resultTypLen);
5225 return (
Expr *)
makeConst(result_type, result_typmod, result_collation,
5227 const_val, const_is_null,
5285 func_oid = fexpr->
funcid;
5313 elog(
ERROR,
"cache lookup failed for function %u", func_oid);
5332 "inline_function_in_from",
5344 if (funcform->prosupport)
5348 req.
type = T_SupportRequestInlineInFrom;
5351 req.
proc = func_tuple;
5366 callback_arg.
prosrc = src;
5369 sqlerrcontext.
arg = &callback_arg;
5379 func_tuple, funcform, src);
5425 root->glob->dependsOnRole =
true;
5462 List *querytree_list;
5472 if (!fexpr->funcretset)
5485 if (funcform->prolang != SQLlanguageId ||
5486 funcform->prokind != PROKIND_FUNCTION ||
5487 funcform->proisstrict ||
5488 funcform->provolatile == PROVOLATILE_VOLATILE ||
5489 funcform->prorettype == VOIDOID ||
5490 funcform->prosecdef ||
5491 !funcform->proretset ||
5498 Anum_pg_proc_prosqlbody,
5523 List *raw_parsetree_list;
5532 fexpr->inputcollid);
5557 if (rtfunc->funccolnames !=
NIL)
5561 rtfunc->funccoltypes,
5562 rtfunc->funccoltypmods,
5563 rtfunc->funccolcollations);
5589 fexpr->funcresulttype, rettupdesc,
5617 context.
nargs = nargs;
5642 context->sublevels_up--;
5706 Oid inputcollid,
List *exprs,
bool haveNonConst)
5708 Node *arrayNode = NULL;
5725 arrayExpr->element_typeid = coltype;
5726 arrayExpr->array_typeid = arraytype;
5727 arrayExpr->multidims =
false;
5728 arrayExpr->elements = exprs;
5731 arrayNode = (
Node *) arrayExpr;
5751 elems[
i] =
value->constvalue;
5752 nulls[
i++] =
value->constisnull;
5756 coltype, typlen, typbyval,
typalign);
5772 saopexpr->
useOr =
true;
5773 saopexpr->inputcollid = inputcollid;
Datum querytree(PG_FUNCTION_ARGS)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
#define DatumGetArrayTypeP(X)
ArrayType * construct_md_array(Datum *elems, bool *nulls, int ndims, int *dims, int *lbs, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
int ArrayGetNItems(int ndim, const int *dims)
#define InvalidAttrNumber
Bitmapset * bms_make_singleton(int x)
Bitmapset * bms_int_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_del_members(Bitmapset *a, const Bitmapset *b)
void bms_free(Bitmapset *a)
int bms_num_members(const Bitmapset *a)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
BMS_Membership bms_membership(const Bitmapset *a)
Bitmapset * bms_join(Bitmapset *a, Bitmapset *b)
#define TextDatumGetCString(d)
#define OidIsValid(objectId)
static bool contain_subplans_walker(Node *node, void *context)
#define CCDN_CASETESTEXPR_OK
static List * simplify_or_arguments(List *args, eval_const_expressions_context *context, bool *haveNull, bool *forceTrue)
static bool is_strict_saop(ScalarArrayOpExpr *expr, bool falseOK)
bool contain_volatile_functions_not_nextval(Node *clause)
List * find_forced_null_vars(Node *node)
static bool contain_leaked_vars_checker(Oid func_id, void *context)
static bool rowtype_field_matches(Oid rowtypeid, int fieldnum, Oid expectedtype, int32 expectedtypmod, Oid expectedcollation)
Query * inline_function_in_from(PlannerInfo *root, RangeTblEntry *rte)
static bool contain_nonstrict_functions_walker(Node *node, void *context)
static List * add_function_defaults(List *args, int pronargs, HeapTuple func_tuple)
#define ece_all_arguments_const(node)
#define ece_evaluate_expr(node)
static bool max_parallel_hazard_checker(Oid func_id, void *context)
static bool max_parallel_hazard_test(char proparallel, max_parallel_hazard_context *context)
bool contain_agg_clause(Node *clause)
static bool contain_agg_clause_walker(Node *node, void *context)
static bool contain_nonstrict_functions_checker(Oid func_id, void *context)
int NumRelids(PlannerInfo *root, Node *clause)
bool contain_mutable_functions(Node *clause)
bool is_pseudo_constant_clause(Node *clause)
static bool max_parallel_hazard_walker(Node *node, max_parallel_hazard_context *context)
bool contain_window_function(Node *clause)
#define ece_generic_processing(node)
Node * estimate_expression_value(PlannerInfo *root, Node *node)
static Expr * evaluate_function(Oid funcid, Oid result_type, int32 result_typmod, Oid result_collid, Oid input_collid, List *args, bool funcvariadic, HeapTuple func_tuple, eval_const_expressions_context *context)
static Node * substitute_actual_parameters_mutator(Node *node, substitute_actual_parameters_context *context)
static bool contain_mutable_functions_checker(Oid func_id, void *context)
Var * find_forced_null_var(Node *node)
bool is_pseudo_constant_clause_relids(Node *clause, Relids relids)
static bool ece_function_is_safe(Oid funcid, eval_const_expressions_context *context)
static bool contain_volatile_functions_checker(Oid func_id, void *context)
static List * simplify_and_arguments(List *args, eval_const_expressions_context *context, bool *haveNull, bool *forceFalse)
WindowFuncLists * find_window_functions(Node *clause, Index maxWinRef)
static Expr * simplify_function(Oid funcid, Oid result_type, int32 result_typmod, Oid result_collid, Oid input_collid, List **args_p, bool funcvariadic, bool process_args, bool allow_non_const, eval_const_expressions_context *context)
Node * eval_const_expressions(PlannerInfo *root, Node *node)
bool contain_volatile_functions_after_planning(Expr *expr)
static Expr * inline_function(Oid funcid, Oid result_type, Oid result_collid, Oid input_collid, List *args, bool funcvariadic, HeapTuple func_tuple, eval_const_expressions_context *context)
static List * reorder_function_arguments(List *args, int pronargs, HeapTuple func_tuple)
static Node * simplify_aggref(Aggref *aggref, eval_const_expressions_context *context)
static Node * substitute_actual_parameters(Node *expr, int nargs, List *args, int *usecounts)
static bool contain_mutable_functions_walker(Node *node, void *context)
static Query * substitute_actual_parameters_in_from(Query *expr, int nargs, List *args)
bool contain_mutable_functions_after_planning(Expr *expr)
static bool contain_volatile_functions_walker(Node *node, void *context)
bool contain_leaked_vars(Node *clause)
List * find_nonnullable_vars(Node *clause)
static Relids find_nonnullable_rels_walker(Node *node, bool top_level)
void convert_saop_to_hashed_saop(Node *node)
static void sql_inline_error_callback(void *arg)
static bool contain_volatile_functions_not_nextval_walker(Node *node, void *context)
static bool contain_leaked_vars_walker(Node *node, void *context)
static bool contain_non_const_walker(Node *node, void *context)
static bool contain_context_dependent_node(Node *clause)
Relids find_nonnullable_rels(Node *clause)
static void recheck_cast_function_args(List *args, Oid result_type, Oid *proargtypes, int pronargs, HeapTuple func_tuple)
static bool find_window_functions_walker(Node *node, WindowFuncLists *lists)
List * expand_function_arguments(List *args, bool include_out_arguments, Oid result_type, HeapTuple func_tuple)
char max_parallel_hazard(Query *parse)
bool is_parallel_safe(PlannerInfo *root, Node *node)
bool contain_nonstrict_functions(Node *clause)
static bool contain_volatile_functions_not_nextval_checker(Oid func_id, void *context)
static List * find_nonnullable_vars_walker(Node *node, bool top_level)
static Node * substitute_actual_parameters_in_from_mutator(Node *node, substitute_actual_parameters_in_from_context *context)
static Query * inline_sql_function_in_from(PlannerInfo *root, RangeTblFunction *rtfunc, FuncExpr *fexpr, HeapTuple func_tuple, Form_pg_proc funcform, const char *src)
bool contain_subplans(Node *clause)
static Node * simplify_boolean_equality(Oid opno, List *args)
static bool contain_exec_param_walker(Node *node, List *param_ids)
Bitmapset * pull_paramids(Expr *expr)
void CommuteOpExpr(OpExpr *clause)
ScalarArrayOpExpr * make_SAOP_expr(Oid oper, Node *leftexpr, Oid coltype, Oid arraycollid, Oid inputcollid, List *exprs, bool haveNonConst)
static Node * eval_const_expressions_mutator(Node *node, eval_const_expressions_context *context)
static bool pull_paramids_walker(Node *node, Bitmapset **context)
Expr * evaluate_expr(Expr *expr, Oid result_type, int32 result_typmod, Oid result_collation)
static bool convert_saop_to_hashed_saop_walker(Node *node, void *context)
bool expr_is_nonnullable(PlannerInfo *root, Expr *expr, bool use_rel_info)
static List * fetch_function_defaults(HeapTuple func_tuple)
bool contain_volatile_functions(Node *clause)
double expression_returns_set_rows(PlannerInfo *root, Node *clause)
bool var_is_nonnullable(PlannerInfo *root, Var *var, bool use_rel_info)
static bool contain_context_dependent_node_walker(Node *node, int *flags)
bool contain_exec_param(Node *clause, List *param_ids)
#define MIN_ARRAY_SIZE_FOR_HASHED_SAOP
void cost_qual_eval(QualCost *cost, List *quals, PlannerInfo *root)
double clamp_row_est(double nrows)
Datum datumCopy(Datum value, bool typByVal, int typLen)
int internalerrquery(const char *query)
int internalerrposition(int cursorpos)
ErrorContextCallback * error_context_stack
int errposition(int cursorpos)
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
void FreeExecutorState(EState *estate)
EState * CreateExecutorState(void)
#define GetPerTupleExprContext(estate)
static Datum ExecEvalExprSwitchContext(ExprState *state, ExprContext *econtext, bool *isNull)
#define OidFunctionCall1(functionId, arg1)
#define PG_DETOAST_DATUM_COPY(datum)
#define FmgrHookIsNeeded(fn_oid)
TypeFuncClass get_expr_result_type(Node *expr, Oid *resultTypeId, TupleDesc *resultTupleDesc)
@ TYPEFUNC_COMPOSITE_DOMAIN
bool check_sql_fn_retval(List *queryTreeLists, Oid rettype, TupleDesc rettupdesc, char prokind, bool insertDroppedCols)
void sql_fn_parser_setup(struct ParseState *pstate, SQLFunctionParseInfoPtr pinfo)
SQLFunctionParseInfoPtr prepare_sql_fn_parse_info(HeapTuple procedureTuple, Node *call_expr, Oid inputCollation)
Assert(PointerIsAligned(start, uint64))
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
if(TABLE==NULL||TABLE_index==NULL)
bool to_json_is_immutable(Oid typoid)
bool to_jsonb_is_immutable(Oid typoid)
bool jspIsMutable(JsonPath *path, List *varnames, List *varexprs)
static JsonPath * DatumGetJsonPathP(Datum d)
List * lappend(List *list, void *datum)
List * list_delete_first(List *list)
List * list_concat(List *list1, const List *list2)
List * list_concat_copy(const List *list1, const List *list2)
List * list_copy(const List *oldlist)
List * lappend_oid(List *list, Oid datum)
List * list_delete_last(List *list)
void list_free(List *list)
bool list_member_int(const List *list, int datum)
bool list_member_oid(const List *list, Oid datum)
List * list_delete_first_n(List *list, int n)
bool list_member(const List *list, const void *datum)
char func_parallel(Oid funcid)
RegProcedure get_func_support(Oid funcid)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
RegProcedure get_opcode(Oid opno)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
char func_volatile(Oid funcid)
bool func_strict(Oid funcid)
bool get_func_leakproof(Oid funcid)
const struct SubscriptRoutines * getSubscriptingRoutines(Oid typid, Oid *typelemp)
bool get_op_hash_functions(Oid opno, RegProcedure *lhs_procno, RegProcedure *rhs_procno)
Oid get_array_type(Oid typid)
Oid get_negator(Oid opno)
Oid get_commutator(Oid opno)
Expr * make_orclause(List *orclauses)
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
Const * makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid)
Node * makeBoolConst(bool value, bool isnull)
Expr * make_andclause(List *andclauses)
JsonValueExpr * makeJsonValueExpr(Expr *raw_expr, Expr *formatted_expr, JsonFormat *format)
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
List * mbms_add_members(List *a, const List *b)
List * mbms_add_member(List *a, int listidx, int bitidx)
List * mbms_int_members(List *a, const List *b)
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
bool check_functions_in_node(Node *node, check_function_callback checker, void *context)
Oid exprCollation(const Node *expr)
Node * applyRelabelType(Node *arg, Oid rtype, int32 rtypmod, Oid rcollid, CoercionForm rformat, int rlocation, bool overwrite_ok)
void fix_opfuncids(Node *node)
void set_sa_opfuncid(ScalarArrayOpExpr *opexpr)
void set_opfuncid(OpExpr *opexpr)
#define expression_tree_mutator(n, m, c)
static bool is_andclause(const void *clause)
static bool is_orclause(const void *clause)
#define query_tree_walker(q, w, c, f)
static bool is_opclause(const void *clause)
#define expression_tree_walker(n, w, c)
#define query_tree_mutator(q, m, c, f)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
void(* ParserSetupHook)(ParseState *pstate, void *arg)
Oid enforce_generic_type_consistency(const Oid *actual_arg_types, Oid *declared_arg_types, int nargs, Oid rettype, bool allow_poly)
void make_fn_arguments(ParseState *pstate, List *fargs, Oid *actual_arg_types, Oid *declared_arg_types)
void free_parsestate(ParseState *pstate)
ParseState * make_parsestate(ParseState *parentParseState)
Operator oper(ParseState *pstate, List *opname, Oid ltypeId, Oid rtypeId, bool noError, int location)
Query * transformTopLevelStmt(ParseState *pstate, RawStmt *parseTree)
#define planner_rt_fetch(rti, root)
FormData_pg_attribute * Form_pg_attribute
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define linitial_node(type, l)
#define forthree(cell1, list1, cell2, list2, cell3, list3)
static void * list_nth(const List *list, int n)
#define list_make3(x1, x2, x3)
#define foreach_node(type, var, lst)
#define list_make2(x1, x2)
FormData_pg_proc * Form_pg_proc
double get_function_rows(PlannerInfo *root, Oid funcid, Node *node)
Bitmapset * find_relation_notnullatts(PlannerInfo *root, Oid relid)
Expr * expression_planner(Expr *expr)
List * pg_analyze_and_rewrite_withcb(RawStmt *parsetree, const char *query_string, ParserSetupHook parserSetup, void *parserSetupArg, QueryEnvironment *queryEnv)
List * pg_parse_query(const char *query_string)
List * pg_rewrite_query(Query *query)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
static Datum Int32GetDatum(int32 X)
Node * negate_clause(Node *node)
void * stringToNode(const char *str)
static struct subre * parse(struct vars *v, int stopper, int type, struct state *init, struct state *final)
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
void AcquireRewriteLocks(Query *parsetree, bool forExecute, bool forUpdatePushedDown)
bool contain_windowfuncs(Node *node)
void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up, int min_sublevels_up)
void record_plan_type_dependency(PlannerInfo *root, Oid typid)
void record_plan_function_dependency(PlannerInfo *root, Oid funcid)
void check_stack_depth(void)
BoolTestType booltesttype
MemoryContext es_query_cxt
struct ErrorContextCallback * previous
void(* callback)(void *arg)
JsonReturning * returning
NullTestType nulltesttype
ParamExternData params[FLEXIBLE_ARRAY_MEMBER]
ParamFetchHook paramFetch
const char * p_sourcetext
VolatileFunctionStatus has_volatile_expr
Bitmapset * notnullattnums
RangeTblFunction * rtfunc
VarReturningType varreturningtype
ParamListInfo boundParams
#define FirstLowInvalidHeapAttributeNumber
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
TupleDesc BuildDescFromLists(const List *names, const List *types, const List *typmods, const List *collations)
#define ReleaseTupleDesc(tupdesc)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
TupleDesc lookup_rowtype_tupdesc_domain(Oid type_id, int32 typmod, bool noError)
bool DomainHasConstraints(Oid type_id)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define TYPECACHE_CMP_PROC
bool contain_var_clause(Node *node)
Relids pull_varnos(PlannerInfo *root, Node *node)