26#include "utils/fmgrprotos.h"
186 lower.infinite =
false;
188 upper.inclusive =
true;
190 upper.infinite =
false;
256 if (
sslot.nnumbers != 1)
257 elog(
ERROR,
"invalid empty fraction statistic");
320 elog(
ERROR,
"unexpected operator %u",
operator);
404 if (
hslot.nvalues < 2)
423 elog(
ERROR,
"bounds histogram contains an empty range");
441 if (
lslot.nvalues < 2)
579 elog(
ERROR,
"unknown range operator %u",
operator);
724 position =
Max(position, 0.0);
725 position =
Min(position, 1.0);
736 return ((
value->infinite &&
value->lower) ? 0.0 : 1.0);
741 return ((
value->infinite && !
value->lower) ? 1.0 : 0.0);
826 if (
isnan(res) || res < 0.0)
969 if (
PA > 0 ||
PB > 0)
970 area += 0.5 * (
PB +
PA) * (B - A);
989 if (
PA > 0 ||
PB > 0)
990 area += 0.5 * (
PB +
PA) * (B - A);
1036 upper->lower =
true;
#define Assert(condition)
#define OidIsValid(objectId)
bool equal(const void *a, const void *b)
#define palloc_array(type, count)
static float8 get_float8_infinity(void)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
#define PG_RETURN_FLOAT8(x)
#define PG_GETARG_POINTER(n)
#define PG_GETARG_INT32(n)
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
void free_attstatsslot(AttStatsSlot *sslot)
bool get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple, int reqkind, Oid reqop, int flags)
Oid get_commutator(Oid opno)
#define ATTSTATSSLOT_NUMBERS
#define ATTSTATSSLOT_VALUES
#define IsA(nodeptr, _type_)
Datum lower(PG_FUNCTION_ARGS)
Datum upper(PG_FUNCTION_ARGS)
FormData_pg_statistic * Form_pg_statistic
static float8 DatumGetFloat8(Datum X)
int range_cmp_bounds(TypeCacheEntry *typcache, const RangeBound *b1, const RangeBound *b2)
RangeType * range_serialize(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper, bool empty, struct Node *escontext)
void range_deserialize(TypeCacheEntry *typcache, const RangeType *range, RangeBound *lower, RangeBound *upper, bool *empty)
TypeCacheEntry * range_get_typcache(FunctionCallInfo fcinfo, Oid rngtypid)
static RangeType * DatumGetRangeTypeP(Datum X)
static double calc_hist_selectivity_contains(TypeCacheEntry *typcache, const RangeBound *lower, const RangeBound *upper, const RangeBound *hist_lower, int hist_nvalues, const Datum *length_hist_values, int length_hist_nvalues)
static float8 get_position(TypeCacheEntry *typcache, const RangeBound *value, const RangeBound *hist1, const RangeBound *hist2)
static double calc_hist_selectivity_scalar(TypeCacheEntry *typcache, const RangeBound *constbound, const RangeBound *hist, int hist_nvalues, bool equal)
static int length_hist_bsearch(const Datum *length_hist_values, int length_hist_nvalues, double value, bool equal)
static double calc_hist_selectivity(TypeCacheEntry *typcache, VariableStatData *vardata, const RangeType *constval, Oid operator)
static int rbound_bsearch(TypeCacheEntry *typcache, const RangeBound *value, const RangeBound *hist, int hist_length, bool equal)
static double calc_rangesel(TypeCacheEntry *typcache, VariableStatData *vardata, const RangeType *constval, Oid operator)
static double default_range_selectivity(Oid operator)
static float8 get_len_position(double value, double hist1, double hist2)
static double calc_length_hist_frac(const Datum *length_hist_values, int length_hist_nvalues, double length1, double length2, bool equal)
static double calc_hist_selectivity_contained(TypeCacheEntry *typcache, const RangeBound *lower, RangeBound *upper, const RangeBound *hist_lower, int hist_nvalues, const Datum *length_hist_values, int length_hist_nvalues)
Datum rangesel(PG_FUNCTION_ARGS)
static float8 get_distance(TypeCacheEntry *typcache, const RangeBound *bound1, const RangeBound *bound2)
static int cmp(const chr *x, const chr *y, size_t len)
bool get_restriction_variable(PlannerInfo *root, List *args, int varRelid, VariableStatData *vardata, Node **other, bool *varonleft)
bool statistic_proc_security_check(VariableStatData *vardata, Oid func_oid)
#define ReleaseVariableStats(vardata)
#define CLAMP_PROBABILITY(p)
#define DEFAULT_RANGE_INEQ_SEL
FmgrInfo rng_cmp_proc_finfo
struct TypeCacheEntry * rngelemtype
FmgrInfo rng_subdiff_finfo