29#include "utils/fmgroids.h"
153 errmsg(
"recovery is in progress"),
154 errhint(
"Statistics cannot be modified during recovery.")));
167 errmsg(
"cannot specify both \"%s\" and \"%s\"",
"attname",
"attnum")));
174 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
186 errmsg(
"column %d of relation \"%s\" does not exist",
193 errmsg(
"must specify either \"%s\" or \"%s\"",
"attname",
"attnum")));
201 errmsg(
"cannot modify statistics on system column \"%s\"",
298 &atttypid, &atttypmod,
309 (
errmsg(
"could not determine element type of column \"%s\"",
attname),
311 "STATISTIC_KIND_MCELEM",
"STATISTIC_KIND_DECHIST")));
326 errmsg(
"could not determine less-than operator for column \"%s\"",
attname),
328 "STATISTIC_KIND_HISTOGRAM",
"STATISTIC_KIND_CORRELATION")));
343 "STATISTIC_KIND_RANGE_LENGTH_HISTOGRAM",
"STATISTIC_KIND_BOUNDS_HISTOGRAM")));
402 errmsg(
"could not parse \"%s\": incorrect number of elements (same as \"%s\" required)",
404 "most_common_freqs")));
412 stanumbers,
false, stavalues,
false);
436 0,
true, stavalues,
false);
452 stanumbers,
false, 0,
true);
473 stanumbers,
false, stavalues,
false);
487 stanumbers,
false, 0,
true);
514 0,
true, stavalues,
false);
541 stanumbers,
false, stavalues,
false);
637 errmsg(
"recovery is in progress"),
638 errhint(
"Statistics cannot be modified during recovery.")));
650 errmsg(
"cannot clear statistics on system column \"%s\"",
656 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
758 errmsg(
"column %d of relation \"%s\" does not exist",
#define DatumGetArrayTypeP(X)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
#define InvalidAttrNumber
static bool delete_pg_statistic(Oid reloid, AttrNumber attnum, bool stainherit)
@ RANGE_LENGTH_HISTOGRAM_ARG
@ RANGE_BOUNDS_HISTOGRAM_ARG
@ NUM_ATTRIBUTE_STATS_ARGS
@ ELEM_COUNT_HISTOGRAM_ARG
@ MOST_COMMON_ELEM_FREQS_ARG
static struct StatsArgInfo cleararginfo[]
static void upsert_pg_statistic(Relation starel, HeapTuple oldtup, const Datum *values, const bool *nulls, const bool *replaces)
static struct StatsArgInfo attarginfo[]
static bool attribute_statistics_update(FunctionCallInfo fcinfo)
clear_attribute_stats_argnum
@ C_NUM_ATTRIBUTE_STATS_ARGS
Datum pg_clear_attribute_stats(PG_FUNCTION_ARGS)
bool delete_attribute_statistics(Relation rel, AttrNumber attnum, bool inherited)
bool import_attribute_statistics(Relation rel, AttrNumber attnum, bool inherited, const NullableDatum *version, const NullableDatum *null_frac, const NullableDatum *avg_width, const NullableDatum *n_distinct, const NullableDatum *most_common_vals, const NullableDatum *most_common_freqs, const NullableDatum *histogram_bounds, const NullableDatum *correlation, const NullableDatum *most_common_elems, const NullableDatum *most_common_elem_freqs, const NullableDatum *elem_count_histogram, const NullableDatum *range_length_histogram, const NullableDatum *range_empty_frac, const NullableDatum *range_bounds_histogram)
static bool attribute_statistics_update_internal(Oid reloid, const char *attname, AttrNumber attnum, bool inherited, FunctionCallInfo fcinfo)
Datum pg_restore_attribute_stats(PG_FUNCTION_ARGS)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define TextDatumGetCString(d)
#define Assert(condition)
#define OidIsValid(objectId)
int errcode(int sqlerrcode)
int errhint(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
#define PG_GETARG_DATUM(n)
#define LOCAL_FCINFO(name, nargs)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_BOOL(x)
#define PG_GETARG_INT16(n)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_deform_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *values, bool *isnull)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
#define ShareUpdateExclusiveLock
char * get_rel_name(Oid relid)
AttrNumber get_attnum(Oid relid, const char *attname)
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
char * get_namespace_name(Oid nspid)
RangeVar * makeRangeVar(char *schemaname, char *relname, int location)
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
static Datum Int16GetDatum(int16 X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
#define PointerGetDatum(X)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define RelationGetNamespace(relation)
bool statatt_get_elem_type(Oid atttypid, char atttyptype, Oid *elemtypid, Oid *elem_eq_opr)
Datum statatt_build_stavalues(const char *staname, FmgrInfo *array_in, Datum d, Oid typid, int32 typmod, bool *ok)
bool stats_fill_fcinfo_from_arg_pairs(FunctionCallInfo pairs_fcinfo, FunctionCallInfo positional_fcinfo, struct StatsArgInfo *arginfo)
void RangeVarCallbackForStats(const RangeVar *relation, Oid relId, Oid oldRelId, void *arg)
void statatt_init_empty_tuple(Oid reloid, int16 attnum, bool inherited, Datum *values, bool *nulls, bool *replaces)
bool stats_check_arg_array(FunctionCallInfo fcinfo, struct StatsArgInfo *arginfo, int argnum)
void statatt_get_type(Oid reloid, AttrNumber attnum, Oid *atttypid, int32 *atttypmod, char *atttyptype, Oid *atttypcoll, Oid *eq_opr, Oid *lt_opr)
void stats_check_required_arg(FunctionCallInfo fcinfo, struct StatsArgInfo *arginfo, int argnum)
bool statatt_check_bounds_histogram(Datum arrayval)
void statatt_set_slot(Datum *values, bool *nulls, bool *replaces, int16 stakind, Oid staop, Oid stacoll, Datum stanumbers, bool stanumbers_isnull, Datum stavalues, bool stavalues_isnull)
bool stats_check_arg_pair(FunctionCallInfo fcinfo, struct StatsArgInfo *arginfo, int argnum1, int argnum2)
void ReleaseSysCache(HeapTuple tuple)
bool SearchSysCacheExistsAttName(Oid relid, const char *attname)
HeapTuple SearchSysCache3(SysCacheIdentifier cacheId, Datum key1, Datum key2, Datum key3)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
void CommandCounterIncrement(void)
bool RecoveryInProgress(void)