PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/heapam.h"
#include "catalog/indexing.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_operator.h"
#include "nodes/nodeFuncs.h"
#include "statistics/statistics.h"
#include "statistics/stat_utils.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
Go to the source code of this file.
Macros | |
#define | DEFAULT_NULL_FRAC Float4GetDatum(0.0) |
#define | DEFAULT_AVG_WIDTH Int32GetDatum(0) /* unknown */ |
#define | DEFAULT_N_DISTINCT Float4GetDatum(0.0) /* unknown */ |
Functions | |
static bool | attribute_statistics_update (FunctionCallInfo fcinfo, int elevel) |
static Node * | get_attr_expr (Relation rel, int attnum) |
static void | get_attr_stat_type (Oid reloid, AttrNumber attnum, int elevel, Oid *atttypid, int32 *atttypmod, char *atttyptype, Oid *atttypcoll, Oid *eq_opr, Oid *lt_opr) |
static bool | get_elem_stat_type (Oid atttypid, char atttyptype, int elevel, Oid *elemtypid, Oid *elem_eq_opr) |
static Datum | text_to_stavalues (const char *staname, FmgrInfo *array_in, Datum d, Oid typid, int32 typmod, int elevel, bool *ok) |
static void | set_stats_slot (Datum *values, bool *nulls, bool *replaces, int16 stakind, Oid staop, Oid stacoll, Datum stanumbers, bool stanumbers_isnull, Datum stavalues, bool stavalues_isnull) |
static void | upsert_pg_statistic (Relation starel, HeapTuple oldtup, Datum *values, bool *nulls, bool *replaces) |
static bool | delete_pg_statistic (Oid reloid, AttrNumber attnum, bool stainherit) |
static void | init_empty_stats_tuple (Oid reloid, int16 attnum, bool inherited, Datum *values, bool *nulls, bool *replaces) |
Datum | pg_set_attribute_stats (PG_FUNCTION_ARGS) |
Datum | pg_clear_attribute_stats (PG_FUNCTION_ARGS) |
Datum | pg_restore_attribute_stats (PG_FUNCTION_ARGS) |
Variables | |
static struct StatsArgInfo | attarginfo [] |
#define DEFAULT_AVG_WIDTH Int32GetDatum(0) /* unknown */ |
Definition at line 34 of file attribute_stats.c.
#define DEFAULT_N_DISTINCT Float4GetDatum(0.0) /* unknown */ |
Definition at line 35 of file attribute_stats.c.
#define DEFAULT_NULL_FRAC Float4GetDatum(0.0) |
Definition at line 33 of file attribute_stats.c.
Definition at line 37 of file attribute_stats.c.
|
static |
Definition at line 116 of file attribute_stats.c.
References attarginfo, attname, ATTNAME_ARG, attnum, ATTRELATION_ARG, AVG_WIDTH_ARG, construct_array_builtin(), CORRELATION_ARG, ELEM_COUNT_HISTOGRAM_ARG, ereport, errcode(), errdetail(), errhint(), errmsg(), ERROR, fmgr_info(), get_attnum(), get_attr_stat_type(), get_elem_stat_type(), get_rel_name(), heap_deform_tuple(), HeapTupleIsValid, HISTOGRAM_BOUNDS_ARG, INHERITED_ARG, init_empty_stats_tuple(), InvalidAttrNumber, InvalidOid, MOST_COMMON_ELEM_FREQS_ARG, MOST_COMMON_ELEMS_ARG, MOST_COMMON_FREQS_ARG, MOST_COMMON_VALS_ARG, N_DISTINCT_ARG, NameStr, NULL_FRAC_ARG, OidIsValid, PG_ARGISNULL, PG_GETARG_BOOL, PG_GETARG_DATUM, PG_GETARG_NAME, PG_GETARG_OID, PointerGetDatum(), RANGE_BOUNDS_HISTOGRAM_ARG, RANGE_EMPTY_FRAC_ARG, RANGE_LENGTH_HISTOGRAM_ARG, RecoveryInProgress(), RelationGetDescr, ReleaseSysCache(), RowExclusiveLock, SearchSysCache3(), set_stats_slot(), stats_check_arg_array(), stats_check_arg_pair(), stats_check_required_arg(), stats_lock_check_privileges(), table_close(), table_open(), text_to_stavalues(), upsert_pg_statistic(), and values.
Referenced by pg_restore_attribute_stats(), and pg_set_attribute_stats().
|
static |
Definition at line 776 of file attribute_stats.c.
References attnum, BoolGetDatum(), CatalogTupleDelete(), CommandCounterIncrement(), HeapTupleIsValid, Int16GetDatum(), ObjectIdGetDatum(), ReleaseSysCache(), RowExclusiveLock, SearchSysCache3(), HeapTupleData::t_self, table_close(), and table_open().
Referenced by pg_clear_attribute_stats().
Definition at line 481 of file attribute_stats.c.
References attnum, elog, ERROR, i, lfirst, list_head(), lnext(), NIL, RelationData::rd_index, RelationData::rd_indexprs, and RelationData::rd_rel.
Referenced by get_attr_stat_type().
|
static |
Definition at line 506 of file attribute_stats.c.
References AccessShareLock, attnum, TypeCacheEntry::eq_opr, ereport, errcode(), errmsg(), ERROR, exprCollation(), exprType(), exprTypmod(), get_attr_expr(), get_multirange_range(), GETSTRUCT, HeapTupleIsValid, Int16GetDatum(), lookup_type_cache(), TypeCacheEntry::lt_opr, NoLock, ObjectIdGetDatum(), OidIsValid, relation_close(), relation_open(), RelationGetRelationName, ReleaseSysCache(), SearchSysCache2(), type_is_multirange(), TYPECACHE_EQ_OPR, TYPECACHE_LT_OPR, and TypeCacheEntry::typtype.
Referenced by attribute_statistics_update().
|
static |
Definition at line 588 of file attribute_stats.c.
References TypeCacheEntry::eq_opr, get_base_element_type(), lookup_type_cache(), OidIsValid, and TYPECACHE_EQ_OPR.
Referenced by attribute_statistics_update().
|
static |
Definition at line 806 of file attribute_stats.c.
References attnum, BoolGetDatum(), DEFAULT_AVG_WIDTH, DEFAULT_N_DISTINCT, DEFAULT_NULL_FRAC, Int16GetDatum(), InvalidOid, ObjectIdGetDatum(), STATISTIC_NUM_SLOTS, and values.
Referenced by attribute_statistics_update().
Datum pg_clear_attribute_stats | ( | PG_FUNCTION_ARGS | ) |
Definition at line 871 of file attribute_stats.c.
References attarginfo, attname, ATTNAME_ARG, attnum, ATTRELATION_ARG, delete_pg_statistic(), ereport, errcode(), errhint(), errmsg(), ERROR, get_attnum(), get_rel_name(), INHERITED_ARG, InvalidAttrNumber, NameStr, PG_GETARG_BOOL, PG_GETARG_NAME, PG_GETARG_OID, PG_RETURN_VOID, RecoveryInProgress(), stats_check_required_arg(), and stats_lock_check_privileges().
Datum pg_restore_attribute_stats | ( | PG_FUNCTION_ARGS | ) |
Definition at line 913 of file attribute_stats.c.
References attarginfo, attribute_statistics_update(), InitFunctionCallInfoData, InvalidOid, LOCAL_FCINFO, NUM_ATTRIBUTE_STATS_ARGS, PG_RETURN_BOOL, stats_fill_fcinfo_from_arg_pairs(), and WARNING.
Datum pg_set_attribute_stats | ( | PG_FUNCTION_ARGS | ) |
Definition at line 861 of file attribute_stats.c.
References attribute_statistics_update(), ERROR, and PG_RETURN_VOID.
|
static |
Definition at line 682 of file attribute_stats.c.
References DatumGetInt16(), DatumGetObjectId(), ereport, errmsg(), ERROR, Int16GetDatum(), ObjectIdGetDatum(), STATISTIC_NUM_SLOTS, and values.
Referenced by attribute_statistics_update().
|
static |
Definition at line 628 of file attribute_stats.c.
References array_contains_nulls(), array_in(), CStringGetDatum(), DatumGetArrayTypeP, ErrorSaveContext::details_wanted, ErrorData::elevel, ereport, errcode(), errmsg(), ERROR, ErrorSaveContext::error_data, ErrorSaveContext::error_occurred, FunctionCallInvoke, InitFunctionCallInfoData, Int32GetDatum(), InvalidOid, LOCAL_FCINFO, ObjectIdGetDatum(), pfree(), TextDatumGetCString, and ThrowErrorData().
Referenced by attribute_statistics_update().
|
static |
Definition at line 750 of file attribute_stats.c.
References CatalogTupleInsert(), CatalogTupleUpdate(), CommandCounterIncrement(), heap_form_tuple(), heap_freetuple(), heap_modify_tuple(), HeapTupleIsValid, RelationGetDescr, HeapTupleData::t_self, and values.
Referenced by attribute_statistics_update().
|
static |
Definition at line 1 of file attribute_stats.c.
Referenced by attribute_statistics_update(), pg_clear_attribute_stats(), and pg_restore_attribute_stats().