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)
2035 &elem_values, &elem_nulls, &num_elems);
2053 for (
i = 0;
i < num_elems;
i++)
2068 clause->inputcollid,
2076 clause->inputcollid,
2110 &elmlen, &elmbyval);
2121 foreach(l, arrayexpr->elements)
2132 if (!useOr &&
IsA(elem,
Const) && ((
Const *) elem)->constisnull)
2143 clause->inputcollid,
2151 clause->inputcollid,
2191 dummyexpr->collation = clause->inputcollid;
2195 clause->inputcollid,
2203 clause->inputcollid,
2208 s1 = useOr ? 0.0 : 1.0;
2215 for (
i = 0;
i < 10;
i++)
2245 if (arrayexpr &&
IsA(arrayexpr,
Const))
2261 else if (arrayexpr &&
root)
2277 if (
IsA(arrayexpr,
Var) && ((
Var *) arrayexpr)->varno == 0)
2293 if (
sslot.nnumbers > 0)
2344 else if (sjinfo ==
NULL)
2555 elog(
ERROR,
"unrecognized join type: %d",
2749 bool op_is_reversed,
2940 bool op_is_reversed,
2957 fcinfo->args[0].isnull =
false;
2958 fcinfo->args[1].isnull =
false;
2987 op_is_reversed = !op_is_reversed;
3003 hash_fcinfo->args[0].isnull =
false;
3050 hash_fcinfo->args[0].isnull =
false;
3090 fcinfo->args[index1].value =
sslot1->values[
i];
3098 fcinfo->args[index2].value =
sslot2->values[
j];
3099 fcinfo->isnull =
false;
3356 opno = ((
OpExpr *) clause)->opno;
3357 collation = ((
OpExpr *) clause)->inputcollid;
3590 *
leftend += stats->stanullfrac;
3705 if (
varinfo->ndistinct <= ndistinct)
3722 varinfo->ndistinct = ndistinct;
3723 varinfo->isdefault = isdefault;
4175 while (clauses !=
NIL)
4194 foreach(
lc, clauses)
4206 relids = rinfo->outer_is_left ?
4207 rinfo->right_relids : rinfo->left_relids;
4208 expr = rinfo->outer_is_left ?
4212 root->simple_rel_array[relid]->statlist !=
NIL)
4352 Assert(ndistinct >= 1.0);
4445 if (
sslot.nnumbers > 0)
4495 if (ndistinct > nbuckets)
4532 path->pathtarget->width,
4819 elog(
ERROR,
"corrupt MVNDistinct entry");
5202 if (*lobound != *hibound || *lobound != *
value)
5204 lobound++, hibound++,
value++;
5479 return (
double) (
timetz->time + (
timetz->zone * 1000000.0));
5580 elog(
ERROR,
"join operator should take two arguments");
5674 (varRelid == 0 || varRelid == ((
Var *)
basenode)->varno))
5681 vardata->atttype = var->vartype;
5682 vardata->atttypmod = var->vartypmod;
5712 if (varRelid == 0 || varRelid == relid)
5782 for (pos = 0; pos <
index->ncolumns; pos++)
5784 if (
index->indexkeys[pos] == 0)
5789 elog(
ERROR,
"too few entries in indexprs list");
5799 if (
index->unique &&
5800 index->nkeycolumns == 1 &&
5826 elog(
ERROR,
"no function provided to release variable stats with");
5922 if (
equal(node, expr))
5983 if (
root->glob->lastPHId == 0)
6053 elog(
ERROR,
"no function provided to release variable stats with");
6142 levelsup =
rte->ctelevelsup;
6144 while (levelsup-- > 0)
6148 elog(
ERROR,
"bad levelsup for CTE \"%s\"",
rte->ctename);
6166 elog(
ERROR,
"could not find CTE \"%s\"",
rte->ctename);
6168 elog(
ERROR,
"could not find plan for CTE \"%s\"",
rte->ctename);
6171 elog(
ERROR,
"no plan was made for CTE \"%s\"",
rte->ctename);
6176 if (subroot ==
NULL)
6187 subquery = subroot->
parse;
6209 elog(
ERROR,
"subquery %s does not have attribute %d",
6251 if (
rte->security_barrier)
6255 if (var &&
IsA(var,
Var) &&
6354 if (
root->append_rel_array !=
NULL)
6392 for (attno = 1; attno <=
appinfo->num_child_cols; attno++)
6411 if (attno >
appinfo->num_child_cols)
6424 varno =
appinfo->parent_relid;
6438 if (
rte->securityQuals !=
NIL)
6456 if (varattnos ==
NULL)
6514 if (
index->indexkeys[indexcol] != 0)
6522 colnum =
index->indexkeys[indexcol];
6534 elog(
ERROR,
"no function provided to release variable stats with");
6548 relid =
index->indexoid;
6549 colnum = indexcol + 1;
6560 elog(
ERROR,
"no function provided to release variable stats with");
6594 (
errmsg_internal(
"not using statistics because function \"%s\" is not leakproof",
6614 double stanullfrac = 0.0;
6631 stadistinct = stats->stadistinct;
6632 stanullfrac = stats->stanullfrac;
6692 stadistinct = -1.0 * (1.0 - stanullfrac);
6697 if (stadistinct > 0.0)
6708 ntuples =
vardata->rel->tuples;
6718 if (stadistinct < 0.0)
6745 Oid sortop,
Oid collation,
6798 if (
sslot.stacoll == collation &&
sslot.nvalues > 0)
6819 collation, typLen, typByVal,
6845 for (
i = 0;
i <
sslot.nnumbers;
i++)
6854 collation, typLen, typByVal,
6872 Oid collation,
int16 typLen,
bool typByVal,
6886 for (
int i = 0;
i <
sslot->nvalues;
i++)
6935 Oid sortop,
Oid collation,
6976 if (
index->hypothetical)
6983 if (!
index->canreturn[0])
6990 if (collation !=
index->indexcollations[0])
6998 if (
index->reverse_sort[0])
7004 if (
index->reverse_sort[0])
7030 "get_actual_variable_range workspace",
7221#define VISITED_PAGES_LIMIT 100
7248 elog(
ERROR,
"no data returned for index-only scan");
7263 elog(
ERROR,
"found unexpected null value in index \"%s\"",
7304 elog(
ERROR,
"could not find RelOptInfo for given relids");
7326 foreach(
lc, indexclauses)
7356 foreach(
lc, indexquals)
7393 elog(
ERROR,
"unsupported indexqual type: %d",
7418 Cost indexStartupCost;
7419 Cost indexTotalCost;
7421 double indexCorrelation;
7422 double numIndexPages;
7423 double numIndexTuples;
7424 double spc_random_page_cost;
7425 double num_sa_scans;
7446 if (num_sa_scans < 1)
7476 if (numIndexTuples <= 0.0)
7478 numIndexTuples = indexSelectivity *
index->rel->tuples;
7487 numIndexTuples =
rint(numIndexTuples / num_sa_scans);
7495 if (numIndexTuples >
index->tuples)
7496 numIndexTuples =
index->tuples;
7497 if (numIndexTuples < 1.0)
7498 numIndexTuples = 1.0;
7517 numIndexPages = 1.0;
7521 &spc_random_page_cost,
7554 (
double)
index->pages,
7571 indexTotalCost = numIndexPages * spc_random_page_cost;
7600 indexCorrelation = 0.0;
7670 double indexCorrelation = 0;
7675 index->opcintype[0],
7676 index->opcintype[0],
7688 if (
index->reverse_sort[0])
7691 if (
index->nkeycolumns > 1)
7699 return indexCorrelation;
7704 Cost *indexStartupCost,
Cost *indexTotalCost,
7705 Selectivity *indexSelectivity,
double *indexCorrelation,
7711 double numIndexTuples;
7721 double num_sa_scans;
7808 bool isdefault =
true;
7879 ndistinct =
Max(ndistinct, 1);
7911 num_sa_scans *= ndistinct;
7930 if (
index->pages < num_sa_scans)
7949 if (indexcol !=
iclause->indexcol)
7967 clause_op = op->
opno;
7982 clause_op = saop->
opno;
8000 elog(
ERROR,
"unsupported indexqual type: %d",
8007 index->opfamily[indexcol]);
8008 Assert(op_strategy != 0);
8032 if (
index->unique &&
8033 indexcol ==
index->nkeycolumns - 1 &&
8037 numIndexTuples = 1.0;
8079 num_sa_scans =
Min(num_sa_scans,
ceil(
index->pages * 0.3333333));
8080 num_sa_scans =
Max(num_sa_scans, 1);
8101 numIndexTuples =
rint(numIndexTuples / num_sa_scans);
8132 if (
index->tuples > 1)
8176 Cost *indexStartupCost,
Cost *indexTotalCost,
8177 Selectivity *indexSelectivity,
double *indexCorrelation,
8221 Cost *indexStartupCost,
Cost *indexTotalCost,
8222 Selectivity *indexSelectivity,
double *indexCorrelation,
8242 if (
index->tree_height < 0)
8244 if (
index->pages > 1)
8247 index->tree_height = 0;
8255 if (
index->tuples > 1)
8278 Cost *indexStartupCost,
Cost *indexTotalCost,
8279 Selectivity *indexSelectivity,
double *indexCorrelation,
8300 if (
index->tree_height < 0)
8302 if (
index->pages > 1)
8305 index->tree_height = 0;
8313 if (
index->tuples > 1)
8389 index->opcintype[indexcol],
8390 index->opcintype[indexcol],
8396 elog(
ERROR,
"missing support function %d for attribute %d of index \"%s\"",
8405 collation =
index->indexcollations[indexcol];
8429 for (
i = 0;
i < nentries;
i++)
8497 if (((
Const *) operand)->constisnull)
8636 Cost *indexStartupCost,
Cost *indexTotalCost,
8637 Selectivity *indexSelectivity,
double *indexCorrelation,
8644 numTuples =
index->tuples;
8658 spc_random_page_cost,
8670 if (!
index->hypothetical)
8757 &spc_random_page_cost,
8763 *indexCorrelation = 0.0;
8768 memset(&counts, 0,
sizeof(counts));
8806 elog(
ERROR,
"unsupported GIN indexqual type: %d",
8815 *indexStartupCost = 0;
8816 *indexTotalCost = 0;
8817 *indexSelectivity = 0;
8828 for (
i = 0;
i <
index->nkeycolumns;
i++)
8885 *indexStartupCost = 0;
8886 *indexTotalCost = 0;
8973 (numTuples / (
BLCKSZ / 3)));
8997 *indexTotalCost += *indexStartupCost +
9026 Cost *indexStartupCost,
Cost *indexTotalCost,
9027 Selectivity *indexSelectivity,
double *indexCorrelation,
9036 Cost spc_random_page_cost;
9052 &spc_random_page_cost,
9059 if (!
index->hypothetical)
9093 *indexCorrelation = 0;
9113 "no function provided to release variable stats with");
9144 elog(
ERROR,
"no function provided to release variable stats with");
9166 if (
sslot.nnumbers > 0)
9194 if (*indexCorrelation < 1.0e-10)
9204 *indexSelectivity =
selec;
9226 *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)
bool array_contains_nulls(const ArrayType *array)
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 int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
#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, uint32 flags)
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
BlockNumber numNonLeafPages
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(SysCacheIdentifier 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)