PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <math.h>
#include "access/htup_details.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_statistic.h"
#include "utils/float.h"
#include "utils/fmgrprotos.h"
#include "utils/lsyscache.h"
#include "utils/multirangetypes.h"
#include "utils/rangetypes.h"
#include "utils/selfuncs.h"
#include "utils/typcache.h"
Go to the source code of this file.
Functions | |
static double | calc_multirangesel (TypeCacheEntry *typcache, VariableStatData *vardata, const MultirangeType *constval, Oid operator) |
static double | default_multirange_selectivity (Oid operator) |
static double | calc_hist_selectivity (TypeCacheEntry *typcache, VariableStatData *vardata, const MultirangeType *constval, Oid operator) |
static double | calc_hist_selectivity_scalar (TypeCacheEntry *typcache, const RangeBound *constbound, const RangeBound *hist, int hist_nvalues, bool equal) |
static int | rbound_bsearch (TypeCacheEntry *typcache, const RangeBound *value, const RangeBound *hist, int hist_length, bool equal) |
static float8 | get_position (TypeCacheEntry *typcache, const RangeBound *value, const RangeBound *hist1, const RangeBound *hist2) |
static float8 | get_len_position (double value, double hist1, double hist2) |
static float8 | get_distance (TypeCacheEntry *typcache, const RangeBound *bound1, const RangeBound *bound2) |
static int | length_hist_bsearch (Datum *length_hist_values, int length_hist_nvalues, double value, bool equal) |
static double | calc_length_hist_frac (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, Datum *length_hist_values, int length_hist_nvalues) |
static double | calc_hist_selectivity_contains (TypeCacheEntry *typcache, const RangeBound *lower, const RangeBound *upper, const RangeBound *hist_lower, int hist_nvalues, Datum *length_hist_values, int length_hist_nvalues) |
Datum | multirangesel (PG_FUNCTION_ARGS) |
|
static |
Definition at line 456 of file multirangetypes_selfuncs.c.
References Assert, ATTSTATSSLOT_VALUES, calc_hist_selectivity_contained(), calc_hist_selectivity_contains(), calc_hist_selectivity_scalar(), DatumGetRangeTypeP(), elog, ERROR, FmgrInfo::fn_oid, free_attstatsslot(), get_attstatsslot(), HeapTupleIsValid, i, RangeBound::infinite, InvalidOid, multirange_get_bounds(), AttStatsSlot::nvalues, OidIsValid, palloc(), range_deserialize(), MultirangeType::rangeCount, TypeCacheEntry::rng_cmp_proc_finfo, TypeCacheEntry::rng_subdiff_finfo, TypeCacheEntry::rngtype, statistic_proc_security_check(), VariableStatData::statsTuple, and AttStatsSlot::values.
Referenced by calc_multirangesel().
|
static |
Definition at line 1131 of file multirangetypes_selfuncs.c.
References calc_length_hist_frac(), get_distance(), get_position(), i, lower(), Min, range_cmp_bounds(), rbound_bsearch(), and upper().
Referenced by calc_hist_selectivity().
|
static |
Definition at line 1252 of file multirangetypes_selfuncs.c.
References calc_length_hist_frac(), get_distance(), get_position(), i, lower(), Min, rbound_bsearch(), and upper().
Referenced by calc_hist_selectivity().
|
static |
Definition at line 707 of file multirangetypes_selfuncs.c.
References equal(), get_position(), Max, and rbound_bsearch().
Referenced by calc_hist_selectivity().
|
static |
Definition at line 966 of file multirangetypes_selfuncs.c.
References Assert, DatumGetFloat8(), equal(), get_len_position(), i, and length_hist_bsearch().
Referenced by calc_hist_selectivity_contained(), and calc_hist_selectivity_contains().
|
static |
Definition at line 291 of file multirangetypes_selfuncs.c.
References ATTSTATSSLOT_NUMBERS, calc_hist_selectivity(), CLAMP_PROBABILITY, default_multirange_selectivity(), elog, ERROR, free_attstatsslot(), get_attstatsslot(), GETSTRUCT, HeapTupleIsValid, InvalidOid, MultirangeIsEmpty, AttStatsSlot::nnumbers, AttStatsSlot::numbers, and VariableStatData::statsTuple.
Referenced by multirangesel().
|
static |
Definition at line 78 of file multirangetypes_selfuncs.c.
References DEFAULT_INEQ_SEL, and DEFAULT_MULTIRANGE_INEQ_SEL.
Referenced by calc_multirangesel(), and multirangesel().
|
static |
Definition at line 918 of file multirangetypes_selfuncs.c.
References DatumGetFloat8(), FmgrInfo::fn_oid, FunctionCall2Coll(), get_float8_infinity(), RangeBound::infinite, RangeBound::lower, OidIsValid, res, TypeCacheEntry::rng_collation, TypeCacheEntry::rng_subdiff_finfo, and RangeBound::val.
Referenced by calc_hist_selectivity_contained(), and calc_hist_selectivity_contains().
|
static |
Definition at line 873 of file multirangetypes_selfuncs.c.
References value.
Referenced by calc_length_hist_frac().
|
static |
Definition at line 794 of file multirangetypes_selfuncs.c.
References DatumGetFloat8(), FmgrInfo::fn_oid, FunctionCall2Coll(), RangeBound::infinite, Max, Min, OidIsValid, TypeCacheEntry::rng_collation, TypeCacheEntry::rng_subdiff_finfo, RangeBound::val, and value.
Referenced by calc_hist_selectivity_contained(), calc_hist_selectivity_contains(), and calc_hist_selectivity_scalar().
|
static |
Definition at line 768 of file multirangetypes_selfuncs.c.
References DatumGetFloat8(), equal(), lower(), upper(), and value.
Referenced by calc_length_hist_frac().
Datum multirangesel | ( | PG_FUNCTION_ARGS | ) |
Definition at line 137 of file multirangetypes_selfuncs.c.
References generate_unaccent_rules::args, calc_multirangesel(), CLAMP_PROBABILITY, DatumGetMultirangeTypeP(), DatumGetRangeTypeP(), default_multirange_selectivity(), get_commutator(), get_restriction_variable(), IsA, lower(), make_multirange(), multirange_get_typcache(), PG_GETARG_INT32, PG_GETARG_OID, PG_GETARG_POINTER, PG_RETURN_FLOAT8, range_serialize(), ReleaseVariableStats, TypeCacheEntry::rngelemtype, TypeCacheEntry::rngtype, root, TypeCacheEntry::type_id, upper(), and VariableStatData::vartype.
|
static |
Definition at line 739 of file multirangetypes_selfuncs.c.
References cmp(), equal(), lower(), range_cmp_bounds(), upper(), and value.
Referenced by calc_hist_selectivity_contained(), calc_hist_selectivity_contains(), and calc_hist_selectivity_scalar().