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

Go to the source code of this file.

Data Structures

struct  WindowFuncLists
 

Functions

bool contain_agg_clause (Node *clause)
 
bool contain_window_function (Node *clause)
 
WindowFuncListsfind_window_functions (Node *clause, Index maxWinRef)
 
double expression_returns_set_rows (PlannerInfo *root, Node *clause)
 
bool contain_subplans (Node *clause)
 
char max_parallel_hazard (Query *parse)
 
bool is_parallel_safe (PlannerInfo *root, Node *node)
 
bool contain_nonstrict_functions (Node *clause)
 
bool contain_exec_param (Node *clause, List *param_ids)
 
bool contain_leaked_vars (Node *clause)
 
Relids find_nonnullable_rels (Node *clause)
 
Listfind_nonnullable_vars (Node *clause)
 
Listfind_forced_null_vars (Node *node)
 
Varfind_forced_null_var (Node *node)
 
bool is_pseudo_constant_clause (Node *clause)
 
bool is_pseudo_constant_clause_relids (Node *clause, Relids relids)
 
int NumRelids (PlannerInfo *root, Node *clause)
 
void CommuteOpExpr (OpExpr *clause)
 
Queryinline_function_in_from (PlannerInfo *root, RangeTblEntry *rte)
 
Bitmapsetpull_paramids (Expr *expr)
 

Function Documentation

◆ CommuteOpExpr()

void CommuteOpExpr ( OpExpr clause)
extern

Definition at line 2159 of file clauses.c.

2160{
2161 Oid opoid;
2162 Node *temp;
2163
2164 /* Sanity checks: caller is at fault if these fail */
2165 if (!is_opclause(clause) ||
2166 list_length(clause->args) != 2)
2167 elog(ERROR, "cannot commute non-binary-operator clause");
2168
2169 opoid = get_commutator(clause->opno);
2170
2171 if (!OidIsValid(opoid))
2172 elog(ERROR, "could not find commutator for operator %u",
2173 clause->opno);
2174
2175 /*
2176 * modify the clause in-place!
2177 */
2178 clause->opno = opoid;
2179 clause->opfuncid = InvalidOid;
2180 /* opresulttype, opretset, opcollid, inputcollid need not change */
2181
2182 temp = linitial(clause->args);
2183 linitial(clause->args) = lsecond(clause->args);
2184 lsecond(clause->args) = temp;
2185}
#define OidIsValid(objectId)
Definition c.h:788
#define ERROR
Definition elog.h:39
#define elog(elevel,...)
Definition elog.h:226
Oid get_commutator(Oid opno)
Definition lsyscache.c:1659
static bool is_opclause(const void *clause)
Definition nodeFuncs.h:76
static int list_length(const List *l)
Definition pg_list.h:152
#define linitial(l)
Definition pg_list.h:178
#define lsecond(l)
Definition pg_list.h:183
#define InvalidOid
unsigned int Oid
static int fb(int x)
Definition nodes.h:135
Oid opno
Definition primnodes.h:850
List * args
Definition primnodes.h:868

References OpExpr::args, elog, ERROR, fb(), get_commutator(), InvalidOid, is_opclause(), linitial, list_length(), lsecond, OidIsValid, and OpExpr::opno.

Referenced by get_switched_clauses().

◆ contain_agg_clause()

bool contain_agg_clause ( Node clause)
extern

Definition at line 190 of file clauses.c.

191{
192 return contain_agg_clause_walker(clause, NULL);
193}
static bool contain_agg_clause_walker(Node *node, void *context)
Definition clauses.c:196

References contain_agg_clause_walker(), and fb().

Referenced by get_eclass_for_sort_expr(), mark_nullable_by_grouping(), and subquery_planner().

◆ contain_exec_param()

bool contain_exec_param ( Node clause,
List param_ids 
)
extern

Definition at line 1148 of file clauses.c.

1149{
1150 return contain_exec_param_walker(clause, param_ids);
1151}
static bool contain_exec_param_walker(Node *node, List *param_ids)
Definition clauses.c:1154

References contain_exec_param_walker(), and fb().

Referenced by test_opexpr_is_hashable().

◆ contain_leaked_vars()

bool contain_leaked_vars ( Node clause)
extern

Definition at line 1274 of file clauses.c.

1275{
1276 return contain_leaked_vars_walker(clause, NULL);
1277}
static bool contain_leaked_vars_walker(Node *node, void *context)
Definition clauses.c:1286

References contain_leaked_vars_walker(), and fb().

Referenced by make_plain_restrictinfo(), and qual_is_pushdown_safe().

◆ contain_nonstrict_functions()

bool contain_nonstrict_functions ( Node clause)
extern

Definition at line 1002 of file clauses.c.

1003{
1005}
static bool contain_nonstrict_functions_walker(Node *node, void *context)
Definition clauses.c:1014

References contain_nonstrict_functions_walker(), and fb().

Referenced by inline_function(), and pullup_replace_vars_callback().

◆ contain_subplans()

bool contain_subplans ( Node clause)
extern

◆ contain_window_function()

bool contain_window_function ( Node clause)
extern

Definition at line 227 of file clauses.c.

228{
229 return contain_windowfuncs(clause);
230}
bool contain_windowfuncs(Node *node)

References contain_windowfuncs().

Referenced by get_eclass_for_sort_expr(), and mark_nullable_by_grouping().

◆ expression_returns_set_rows()

double expression_returns_set_rows ( PlannerInfo root,
Node clause 
)
extern

Definition at line 298 of file clauses.c.

299{
300 if (clause == NULL)
301 return 1.0;
302 if (IsA(clause, FuncExpr))
303 {
304 FuncExpr *expr = (FuncExpr *) clause;
305
306 if (expr->funcretset)
307 return clamp_row_est(get_function_rows(root, expr->funcid, clause));
308 }
309 if (IsA(clause, OpExpr))
310 {
311 OpExpr *expr = (OpExpr *) clause;
312
313 if (expr->opretset)
314 {
315 set_opfuncid(expr);
316 return clamp_row_est(get_function_rows(root, expr->opfuncid, clause));
317 }
318 }
319 return 1.0;
320}
double clamp_row_est(double nrows)
Definition costsize.c:213
void set_opfuncid(OpExpr *opexpr)
Definition nodeFuncs.c:1871
#define IsA(nodeptr, _type_)
Definition nodes.h:164
double get_function_rows(PlannerInfo *root, Oid funcid, Node *node)
Definition plancat.c:2421
tree ctl root
Definition radixtree.h:1857
Oid funcid
Definition primnodes.h:782

References clamp_row_est(), fb(), FuncExpr::funcid, get_function_rows(), IsA, root, and set_opfuncid().

Referenced by create_set_projection_path(), estimate_num_groups(), and set_function_size_estimates().

◆ find_forced_null_var()

Var * find_forced_null_var ( Node node)
extern

Definition at line 1989 of file clauses.c.

1990{
1991 if (node == NULL)
1992 return NULL;
1993 if (IsA(node, NullTest))
1994 {
1995 /* check for var IS NULL */
1996 NullTest *expr = (NullTest *) node;
1997
1998 if (expr->nulltesttype == IS_NULL && !expr->argisrow)
1999 {
2000 Var *var = (Var *) expr->arg;
2001
2002 if (var && IsA(var, Var) &&
2003 var->varlevelsup == 0)
2004 return var;
2005 }
2006 }
2007 else if (IsA(node, BooleanTest))
2008 {
2009 /* var IS UNKNOWN is equivalent to var IS NULL */
2010 BooleanTest *expr = (BooleanTest *) node;
2011
2012 if (expr->booltesttype == IS_UNKNOWN)
2013 {
2014 Var *var = (Var *) expr->arg;
2015
2016 if (var && IsA(var, Var) &&
2017 var->varlevelsup == 0)
2018 return var;
2019 }
2020 }
2021 return NULL;
2022}
@ IS_UNKNOWN
Definition primnodes.h:2001
@ IS_NULL
Definition primnodes.h:1977
BoolTestType booltesttype
Definition primnodes.h:2008
NullTestType nulltesttype
Definition primnodes.h:1984
Expr * arg
Definition primnodes.h:1983

References NullTest::arg, BooleanTest::arg, BooleanTest::booltesttype, fb(), IS_NULL, IS_UNKNOWN, IsA, NullTest::nulltesttype, and Var::varlevelsup.

Referenced by check_redundant_nullability_qual(), and find_forced_null_vars().

◆ find_forced_null_vars()

List * find_forced_null_vars ( Node node)
extern

Definition at line 1928 of file clauses.c.

1929{
1930 List *result = NIL;
1931 Var *var;
1932 ListCell *l;
1933
1934 if (node == NULL)
1935 return NIL;
1936 /* Check single-clause cases using subroutine */
1937 var = find_forced_null_var(node);
1938 if (var)
1939 {
1940 result = mbms_add_member(result,
1941 var->varno,
1943 }
1944 /* Otherwise, handle AND-conditions */
1945 else if (IsA(node, List))
1946 {
1947 /*
1948 * At top level, we are examining an implicit-AND list: if any of the
1949 * arms produces FALSE-or-NULL then the result is FALSE-or-NULL.
1950 */
1951 foreach(l, (List *) node)
1952 {
1953 result = mbms_add_members(result,
1955 }
1956 }
1957 else if (IsA(node, BoolExpr))
1958 {
1959 BoolExpr *expr = (BoolExpr *) node;
1960
1961 /*
1962 * We don't bother considering the OR case, because it's fairly
1963 * unlikely anyone would write "v1 IS NULL OR v1 IS NULL". Likewise,
1964 * the NOT case isn't worth expending code on.
1965 */
1966 if (expr->boolop == AND_EXPR)
1967 {
1968 /* At top level we can just recurse (to the List case) */
1969 result = find_forced_null_vars((Node *) expr->args);
1970 }
1971 }
1972 return result;
1973}
List * find_forced_null_vars(Node *node)
Definition clauses.c:1928
Var * find_forced_null_var(Node *node)
Definition clauses.c:1989
List * mbms_add_members(List *a, const List *b)
List * mbms_add_member(List *a, int listidx, int bitidx)
#define lfirst(lc)
Definition pg_list.h:172
#define NIL
Definition pg_list.h:68
@ AND_EXPR
Definition primnodes.h:963
BoolExprType boolop
Definition primnodes.h:971
List * args
Definition primnodes.h:972
Definition pg_list.h:54
AttrNumber varattno
Definition primnodes.h:274
int varno
Definition primnodes.h:269
#define FirstLowInvalidHeapAttributeNumber
Definition sysattr.h:27

References AND_EXPR, BoolExpr::args, BoolExpr::boolop, fb(), find_forced_null_var(), find_forced_null_vars(), FirstLowInvalidHeapAttributeNumber, IsA, lfirst, mbms_add_member(), mbms_add_members(), NIL, Var::varattno, and Var::varno.

Referenced by find_forced_null_vars(), and reduce_outer_joins_pass2().

◆ find_nonnullable_rels()

Relids find_nonnullable_rels ( Node clause)
extern

Definition at line 1468 of file clauses.c.

1469{
1470 return find_nonnullable_rels_walker(clause, true);
1471}
static Relids find_nonnullable_rels_walker(Node *node, bool top_level)
Definition clauses.c:1474

References find_nonnullable_rels_walker().

Referenced by make_outerjoininfo(), and reduce_outer_joins_pass2().

◆ find_nonnullable_vars()

List * find_nonnullable_vars ( Node clause)
extern

Definition at line 1719 of file clauses.c.

1720{
1721 return find_nonnullable_vars_walker(clause, true);
1722}
static List * find_nonnullable_vars_walker(Node *node, bool top_level)
Definition clauses.c:1725

References find_nonnullable_vars_walker().

Referenced by reduce_outer_joins_pass2().

◆ find_window_functions()

WindowFuncLists * find_window_functions ( Node clause,
Index  maxWinRef 
)
extern

Definition at line 240 of file clauses.c.

241{
243
244 lists->numWindowFuncs = 0;
245 lists->maxWinRef = maxWinRef;
246 lists->windowFuncs = (List **) palloc0((maxWinRef + 1) * sizeof(List *));
248 return lists;
249}
static bool find_window_functions_walker(Node *node, WindowFuncLists *lists)
Definition clauses.c:252
#define palloc_object(type)
Definition fe_memutils.h:74
void * palloc0(Size size)
Definition mcxt.c:1417

References fb(), find_window_functions_walker(), palloc0(), and palloc_object.

Referenced by grouping_planner().

◆ inline_function_in_from()

Query * inline_function_in_from ( PlannerInfo root,
RangeTblEntry rte 
)
extern

Definition at line 5376 of file clauses.c.

5377{
5378 RangeTblFunction *rtfunc;
5379 FuncExpr *fexpr;
5380 Oid func_oid;
5385 Datum tmp;
5386 char *src;
5387 inline_error_callback_arg callback_arg;
5389 Query *querytree = NULL;
5390
5391 Assert(rte->rtekind == RTE_FUNCTION);
5392
5393 /*
5394 * Guard against infinite recursion during expansion by checking for stack
5395 * overflow. (There's no need to do more.)
5396 */
5398
5399 /* Fail if the RTE has ORDINALITY - we don't implement that here. */
5400 if (rte->funcordinality)
5401 return NULL;
5402
5403 /* Fail if RTE isn't a single, simple FuncExpr */
5404 if (list_length(rte->functions) != 1)
5405 return NULL;
5406 rtfunc = (RangeTblFunction *) linitial(rte->functions);
5407
5408 if (!IsA(rtfunc->funcexpr, FuncExpr))
5409 return NULL;
5410 fexpr = (FuncExpr *) rtfunc->funcexpr;
5411
5412 func_oid = fexpr->funcid;
5413
5414 /*
5415 * Refuse to inline if the arguments contain any volatile functions or
5416 * sub-selects. Volatile functions are rejected because inlining may
5417 * result in the arguments being evaluated multiple times, risking a
5418 * change in behavior. Sub-selects are rejected partly for implementation
5419 * reasons (pushing them down another level might change their behavior)
5420 * and partly because they're likely to be expensive and so multiple
5421 * evaluation would be bad.
5422 */
5423 if (contain_volatile_functions((Node *) fexpr->args) ||
5424 contain_subplans((Node *) fexpr->args))
5425 return NULL;
5426
5427 /* Check permission to call function (fail later, if not) */
5429 return NULL;
5430
5431 /* Check whether a plugin wants to hook function entry/exit */
5433 return NULL;
5434
5435 /*
5436 * OK, let's take a look at the function's pg_proc entry.
5437 */
5440 elog(ERROR, "cache lookup failed for function %u", func_oid);
5442
5443 /*
5444 * If the function SETs any configuration parameters, inlining would cause
5445 * us to miss making those changes.
5446 */
5448 {
5450 return NULL;
5451 }
5452
5453 /*
5454 * Make a temporary memory context, so that we don't leak all the stuff
5455 * that parsing and rewriting might create. If we succeed, we'll copy
5456 * just the finished query tree back up to the caller's context.
5457 */
5459 "inline_function_in_from",
5462
5463 /* Fetch the function body */
5465 src = TextDatumGetCString(tmp);
5466
5467 /*
5468 * If the function has an attached support function that can handle
5469 * SupportRequestInlineInFrom, then attempt to inline with that.
5470 */
5471 if (funcform->prosupport)
5472 {
5474
5476 req.root = root;
5477 req.rtfunc = rtfunc;
5478 req.proc = func_tuple;
5479
5480 querytree = (Query *)
5482 PointerGetDatum(&req)));
5483 }
5484
5485 /*
5486 * Setup error traceback support for ereport(). This is so that we can
5487 * finger the function that bad information came from. We don't install
5488 * this while running the support function, since it'd be likely to do the
5489 * wrong thing: any parse errors reported during that are very likely not
5490 * against the raw function source text.
5491 */
5492 callback_arg.proname = NameStr(funcform->proname);
5493 callback_arg.prosrc = src;
5494
5496 sqlerrcontext.arg = &callback_arg;
5499
5500 /*
5501 * If SupportRequestInlineInFrom didn't work, try our built-in inlining
5502 * mechanism.
5503 */
5504 if (!querytree)
5506 func_tuple, funcform, src);
5507
5508 if (!querytree)
5509 goto fail; /* no luck there either, fail */
5510
5511 /*
5512 * The result had better be a SELECT Query.
5513 */
5515 Assert(querytree->commandType == CMD_SELECT);
5516
5517 /*
5518 * Looks good --- substitute parameters into the query.
5519 */
5521 funcform->pronargs,
5522 fexpr->args);
5523
5524 /*
5525 * Copy the modified query out of the temporary memory context, and clean
5526 * up.
5527 */
5529
5531
5535
5536 /*
5537 * We don't have to fix collations here because the upper query is already
5538 * parsed, ie, the collations in the RTE are what count.
5539 */
5540
5541 /*
5542 * Since there is now no trace of the function in the plan tree, we must
5543 * explicitly record the plan's dependency on the function.
5544 */
5546
5547 /*
5548 * We must also notice if the inserted query adds a dependency on the
5549 * calling role due to RLS quals.
5550 */
5551 if (querytree->hasRowSecurity)
5552 root->glob->dependsOnRole = true;
5553
5554 return querytree;
5555
5556 /* Here if func is not inlinable: release temp memory and return NULL */
5557fail:
5562
5563 return NULL;
5564}
Datum querytree(PG_FUNCTION_ARGS)
Definition _int_bool.c:665
@ ACLCHECK_OK
Definition acl.h:183
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
Definition aclchk.c:3836
#define TextDatumGetCString(d)
Definition builtins.h:98
#define NameStr(name)
Definition c.h:765
#define Assert(condition)
Definition c.h:873
static Query * substitute_actual_parameters_in_from(Query *expr, int nargs, List *args)
Definition clauses.c:5740
static void sql_inline_error_callback(void *arg)
Definition clauses.c:5260
static Query * inline_sql_function_in_from(PlannerInfo *root, RangeTblFunction *rtfunc, FuncExpr *fexpr, HeapTuple func_tuple, Form_pg_proc funcform, const char *src)
Definition clauses.c:5580
bool contain_subplans(Node *clause)
Definition clauses.c:339
bool contain_volatile_functions(Node *clause)
Definition clauses.c:547
ErrorContextCallback * error_context_stack
Definition elog.c:95
#define OidFunctionCall1(functionId, arg1)
Definition fmgr.h:722
#define FmgrHookIsNeeded(fn_oid)
Definition fmgr.h:850
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
Definition heaptuple.c:456
#define HeapTupleIsValid(tuple)
Definition htup.h:78
static void * GETSTRUCT(const HeapTupleData *tuple)
MemoryContext CurrentMemoryContext
Definition mcxt.c:160
void MemoryContextDelete(MemoryContext context)
Definition mcxt.c:472
#define AllocSetContextCreate
Definition memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition memutils.h:160
Oid GetUserId(void)
Definition miscinit.c:469
#define copyObject(obj)
Definition nodes.h:232
@ CMD_SELECT
Definition nodes.h:275
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
Definition palloc.h:124
@ RTE_FUNCTION
#define ACL_EXECUTE
Definition parsenodes.h:83
FormData_pg_proc * Form_pg_proc
Definition pg_proc.h:136
static Datum PointerGetDatum(const void *X)
Definition postgres.h:352
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:262
uint64_t Datum
Definition postgres.h:70
static Pointer DatumGetPointer(Datum X)
Definition postgres.h:342
void record_plan_function_dependency(PlannerInfo *root, Oid funcid)
Definition setrefs.c:3575
void check_stack_depth(void)
Definition stack_depth.c:95
struct ErrorContextCallback * previous
Definition elog.h:297
void ReleaseSysCache(HeapTuple tuple)
Definition syscache.c:264
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition syscache.c:220
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
Definition syscache.c:625

References ACL_EXECUTE, ACLCHECK_OK, ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, check_stack_depth(), CMD_SELECT, contain_subplans(), contain_volatile_functions(), copyObject, CurrentMemoryContext, DatumGetPointer(), elog, ERROR, error_context_stack, fb(), FmgrHookIsNeeded, RangeTblFunction::funcexpr, GETSTRUCT(), GetUserId(), heap_attisnull(), HeapTupleIsValid, inline_sql_function_in_from(), IsA, linitial, list_length(), MemoryContextDelete(), MemoryContextSwitchTo(), NameStr, object_aclcheck(), ObjectIdGetDatum(), OidFunctionCall1, PointerGetDatum(), ErrorContextCallback::previous, inline_error_callback_arg::proname, inline_error_callback_arg::prosrc, querytree(), record_plan_function_dependency(), ReleaseSysCache(), root, RTE_FUNCTION, SearchSysCache1(), sql_inline_error_callback(), substitute_actual_parameters_in_from(), SysCacheGetAttrNotNull(), TextDatumGetCString, and SupportRequestInlineInFrom::type.

Referenced by preprocess_function_rtes().

◆ is_parallel_safe()

bool is_parallel_safe ( PlannerInfo root,
Node node 
)
extern

Definition at line 762 of file clauses.c.

763{
766 ListCell *l;
767
768 /*
769 * Even if the original querytree contained nothing unsafe, we need to
770 * search the expression if we have generated any PARAM_EXEC Params while
771 * planning, because those are parallel-restricted and there might be one
772 * in this expression. But otherwise we don't need to look.
773 */
774 if (root->glob->maxParallelHazard == PROPARALLEL_SAFE &&
775 root->glob->paramExecTypes == NIL)
776 return true;
777 /* Else use max_parallel_hazard's search logic, but stop on RESTRICTED */
780 context.safe_param_ids = NIL;
781
782 /*
783 * The params that refer to the same or parent query level are considered
784 * parallel-safe. The idea is that we compute such params at Gather or
785 * Gather Merge node and pass their value to workers.
786 */
787 for (proot = root; proot != NULL; proot = proot->parent_root)
788 {
789 foreach(l, proot->init_plans)
790 {
792
793 context.safe_param_ids = list_concat(context.safe_param_ids,
794 initsubplan->setParam);
795 }
796 }
797
798 return !max_parallel_hazard_walker(node, &context);
799}
static bool max_parallel_hazard_walker(Node *node, max_parallel_hazard_context *context)
Definition clauses.c:838
List * list_concat(List *list1, const List *list2)
Definition list.c:561

References fb(), lfirst, list_concat(), max_parallel_hazard_context::max_hazard, max_parallel_hazard_context::max_interesting, max_parallel_hazard_walker(), NIL, root, and max_parallel_hazard_context::safe_param_ids.

Referenced by apply_projection_to_path(), build_join_rel(), create_minmaxagg_path(), create_nestloop_plan(), create_partial_unique_paths(), create_projection_path(), create_set_projection_path(), create_window_paths(), find_computable_ec_member(), grouping_planner(), make_grouping_rel(), plan_create_index_workers(), query_planner(), relation_can_be_sorted_early(), and set_rel_consider_parallel().

◆ is_pseudo_constant_clause()

bool is_pseudo_constant_clause ( Node clause)
extern

Definition at line 2100 of file clauses.c.

2101{
2102 /*
2103 * We could implement this check in one recursive scan. But since the
2104 * check for volatile functions is both moderately expensive and unlikely
2105 * to fail, it seems better to look for Vars first and only check for
2106 * volatile functions if we find no Vars.
2107 */
2108 if (!contain_var_clause(clause) &&
2110 return true;
2111 return false;
2112}
bool contain_var_clause(Node *node)
Definition var.c:406

References contain_var_clause(), and contain_volatile_functions().

Referenced by clauselist_selectivity_ext(), dependency_is_compatible_clause(), dependency_is_compatible_expression(), and find_window_run_conditions().

◆ is_pseudo_constant_clause_relids()

bool is_pseudo_constant_clause_relids ( Node clause,
Relids  relids 
)
extern

Definition at line 2120 of file clauses.c.

2121{
2122 if (bms_is_empty(relids) &&
2124 return true;
2125 return false;
2126}
#define bms_is_empty(a)
Definition bitmapset.h:118

References bms_is_empty, and contain_volatile_functions().

Referenced by clauselist_selectivity_ext().

◆ max_parallel_hazard()

char max_parallel_hazard ( Query parse)
extern

◆ NumRelids()

int NumRelids ( PlannerInfo root,
Node clause 
)
extern

Definition at line 2142 of file clauses.c.

2143{
2144 int result;
2145 Relids varnos = pull_varnos(root, clause);
2146
2147 varnos = bms_del_members(varnos, root->outer_join_rels);
2148 result = bms_num_members(varnos);
2149 bms_free(varnos);
2150 return result;
2151}
Bitmapset * bms_del_members(Bitmapset *a, const Bitmapset *b)
Definition bitmapset.c:1160
void bms_free(Bitmapset *a)
Definition bitmapset.c:239
int bms_num_members(const Bitmapset *a)
Definition bitmapset.c:750
Relids pull_varnos(PlannerInfo *root, Node *node)
Definition var.c:114

References bms_del_members(), bms_free(), bms_num_members(), pull_varnos(), and root.

Referenced by clauselist_selectivity_ext(), rowcomparesel(), and treat_as_join_clause().

◆ pull_paramids()

Bitmapset * pull_paramids ( Expr expr)
extern

Definition at line 5800 of file clauses.c.

5801{
5802 Bitmapset *result = NULL;
5803
5804 (void) pull_paramids_walker((Node *) expr, &result);
5805
5806 return result;
5807}
static bool pull_paramids_walker(Node *node, Bitmapset **context)
Definition clauses.c:5810

References fb(), and pull_paramids_walker().

Referenced by create_memoize_plan().