131#include "utils/fmgroids.h"
144#define DEFAULT_PAGE_CPU_MULTIPLIER 50.0
153#ifndef USE_ASSERT_CHECKING
154#define EQJOINSEL_MCV_HASH_THRESHOLD 200
156#define EQJOINSEL_MCV_HASH_THRESHOLD 20
253 Oid sortop,
Oid collation,
257 Oid collation,
int16 typLen,
bool typByVal,
261 Oid sortop,
Oid collation,
277#define SH_PREFIX MCVHashTable
278#define SH_ELEMENT_TYPE MCVHashEntry
279#define SH_KEY_TYPE Datum
281#define SH_HASH_KEY(tab,key) hash_mcv(tab, key)
282#define SH_EQUAL(tab,key0,key1) mcvs_equal(tab, key0, key1)
283#define SH_SCOPE static inline
285#define SH_GET_HASH(tab,ent) (ent)->hash
439 fcinfo->args[0].isnull =
false;
440 fcinfo->args[1].isnull =
false;
443 fcinfo->args[1].value = constval;
445 fcinfo->args[0].value = constval;
452 fcinfo->args[0].value =
sslot.values[
i];
454 fcinfo->args[1].value =
sslot.values[
i];
455 fcinfo->isnull =
false;
488 for (
i = 0;
i <
sslot.nnumbers;
i++)
698 if (block >=
vardata->rel->pages - 1)
764 constval, consttype);
834 fcinfo->args[0].isnull =
false;
835 fcinfo->args[1].isnull =
false;
838 fcinfo->args[1].value = constval;
840 fcinfo->args[0].value = constval;
847 fcinfo->args[0].value =
sslot.values[
i];
849 fcinfo->args[1].value =
sslot.values[
i];
850 fcinfo->isnull =
false;
932 fcinfo->args[0].isnull =
false;
933 fcinfo->args[1].isnull =
false;
936 fcinfo->args[1].value = constval;
938 fcinfo->args[0].value = constval;
945 fcinfo->args[0].value =
sslot.values[
i];
947 fcinfo->args[1].value =
sslot.values[
i];
948 fcinfo->isnull =
false;
988 List *args,
int varRelid,
1064 else if (
selec > 0.9999)
1143 if (
sslot.nvalues > 1 &&
1144 sslot.stacoll == collation &&
1176 if (
sslot.nvalues == 2)
1184 while (lobound < hibound)
1186 int probe = (lobound + hibound) / 2;
1216 lobound =
probe + 1;
1233 else if (lobound >=
sslot.nvalues)
1306 else if (
val <= low)
1308 else if (
val >= high)
1409 double cutoff = 0.01 / (
double) (
sslot.nvalues - 1);
1417 else if (
sslot.nvalues > 1)
1431 fcinfo->args[0].isnull =
false;
1432 fcinfo->args[1].isnull =
false;
1433 fcinfo->args[1].value = constval;
1434 for (
int i = 0;
i <
sslot.nvalues;
i++)
1438 fcinfo->args[0].value =
sslot.values[
i];
1439 fcinfo->isnull =
false;
1453 double cutoff = 0.01 / (
double) (
sslot.nvalues - 1);
1533 &
vardata, constval, consttype);
1644 &&
sslot.nnumbers > 0)
1663 switch (booltesttype)
1690 elog(
ERROR,
"unrecognized booltesttype: %d",
1691 (
int) booltesttype);
1705 switch (booltesttype)
1727 elog(
ERROR,
"unrecognized booltesttype: %d",
1728 (
int) booltesttype);
1742 switch (booltesttype)
1763 elog(
ERROR,
"unrecognized booltesttype: %d",
1764 (
int) booltesttype);
1798 switch (nulltesttype)
1816 elog(
ERROR,
"unrecognized nulltesttype: %d",
1817 (
int) nulltesttype);
1835 switch (nulltesttype)
1844 elog(
ERROR,
"unrecognized nulltesttype: %d",
1845 (
int) nulltesttype);
1908 bool useOr = clause->
useOr;
1947 if (
operator == typentry->
eq_opr)
2026 &elem_values, &elem_nulls, &num_elems);
2044 for (
i = 0;
i < num_elems;
i++)
2059 clause->inputcollid,
2067 clause->inputcollid,
2112 foreach(l, arrayexpr->elements)
2126 clause->inputcollid,
2134 clause->inputcollid,
2174 dummyexpr->collation = clause->inputcollid;
2178 clause->inputcollid,
2186 clause->inputcollid,
2191 s1 = useOr ? 0.0 : 1.0;
2198 for (
i = 0;
i < 10;
i++)
2228 if (arrayexpr &&
IsA(arrayexpr,
Const))
2244 else if (arrayexpr &&
root)
2264 if (
sslot.nnumbers > 0)
2315 else if (sjinfo ==
NULL)
2526 elog(
ERROR,
"unrecognized join type: %d",
2720 bool op_is_reversed,
2911 bool op_is_reversed,
2928 fcinfo->args[0].isnull =
false;
2929 fcinfo->args[1].isnull =
false;
2958 op_is_reversed = !op_is_reversed;
2974 hash_fcinfo->args[0].isnull =
false;
3021 hash_fcinfo->args[0].isnull =
false;
3061 fcinfo->args[index1].value =
sslot1->values[
i];
3069 fcinfo->args[index2].value =
sslot2->values[
j];
3070 fcinfo->isnull =
false;
3220 result = 1.0 - result;
3327 opno = ((
OpExpr *) clause)->opno;
3328 collation = ((
OpExpr *) clause)->inputcollid;
3561 *
leftend += stats->stanullfrac;
3676 if (
varinfo->ndistinct <= ndistinct)
3693 varinfo->ndistinct = ndistinct;
3694 varinfo->isdefault = isdefault;
4146 while (clauses !=
NIL)
4165 foreach(
lc, clauses)
4177 relids = rinfo->outer_is_left ?
4178 rinfo->right_relids : rinfo->left_relids;
4179 expr = rinfo->outer_is_left ?
4183 root->simple_rel_array[relid]->statlist !=
NIL)
4323 Assert(ndistinct >= 1.0);
4417 if (
sslot.nnumbers > 0)
4454 stanullfrac = stats->stanullfrac;
4460 avgfreq = (1.0 - stanullfrac) / ndistinct;
4481 if (ndistinct > nbuckets)
4527 path->pathtarget->width,
4814 elog(
ERROR,
"corrupt MVNDistinct entry");
5197 if (*lobound != *hibound || *lobound != *
value)
5199 lobound++, hibound++,
value++;
5474 return (
double) (
timetz->time + (
timetz->zone * 1000000.0));
5575 elog(
ERROR,
"join operator should take two arguments");
5669 (varRelid == 0 || varRelid == ((
Var *)
basenode)->varno))
5676 vardata->atttype = var->vartype;
5677 vardata->atttypmod = var->vartypmod;
5707 if (varRelid == 0 || varRelid == relid)
5777 for (pos = 0; pos <
index->ncolumns; pos++)
5779 if (
index->indexkeys[pos] == 0)
5784 elog(
ERROR,
"too few entries in indexprs list");
5794 if (
index->unique &&
5795 index->nkeycolumns == 1 &&
5821 elog(
ERROR,
"no function provided to release variable stats with");
5917 if (
equal(node, expr))
5974 if (
root->glob->lastPHId == 0)
6044 elog(
ERROR,
"no function provided to release variable stats with");
6133 levelsup =
rte->ctelevelsup;
6135 while (levelsup-- > 0)
6139 elog(
ERROR,
"bad levelsup for CTE \"%s\"",
rte->ctename);
6157 elog(
ERROR,
"could not find CTE \"%s\"",
rte->ctename);
6159 elog(
ERROR,
"could not find plan for CTE \"%s\"",
rte->ctename);
6162 elog(
ERROR,
"no plan was made for CTE \"%s\"",
rte->ctename);
6167 if (subroot ==
NULL)
6178 subquery = subroot->
parse;
6200 elog(
ERROR,
"subquery %s does not have attribute %d",
6242 if (
rte->security_barrier)
6246 if (var &&
IsA(var,
Var) &&
6345 if (
root->append_rel_array !=
NULL)
6383 for (attno = 1; attno <=
appinfo->num_child_cols; attno++)
6402 if (attno >
appinfo->num_child_cols)
6415 varno =
appinfo->parent_relid;
6429 if (
rte->securityQuals !=
NIL)
6447 if (varattnos ==
NULL)
6505 if (
index->indexkeys[indexcol] != 0)
6513 colnum =
index->indexkeys[indexcol];
6525 elog(
ERROR,
"no function provided to release variable stats with");
6539 relid =
index->indexoid;
6540 colnum = indexcol + 1;
6551 elog(
ERROR,
"no function provided to release variable stats with");
6585 (
errmsg_internal(
"not using statistics because function \"%s\" is not leakproof",
6605 double stanullfrac = 0.0;
6622 stadistinct = stats->stadistinct;
6623 stanullfrac = stats->stanullfrac;
6683 stadistinct = -1.0 * (1.0 - stanullfrac);
6688 if (stadistinct > 0.0)
6699 ntuples =
vardata->rel->tuples;
6709 if (stadistinct < 0.0)
6736 Oid sortop,
Oid collation,
6789 if (
sslot.stacoll == collation &&
sslot.nvalues > 0)
6810 collation, typLen, typByVal,
6836 for (
i = 0;
i <
sslot.nnumbers;
i++)
6845 collation, typLen, typByVal,
6863 Oid collation,
int16 typLen,
bool typByVal,
6877 for (
int i = 0;
i <
sslot->nvalues;
i++)
6926 Oid sortop,
Oid collation,
6967 if (
index->hypothetical)
6974 if (!
index->canreturn[0])
6981 if (collation !=
index->indexcollations[0])
6989 if (
index->reverse_sort[0])
6995 if (
index->reverse_sort[0])
7021 "get_actual_variable_range workspace",
7211#define VISITED_PAGES_LIMIT 100
7238 elog(
ERROR,
"no data returned for index-only scan");
7253 elog(
ERROR,
"found unexpected null value in index \"%s\"",
7294 elog(
ERROR,
"could not find RelOptInfo for given relids");
7316 foreach(
lc, indexclauses)
7325 result =
lappend(result, rinfo);
7346 foreach(
lc, indexquals)
7383 elog(
ERROR,
"unsupported indexqual type: %d",
7403 Cost indexStartupCost;
7404 Cost indexTotalCost;
7406 double indexCorrelation;
7407 double numIndexPages;
7408 double numIndexTuples;
7409 double spc_random_page_cost;
7410 double num_sa_scans;
7431 if (num_sa_scans < 1)
7461 if (numIndexTuples <= 0.0)
7463 numIndexTuples = indexSelectivity *
index->rel->tuples;
7472 numIndexTuples =
rint(numIndexTuples / num_sa_scans);
7480 if (numIndexTuples >
index->tuples)
7481 numIndexTuples =
index->tuples;
7482 if (numIndexTuples < 1.0)
7483 numIndexTuples = 1.0;
7498 numIndexPages =
ceil(numIndexTuples *
index->pages /
index->tuples);
7500 numIndexPages = 1.0;
7504 &spc_random_page_cost,
7537 (
double)
index->pages,
7554 indexTotalCost = numIndexPages * spc_random_page_cost;
7583 indexCorrelation = 0.0;
7653 double indexCorrelation = 0;
7658 index->opcintype[0],
7659 index->opcintype[0],
7671 if (
index->reverse_sort[0])
7674 if (
index->nkeycolumns > 1)
7682 return indexCorrelation;
7687 Cost *indexStartupCost,
Cost *indexTotalCost,
7688 Selectivity *indexSelectivity,
double *indexCorrelation,
7694 double numIndexTuples;
7704 double num_sa_scans;
7791 bool isdefault =
true;
7862 ndistinct =
Max(ndistinct, 1);
7894 num_sa_scans *= ndistinct;
7913 if (
index->pages < num_sa_scans)
7932 if (indexcol !=
iclause->indexcol)
7950 clause_op = op->
opno;
7965 clause_op = saop->
opno;
7983 elog(
ERROR,
"unsupported indexqual type: %d",
7990 index->opfamily[indexcol]);
7991 Assert(op_strategy != 0);
8015 if (
index->unique &&
8016 indexcol ==
index->nkeycolumns - 1 &&
8020 numIndexTuples = 1.0;
8062 num_sa_scans =
Min(num_sa_scans,
ceil(
index->pages * 0.3333333));
8063 num_sa_scans =
Max(num_sa_scans, 1);
8084 numIndexTuples =
rint(numIndexTuples / num_sa_scans);
8106 if (
index->tuples > 1)
8150 Cost *indexStartupCost,
Cost *indexTotalCost,
8151 Selectivity *indexSelectivity,
double *indexCorrelation,
8192 Cost *indexStartupCost,
Cost *indexTotalCost,
8193 Selectivity *indexSelectivity,
double *indexCorrelation,
8211 if (
index->tree_height < 0)
8213 if (
index->pages > 1)
8216 index->tree_height = 0;
8224 if (
index->tuples > 1)
8247 Cost *indexStartupCost,
Cost *indexTotalCost,
8248 Selectivity *indexSelectivity,
double *indexCorrelation,
8266 if (
index->tree_height < 0)
8268 if (
index->pages > 1)
8271 index->tree_height = 0;
8279 if (
index->tuples > 1)
8355 index->opcintype[indexcol],
8356 index->opcintype[indexcol],
8362 elog(
ERROR,
"missing support function %d for attribute %d of index \"%s\"",
8371 collation =
index->indexcollations[indexcol];
8395 for (
i = 0;
i < nentries;
i++)
8463 if (((
Const *) operand)->constisnull)
8602 Cost *indexStartupCost,
Cost *indexTotalCost,
8603 Selectivity *indexSelectivity,
double *indexCorrelation,
8610 numTuples =
index->tuples;
8624 spc_random_page_cost,
8636 if (!
index->hypothetical)
8723 &spc_random_page_cost,
8729 *indexCorrelation = 0.0;
8734 memset(&counts, 0,
sizeof(counts));
8772 elog(
ERROR,
"unsupported GIN indexqual type: %d",
8781 *indexStartupCost = 0;
8782 *indexTotalCost = 0;
8783 *indexSelectivity = 0;
8794 for (
i = 0;
i <
index->nkeycolumns;
i++)
8851 *indexStartupCost = 0;
8852 *indexTotalCost = 0;
8939 (numTuples / (
BLCKSZ / 3)));
8963 *indexTotalCost += *indexStartupCost +
8992 Cost *indexStartupCost,
Cost *indexTotalCost,
8993 Selectivity *indexSelectivity,
double *indexCorrelation,
9002 Cost spc_random_page_cost;
9018 &spc_random_page_cost,
9025 if (!
index->hypothetical)
9059 *indexCorrelation = 0;
9079 "no function provided to release variable stats with");
9110 elog(
ERROR,
"no function provided to release variable stats with");
9132 if (
sslot.nnumbers > 0)
9160 if (*indexCorrelation < 1.0e-10)
9170 *indexSelectivity =
selec;
9192 *indexTotalCost = *indexStartupCost +
Datum idx(PG_FUNCTION_ARGS)
AclResult pg_attribute_aclcheck_all(Oid table_oid, Oid roleid, AclMode mode, AclMaskHow how)
AclResult pg_attribute_aclcheck(Oid table_oid, AttrNumber attnum, Oid roleid, AclMode mode)
AclResult pg_class_aclcheck(Oid table_oid, Oid roleid, AclMode mode)
StrategyNumber IndexAmTranslateCompareType(CompareType cmptype, Oid amoid, Oid opfamily, bool missing_ok)
CompareType IndexAmTranslateStrategy(StrategyNumber strategy, Oid amoid, Oid opfamily, bool missing_ok)
#define DatumGetArrayTypeP(X)
Selectivity scalararraysel_containment(PlannerInfo *root, Node *leftop, Node *rightop, Oid elemtype, bool isEquality, bool useOr, int varRelid)
void deconstruct_array(const ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
int ArrayGetNItems(int ndim, const int *dims)
#define AttrNumberIsForUserDefinedAttr(attributeNumber)
#define InvalidAttrNumber
Datum numeric_float8_no_overflow(PG_FUNCTION_ARGS)
Bitmapset * bms_difference(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_make_singleton(int x)
int bms_next_member(const Bitmapset *a, int prevbit)
bool bms_is_subset(const 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)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
bool bms_get_singleton_member(const Bitmapset *a, int *member)
#define InvalidBlockNumber
static Datum values[MAXATTR]
void brinGetStats(Relation index, BrinStatsData *stats)
#define BRIN_DEFAULT_PAGES_PER_RANGE
#define REVMAP_PAGE_MAXITEMS
void ReleaseBuffer(Buffer buffer)
#define TextDatumGetCString(d)
#define PG_USED_FOR_ASSERTS_ONLY
#define Assert(condition)
#define MemSet(start, val, len)
#define OidIsValid(objectId)
int NumRelids(PlannerInfo *root, Node *clause)
Node * estimate_expression_value(PlannerInfo *root, Node *node)
bool contain_volatile_functions(Node *clause)
double expression_returns_set_rows(PlannerInfo *root, Node *clause)
Selectivity clauselist_selectivity(PlannerInfo *root, List *clauses, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
Selectivity clause_selectivity(PlannerInfo *root, Node *clause, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
double index_pages_fetched(double tuples_fetched, BlockNumber pages, double index_pages, PlannerInfo *root)
void cost_qual_eval_node(QualCost *cost, Node *qual, PlannerInfo *root)
double clamp_row_est(double nrows)
double cpu_index_tuple_cost
double date2timestamp_no_overflow(DateADT dateVal)
static TimeTzADT * DatumGetTimeTzADTP(Datum X)
static DateADT DatumGetDateADT(Datum X)
static TimeADT DatumGetTimeADT(Datum X)
Datum datumCopy(Datum value, bool typByVal, int typLen)
bool datum_image_eq(Datum value1, Datum value2, bool typByVal, int typLen)
int errmsg_internal(const char *fmt,...)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
bool exprs_known_equal(PlannerInfo *root, Node *item1, Node *item2, Oid opfamily)
void ExecDropSingleTupleTableSlot(TupleTableSlot *slot)
HeapTuple statext_expressions_load(Oid stxoid, bool inh, int idx)
#define palloc_object(type)
#define palloc0_object(type)
Datum FunctionCall4Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4)
void set_fn_opclass_options(FmgrInfo *flinfo, bytea *options)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Datum FunctionCall5Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5)
Datum DirectFunctionCall5Coll(PGFunction func, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5)
Datum FunctionCall7Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2, Datum arg3, Datum arg4, Datum arg5, Datum arg6, Datum arg7)
#define DatumGetByteaPP(X)
#define PG_RETURN_FLOAT8(x)
#define PG_GETARG_POINTER(n)
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
#define DirectFunctionCall1(func, arg1)
#define LOCAL_FCINFO(name, nargs)
#define FunctionCallInvoke(fcinfo)
#define PG_GETARG_INT32(n)
#define PG_GET_COLLATION()
#define PG_GETARG_INT16(n)
#define GIN_EXTRACTQUERY_PROC
#define GIN_SEARCH_MODE_DEFAULT
#define GIN_SEARCH_MODE_INCLUDE_EMPTY
void ginGetStats(Relation index, GinStatsData *stats)
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
IndexScanDesc index_beginscan(Relation heapRelation, Relation indexRelation, Snapshot snapshot, IndexScanInstrumentation *instrument, int nkeys, int norderbys)
void index_close(Relation relation, LOCKMODE lockmode)
ItemPointer index_getnext_tid(IndexScanDesc scan, ScanDirection direction)
bool index_fetch_heap(IndexScanDesc scan, TupleTableSlot *slot)
void index_endscan(IndexScanDesc scan)
Relation index_open(Oid relationId, LOCKMODE lockmode)
void index_rescan(IndexScanDesc scan, ScanKey keys, int nkeys, ScanKey orderbys, int norderbys)
void index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor, Datum *values, bool *isnull)
bool match_index_to_operand(Node *operand, int indexcol, IndexOptInfo *index)
static OffsetNumber ItemPointerGetOffsetNumberNoCheck(const ItemPointerData *pointer)
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
static BlockNumber ItemPointerGetBlockNumberNoCheck(const ItemPointerData *pointer)
ItemPointerData * ItemPointer
List * lappend(List *list, void *datum)
List * list_concat(List *list1, const List *list2)
List * list_copy(const List *oldlist)
bool list_member_ptr(const List *list, const void *datum)
void list_free(List *list)
bool list_member_int(const List *list, int datum)
void list_free_deep(List *list)
char * get_rel_name(Oid relid)
void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op, int *strategy, Oid *lefttype, Oid *righttype)
RegProcedure get_oprrest(Oid opno)
void free_attstatsslot(AttStatsSlot *sslot)
bool comparison_ops_are_compatible(Oid opno1, Oid opno2)
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
RegProcedure get_oprjoin(Oid opno)
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
RegProcedure get_opcode(Oid opno)
int get_op_opfamily_strategy(Oid opno, Oid opfamily)
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
bool get_func_leakproof(Oid funcid)
char * get_func_name(Oid funcid)
Oid get_base_element_type(Oid typid)
Oid get_opfamily_method(Oid opfid)
bool get_op_hash_functions(Oid opno, RegProcedure *lhs_procno, RegProcedure *rhs_procno)
bool get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple, int reqkind, Oid reqop, int flags)
Oid get_negator(Oid opno)
Oid get_commutator(Oid opno)
#define ATTSTATSSLOT_NUMBERS
#define ATTSTATSSLOT_VALUES
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
MVNDistinct * statext_ndistinct_load(Oid mvoid, bool inh)
double convert_network_to_scalar(Datum value, Oid typid, bool *failure)
Size hash_agg_entry_size(int numTrans, Size tupleWidth, Size transitionSpace)
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
#define expression_tree_mutator(n, m, c)
static Node * get_rightop(const void *clause)
static bool is_opclause(const void *clause)
static bool is_funcclause(const void *clause)
#define expression_tree_walker(n, w, c)
static Node * get_leftop(const void *clause)
#define IsA(nodeptr, _type_)
#define PVC_RECURSE_AGGREGATES
#define PVC_RECURSE_PLACEHOLDERS
#define PVC_RECURSE_WINDOWFUNCS
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
bool targetIsInSortList(TargetEntry *tle, Oid sortop, List *sortList)
RTEPermissionInfo * getRTEPermissionInfo(List *rteperminfos, RangeTblEntry *rte)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
#define IS_SIMPLE_REL(rel)
#define planner_rt_fetch(rti, root)
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
#define foreach_delete_current(lst, var_or_cell)
#define for_each_from(cell, lst, N)
static void * list_nth(const List *list, int n)
static ListCell * list_head(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
#define list_make2(x1, x2)
static int list_nth_int(const List *list, int n)
pg_locale_t pg_newlocale_from_collation(Oid collid)
size_t pg_strxfrm(char *dest, const char *src, size_t destsize, pg_locale_t locale)
FormData_pg_statistic * Form_pg_statistic
Selectivity restriction_selectivity(PlannerInfo *root, Oid operatorid, List *args, Oid inputcollid, int varRelid)
bool has_unique_index(RelOptInfo *rel, AttrNumber attno)
Selectivity join_selectivity(PlannerInfo *root, Oid operatorid, List *args, Oid inputcollid, JoinType jointype, SpecialJoinInfo *sjinfo)
static uint32 DatumGetUInt32(Datum X)
static bool DatumGetBool(Datum X)
static int64 DatumGetInt64(Datum X)
static Datum PointerGetDatum(const void *X)
static float4 DatumGetFloat4(Datum X)
static Oid DatumGetObjectId(Datum X)
static Datum Int16GetDatum(int16 X)
static Datum UInt16GetDatum(uint16 X)
static Datum BoolGetDatum(bool X)
static float8 DatumGetFloat8(Datum X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
static char DatumGetChar(Datum X)
static Datum Int32GetDatum(int32 X)
static int16 DatumGetInt16(Datum X)
static int32 DatumGetInt32(Datum X)
bool predicate_implied_by(List *predicate_list, List *clause_list, bool weak)
GlobalVisState * GlobalVisTestFor(Relation rel)
#define RelationGetRelationName(relation)
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
RelOptInfo * find_base_rel_noerr(PlannerInfo *root, int relid)
RelOptInfo * find_join_rel(PlannerInfo *root, Relids relids)
Node * remove_nulling_relids(Node *node, const Bitmapset *removable_relids, const Bitmapset *except_relids)
void ScanKeyEntryInitialize(ScanKey entry, int flags, AttrNumber attributeNumber, StrategyNumber strategy, Oid subtype, Oid collation, RegProcedure procedure, Datum argument)
static bool get_actual_variable_endpoint(Relation heapRel, Relation indexRel, ScanDirection indexscandir, ScanKey scankeys, int16 typLen, bool typByVal, TupleTableSlot *tableslot, MemoryContext outercontext, Datum *endpointDatum)
bool get_restriction_variable(PlannerInfo *root, List *args, int varRelid, VariableStatData *vardata, Node **other, bool *varonleft)
Datum neqsel(PG_FUNCTION_ARGS)
static RelOptInfo * find_join_input_rel(PlannerInfo *root, Relids relids)
void mergejoinscansel(PlannerInfo *root, Node *clause, Oid opfamily, CompareType cmptype, bool nulls_first, Selectivity *leftstart, Selectivity *leftend, Selectivity *rightstart, Selectivity *rightend)
bool all_rows_selectable(PlannerInfo *root, Index varno, Bitmapset *varattnos)
static Node * strip_all_phvs_mutator(Node *node, void *context)
static bool get_variable_range(PlannerInfo *root, VariableStatData *vardata, Oid sortop, Oid collation, Datum *min, Datum *max)
void btcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
List * get_quals_from_indexclauses(List *indexclauses)
static void convert_string_to_scalar(char *value, double *scaledvalue, char *lobound, double *scaledlobound, char *hibound, double *scaledhibound)
double var_eq_const(VariableStatData *vardata, Oid oproid, Oid collation, Datum constval, bool constisnull, bool varonleft, bool negate)
List * add_predicate_to_index_quals(IndexOptInfo *index, List *indexQuals)
double generic_restriction_selectivity(PlannerInfo *root, Oid oproid, Oid collation, List *args, int varRelid, double default_selectivity)
#define VISITED_PAGES_LIMIT
void spgcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
static double eqjoinsel_inner(FmgrInfo *eqproc, Oid collation, Oid hashLeft, Oid hashRight, VariableStatData *vardata1, VariableStatData *vardata2, double nd1, double nd2, bool isdefault1, bool isdefault2, AttStatsSlot *sslot1, AttStatsSlot *sslot2, Form_pg_statistic stats1, Form_pg_statistic stats2, bool have_mcvs1, bool have_mcvs2, bool *hasmatch1, bool *hasmatch2, int *p_nmatches)
Datum scalargtsel(PG_FUNCTION_ARGS)
#define DEFAULT_PAGE_CPU_MULTIPLIER
static bool estimate_multivariate_ndistinct(PlannerInfo *root, RelOptInfo *rel, List **varinfos, double *ndistinct)
Selectivity booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
Datum eqjoinsel(PG_FUNCTION_ARGS)
double estimate_array_length(PlannerInfo *root, Node *arrayexpr)
double mcv_selectivity(VariableStatData *vardata, FmgrInfo *opproc, Oid collation, Datum constval, bool varonleft, double *sumcommonp)
Selectivity nulltestsel(PlannerInfo *root, NullTestType nulltesttype, Node *arg, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
static void examine_simple_variable(PlannerInfo *root, Var *var, VariableStatData *vardata)
static List * add_unique_group_var(PlannerInfo *root, List *varinfos, Node *var, VariableStatData *vardata)
Datum matchingsel(PG_FUNCTION_ARGS)
Datum eqsel(PG_FUNCTION_ARGS)
static bool mcvs_equal(MCVHashTable_hash *tab, Datum key0, Datum key1)
void examine_variable(PlannerInfo *root, Node *node, int varRelid, VariableStatData *vardata)
Datum scalargtjoinsel(PG_FUNCTION_ARGS)
static double convert_one_string_to_scalar(char *value, int rangelo, int rangehi)
static Datum scalarineqsel_wrapper(PG_FUNCTION_ARGS, bool isgt, bool iseq)
static Node * strip_all_phvs_deep(PlannerInfo *root, Node *node)
void gincostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
static void eqjoinsel_find_matches(FmgrInfo *eqproc, Oid collation, Oid hashLeft, Oid hashRight, bool op_is_reversed, AttStatsSlot *sslot1, AttStatsSlot *sslot2, int nvalues1, int nvalues2, bool *hasmatch1, bool *hasmatch2, int *p_nmatches, double *p_matchprodfreq)
static double convert_timevalue_to_scalar(Datum value, Oid typid, bool *failure)
static double convert_numeric_to_scalar(Datum value, Oid typid, bool *failure)
#define EQJOINSEL_MCV_HASH_THRESHOLD
static Node * strip_array_coercion(Node *node)
double estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows, List **pgset, EstimationInfo *estinfo)
static bool convert_to_scalar(Datum value, Oid valuetypid, Oid collid, double *scaledvalue, Datum lobound, Datum hibound, Oid boundstypid, double *scaledlobound, double *scaledhibound)
double ineq_histogram_selectivity(PlannerInfo *root, VariableStatData *vardata, Oid opoid, FmgrInfo *opproc, bool isgt, bool iseq, Oid collation, Datum constval, Oid consttype)
void genericcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, GenericCosts *costs)
List * estimate_multivariate_bucketsize(PlannerInfo *root, RelOptInfo *inner, List *hashclauses, Selectivity *innerbucketsize)
Datum scalarltjoinsel(PG_FUNCTION_ARGS)
static bool gincost_pattern(IndexOptInfo *index, int indexcol, Oid clause_op, Datum query, GinQualCounts *counts)
static bool contain_placeholder_walker(Node *node, void *context)
struct MCVHashTable_hash MCVHashTable_hash
void brincostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
void gistcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
Datum scalargejoinsel(PG_FUNCTION_ARGS)
static double eqjoinsel_semi(FmgrInfo *eqproc, Oid collation, Oid hashLeft, Oid hashRight, bool op_is_reversed, VariableStatData *vardata1, VariableStatData *vardata2, double nd1, double nd2, bool isdefault1, bool isdefault2, AttStatsSlot *sslot1, AttStatsSlot *sslot2, Form_pg_statistic stats1, Form_pg_statistic stats2, bool have_mcvs1, bool have_mcvs2, bool *hasmatch1, bool *hasmatch2, int *p_nmatches, RelOptInfo *inner_rel)
get_index_stats_hook_type get_index_stats_hook
Datum matchingjoinsel(PG_FUNCTION_ARGS)
static bool gincost_scalararrayopexpr(PlannerInfo *root, IndexOptInfo *index, int indexcol, ScalarArrayOpExpr *clause, double numIndexEntries, GinQualCounts *counts)
double histogram_selectivity(VariableStatData *vardata, FmgrInfo *opproc, Oid collation, Datum constval, bool varonleft, int min_hist_size, int n_skip, int *hist_size)
static uint32 hash_mcv(MCVHashTable_hash *tab, Datum key)
Selectivity boolvarsel(PlannerInfo *root, Node *arg, int varRelid)
static void examine_indexcol_variable(PlannerInfo *root, IndexOptInfo *index, int indexcol, VariableStatData *vardata)
Datum scalarlesel(PG_FUNCTION_ARGS)
Datum scalargesel(PG_FUNCTION_ARGS)
static double scalarineqsel(PlannerInfo *root, Oid operator, bool isgt, bool iseq, Oid collation, VariableStatData *vardata, Datum constval, Oid consttype)
static double convert_one_bytea_to_scalar(unsigned char *value, int valuelen, int rangelo, int rangehi)
Selectivity scalararraysel(PlannerInfo *root, ScalarArrayOpExpr *clause, bool is_join_clause, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
Datum scalarltsel(PG_FUNCTION_ARGS)
static double btcost_correlation(IndexOptInfo *index, VariableStatData *vardata)
double var_eq_non_const(VariableStatData *vardata, Oid oproid, Oid collation, Node *other, bool varonleft, bool negate)
static bool get_actual_variable_range(PlannerInfo *root, VariableStatData *vardata, Oid sortop, Oid collation, Datum *min, Datum *max)
Datum scalarlejoinsel(PG_FUNCTION_ARGS)
double get_variable_numdistinct(VariableStatData *vardata, bool *isdefault)
bool statistic_proc_security_check(VariableStatData *vardata, Oid func_oid)
void hashcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
Datum neqjoinsel(PG_FUNCTION_ARGS)
double estimate_hashagg_tablesize(PlannerInfo *root, Path *path, const AggClauseCosts *agg_costs, double dNumGroups)
void estimate_hash_bucket_stats(PlannerInfo *root, Node *hashkey, double nbuckets, Selectivity *mcv_freq, Selectivity *bucketsize_frac)
static void convert_bytea_to_scalar(Datum value, double *scaledvalue, Datum lobound, double *scaledlobound, Datum hibound, double *scaledhibound)
Cost index_other_operands_eval_cost(PlannerInfo *root, List *indexquals)
get_relation_stats_hook_type get_relation_stats_hook
Selectivity rowcomparesel(PlannerInfo *root, RowCompareExpr *clause, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
static bool gincost_opexpr(PlannerInfo *root, IndexOptInfo *index, int indexcol, OpExpr *clause, GinQualCounts *counts)
static void ReleaseDummy(HeapTuple tuple)
static char * convert_string_datum(Datum value, Oid typid, Oid collid, bool *failure)
static double eqsel_internal(PG_FUNCTION_ARGS, bool negate)
static void get_stats_slot_range(AttStatsSlot *sslot, Oid opfuncoid, FmgrInfo *opproc, Oid collation, int16 typLen, bool typByVal, Datum *min, Datum *max, bool *p_have_data)
void get_join_variables(PlannerInfo *root, List *args, SpecialJoinInfo *sjinfo, VariableStatData *vardata1, VariableStatData *vardata2, bool *join_is_reversed)
#define DEFAULT_NOT_UNK_SEL
#define ReleaseVariableStats(vardata)
#define CLAMP_PROBABILITY(p)
bool(* get_relation_stats_hook_type)(PlannerInfo *root, RangeTblEntry *rte, AttrNumber attnum, VariableStatData *vardata)
#define DEFAULT_RANGE_INEQ_SEL
bool(* get_index_stats_hook_type)(PlannerInfo *root, Oid indexOid, AttrNumber indexattnum, VariableStatData *vardata)
#define DEFAULT_MATCHING_SEL
#define DEFAULT_NUM_DISTINCT
#define SELFLAG_USED_DEFAULT
#define InitNonVacuumableSnapshot(snapshotdata, vistestp)
void get_tablespace_page_costs(Oid spcid, double *spc_random_page_cost, double *spc_seq_page_cost)
#define BTLessStrategyNumber
#define BTEqualStrategyNumber
NullableDatum args[FLEXIBLE_ARRAY_MEMBER]
Selectivity indexSelectivity
double spc_random_page_cost
bool attHasNormalScan[INDEX_MAX_KEYS]
bool attHasFullScan[INDEX_MAX_KEYS]
FunctionCallInfo hash_fcinfo
FunctionCallInfo equal_fcinfo
MVNDistinctItem items[FLEXIBLE_ARRAY_MEMBER]
#define FirstLowInvalidHeapAttributeNumber
#define TableOidAttributeNumber
#define SelfItemPointerAttributeNumber
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
TupleTableSlot * table_slot_create(Relation relation, List **reglist)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
static Interval * DatumGetIntervalP(Datum X)
static Timestamp DatumGetTimestamp(Datum X)
static TimestampTz DatumGetTimestampTz(Datum X)
Relids pull_varnos(PlannerInfo *root, Node *node)
List * pull_var_clause(Node *node, int flags)
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
#define VM_ALL_VISIBLE(r, b, v)