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) |
static Node * | get_attr_expr (Relation rel, int attnum) |
static void | get_attr_stat_type (Oid reloid, AttrNumber attnum, Oid *atttypid, int32 *atttypmod, char *atttyptype, Oid *atttypcoll, Oid *eq_opr, Oid *lt_opr) |
static bool | get_elem_stat_type (Oid atttypid, char atttyptype, Oid *elemtypid, Oid *elem_eq_opr) |
static Datum | text_to_stavalues (const char *staname, FmgrInfo *array_in, Datum d, Oid typid, int32 typmod, 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_clear_attribute_stats (PG_FUNCTION_ARGS) |
Datum | pg_restore_attribute_stats (PG_FUNCTION_ARGS) |
Variables | |
static struct StatsArgInfo | attarginfo [] |
static struct StatsArgInfo | cleararginfo [] |
#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.
Enumerator | |
---|---|
C_ATTRELSCHEMA_ARG | |
C_ATTRELNAME_ARG | |
C_ATTNAME_ARG | |
C_INHERITED_ARG | |
C_NUM_ATTRIBUTE_STATS_ARGS |
Definition at line 83 of file attribute_stats.c.
|
static |
Definition at line 138 of file attribute_stats.c.
References attarginfo, attname, ATTNAME_ARG, attnum, ATTNUM_ARG, ATTRELNAME_ARG, ATTRELSCHEMA_ARG, AVG_WIDTH_ARG, construct_array_builtin(), CORRELATION_ARG, ELEM_COUNT_HISTOGRAM_ARG, ereport, errcode(), errdetail(), errhint(), errmsg(), ERROR, fmgr_info(), get_attname(), get_attnum(), get_attr_stat_type(), get_elem_stat_type(), 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, NULL_FRAC_ARG, OidIsValid, PG_ARGISNULL, PG_GETARG_BOOL, PG_GETARG_DATUM, PG_GETARG_INT16, PointerGetDatum(), RANGE_BOUNDS_HISTOGRAM_ARG, RANGE_EMPTY_FRAC_ARG, RANGE_LENGTH_HISTOGRAM_ARG, RecoveryInProgress(), RelationGetDescr, ReleaseSysCache(), relname, RowExclusiveLock, SearchSysCache3(), SearchSysCacheExistsAttName(), set_stats_slot(), stats_check_arg_array(), stats_check_arg_pair(), stats_check_required_arg(), stats_lock_check_privileges(), stats_lookup_relid(), table_close(), table_open(), text_to_stavalues(), TextDatumGetCString, upsert_pg_statistic(), values, and WARNING.
Referenced by pg_restore_attribute_stats().
|
static |
Definition at line 841 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 533 of file attribute_stats.c.
References attnum, elog, ERROR, i, lfirst, list_head(), lnext(), NIL, RelationData::rd_index, RelationData::rd_indexprs, RelationData::rd_rel, and RelationGetIndexExpressions().
Referenced by get_attr_stat_type().
|
static |
Definition at line 572 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 654 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 871 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 909 of file attribute_stats.c.
References attname, attnum, C_ATTNAME_ARG, C_ATTRELNAME_ARG, C_ATTRELSCHEMA_ARG, C_INHERITED_ARG, cleararginfo, delete_pg_statistic(), ereport, errcode(), errhint(), errmsg(), ERROR, get_attnum(), get_rel_name(), InvalidAttrNumber, PG_GETARG_BOOL, PG_GETARG_DATUM, PG_RETURN_VOID, RecoveryInProgress(), relname, stats_check_required_arg(), stats_lock_check_privileges(), stats_lookup_relid(), and TextDatumGetCString.
Datum pg_restore_attribute_stats | ( | PG_FUNCTION_ARGS | ) |
Definition at line 984 of file attribute_stats.c.
References attarginfo, attribute_statistics_update(), InitFunctionCallInfoData, InvalidOid, LOCAL_FCINFO, NUM_ATTRIBUTE_STATS_ARGS, PG_RETURN_BOOL, and stats_fill_fcinfo_from_arg_pairs().
|
static |
Definition at line 747 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 694 of file attribute_stats.c.
References array_contains_nulls(), array_in(), CStringGetDatum(), DatumGetArrayTypeP, ErrorSaveContext::details_wanted, ErrorData::elevel, ereport, errcode(), errmsg(), ErrorSaveContext::error_data, ErrorSaveContext::error_occurred, FunctionCallInvoke, InitFunctionCallInfoData, Int32GetDatum(), InvalidOid, LOCAL_FCINFO, ObjectIdGetDatum(), pfree(), TextDatumGetCString, ThrowErrorData(), and WARNING.
Referenced by attribute_statistics_update().
|
static |
Definition at line 815 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 60 of file attribute_stats.c.
Referenced by attribute_statistics_update(), and pg_restore_attribute_stats().
|
static |
Definition at line 92 of file attribute_stats.c.
Referenced by pg_clear_attribute_stats().