22#include "catalog/pg_collation_d.h"
36#include "utils/fmgroids.h"
117 "most_common_elem_freqs",
118 "elem_count_histogram",
119 "range_length_histogram",
121 "range_bounds_histogram"
237 elog(
ERROR,
"stxkind is not a one-dimension char array");
258 elog(
ERROR,
"incorrect stxkind %c found", kinds[
i]);
370 errmsg(
"recovery is in progress"),
371 errhint(
"Statistics cannot be modified during recovery."));
404 errmsg(
"could not find schema \"%s\"", nspname));
416 errmsg(
"could not find extended statistics object \"%s.%s\"",
428 if (
stxform->stxrelid != relid)
432 errmsg(
"could not restore extended statistics object \"%s.%s\": incorrect relation \"%s.%s\" specified",
484 errmsg(
"cannot specify parameter \"%s\"",
486 errhint(
"Extended statistics object \"%s.%s\" does not support statistics of this type.",
489 has.ndistinct =
false;
501 errmsg(
"cannot specify parameter \"%s\"",
503 errhint(
"Extended statistics object \"%s.%s\" does not support statistics of this type.",
505 has.dependencies =
false;
523 errmsg(
"cannot specify parameters \"%s\", \"%s\" or \"%s\"",
527 errhint(
"Extended statistics object \"%s.%s\" does not support statistics of this type.",
547 errmsg(
"could not use \"%s\", \"%s\" and \"%s\": missing one or more parameters",
563 errmsg(
"cannot specify parameter \"%s\"",
565 errhint(
"Extended statistics object \"%s.%s\" does not support statistics of this type.",
568 has.expressions =
false;
581 if (
has.mcv ||
has.expressions)
607 if (attr->attisdropped)
611 atttypmods[
i] = attr->atttypmod;
675 if (
has.dependencies)
761 if (atttypmods !=
NULL)
780 errmsg(
"could not parse array \"%s\": incorrect number of dimensions (%d required)",
789 errmsg(
"could not parse array \"%s\": NULL value found",
798 errmsg(
"could not parse array \"%s\": incorrect number of elements (same as \"%s\" required)",
833 errmsg(
"could not parse array \"%s\": incorrect number of dimensions (%d required)",
842 errmsg(
"could not parse array \"%s\": found %d attributes but expected %d",
951 errmsg(
"could not import element in expression %d: invalid key name",
986 .details_wanted =
true
993 (
Node *) &escontext, datum);
1005 "Element \"%s\" in expression %d could not be parsed.",
1036 .details_wanted =
true
1044 fcinfo->args[0].isnull =
false;
1046 fcinfo->args[1].isnull =
false;
1048 fcinfo->args[2].isnull =
false;
1064 "Element \"%s\" in expression %d could not be parsed.",
1077 errmsg(
"could not import element \"%s\" in expression %d: null value found",
1122 errmsg(
"could not parse \"%s\": invalid element in expression %d",
1153 errhint(
"Value of element \"%s\" must be type a null or a string.", s));
1172 errmsg(
"could not parse \"%s\": invalid element in expression %d",
1174 errhint(
"\"%s\" and \"%s\" must be both either strings or nulls.",
1183 errmsg(
"could not parse \"%s\": invalid element in expression %d",
1185 errhint(
"\"%s\" and \"%s\" must be both either strings or nulls.",
1200 errmsg(
"could not parse \"%s\": invalid element in expression %d",
1202 errhint(
"\"%s\", \"%s\", and \"%s\" must be all either strings or all nulls.",
1234 errmsg(
"could not parse \"%s\": invalid element type in expression %d",
1253 errmsg(
"could not parse \"%s\": invalid data in expression %d",
1255 errhint(
"\"%s\", \"%s\", and \"%s\" can only be set for a range type.",
1342 stanumbers,
false, stavalues,
false);
1363 0,
true, stavalues,
false);
1382 stanumbers,
false, 0,
true);
1415 stanumbers,
false, stavalues,
false);
1471 0,
true, stavalues,
false);
1504 stanumbers,
false, stavalues,
false);
1557 errmsg(
"could not parse \"%s\": root-level array required",
argname));
1572 errmsg(
"could not parse \"%s\": incorrect number of elements (%d required)",
1591 bool isnull =
false;
1632 errmsg(
"could not parse \"%s\": invalid element in expression %d",
1669 bool result =
false;
1751 errmsg(
"recovery is in progress"),
1752 errhint(
"Statistics cannot be modified during recovery."));
1772 errmsg(
"could not find schema \"%s\"", nspname));
1784 errmsg(
"could not find extended statistics object \"%s.%s\"",
1795 if (
stxform->stxrelid != relid)
1800 errmsg(
"could not clear extended statistics object \"%s.%s\": incorrect relation \"%s.%s\" specified",
#define PG_GETARG_ARRAYTYPE_P(n)
#define DatumGetArrayTypeP(X)
ArrayBuildState * accumArrayResult(ArrayBuildState *astate, Datum dvalue, bool disnull, Oid element_type, MemoryContext rcontext)
bool array_contains_nulls(const ArrayType *array)
Datum array_in(PG_FUNCTION_ARGS)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
void deconstruct_array_builtin(const ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
Datum makeArrayResult(ArrayBuildState *astate, MemoryContext rcontext)
#define InvalidAttrNumber
static Datum values[MAXATTR]
static void cleanup(void)
#define TextDatumGetCString(d)
#define Assert(condition)
#define OidIsValid(objectId)
Node * eval_const_expressions(PlannerInfo *root, Node *node)
MVDependencies * statext_dependencies_deserialize(bytea *data)
bool statext_dependencies_validate(const MVDependencies *dependencies, const int2vector *stxkeys, int numexprs, int elevel)
void statext_dependencies_free(MVDependencies *dependencies)
void ThrowErrorData(ErrorData *edata)
int errcode(int sqlerrcode)
int errhint(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
static bool key_in_expr_argnames(JsonbValue *key)
@ NUM_EXTENDED_STATS_ARGS
@ MOST_COMMON_BASE_FREQS_ARG
Datum pg_clear_extended_stats(PG_FUNCTION_ARGS)
static void upsert_pg_statistic_ext_data(const Datum *values, const bool *nulls, const bool *replaces)
static Datum import_expressions(Relation pgsd, int numexprs, Oid *atttypids, int32 *atttypmods, Oid *atttypcolls, Jsonb *exprs_jsonb, bool *exprs_is_perfect)
static bool delete_pg_statistic_ext_data(Oid stxoid, bool inherited)
static struct StatsArgInfo extarginfo[]
Datum pg_restore_extended_stats(PG_FUNCTION_ARGS)
extended_stats_exprs_element
@ MOST_COMMON_ELEM_FREQS_ELEM
@ NUM_ATTRIBUTE_STATS_ELEMS
@ ELEM_COUNT_HISTOGRAM_ELEM
@ RANGE_LENGTH_HISTOGRAM_ELEM
@ RANGE_BOUNDS_HISTOGRAM_ELEM
static bool jbv_to_infunc_datum(JsonbValue *jval, PGFunction func, AttrNumber exprnum, const char *argname, Datum *datum)
static Datum import_pg_statistic(Relation pgsd, JsonbContainer *cont, AttrNumber exprnum, FmgrInfo *array_in_fn, Oid typid, int32 typmod, Oid typcoll, bool *pg_statistic_ok)
static void expand_stxkind(HeapTuple tup, StakindFlags *enabled)
static char * jbv_string_get_cstr(JsonbValue *jval)
static HeapTuple get_pg_statistic_ext(Relation pg_stext, Oid nspoid, const char *stxname)
static Datum array_in_safe(FmgrInfo *array_in, const char *s, Oid typid, int32 typmod, AttrNumber exprnum, const char *element_name, bool *ok)
static bool extended_statistics_update(FunctionCallInfo fcinfo)
static bool check_all_expr_argnames_valid(JsonbContainer *cont, AttrNumber exprnum)
static const char * extexprargname[NUM_ATTRIBUTE_STATS_ELEMS]
static bool check_mcvlist_array(const ArrayType *arr, int argindex, int required_ndims, int mcv_length)
static Datum import_mcv(const ArrayType *mcv_arr, const ArrayType *freqs_arr, const ArrayType *base_freqs_arr, Oid *atttypids, int32 *atttypmods, Oid *atttypcolls, int numattrs, bool *ok)
#define palloc0_array(type, count)
Datum float4in(PG_FUNCTION_ARGS)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
bool DirectInputFunctionCallSafe(PGFunction func, char *str, Oid typioparam, int32 typmod, Node *escontext, Datum *result)
#define DatumGetByteaPP(X)
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
#define PG_GETARG_DATUM(n)
#define LOCAL_FCINFO(name, nargs)
#define FunctionCallInvoke(fcinfo)
#define PG_GETARG_BOOL(n)
Datum(* PGFunction)(FunctionCallInfo fcinfo)
#define PG_RETURN_BOOL(x)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
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)
Datum heap_copy_tuple_as_datum(HeapTuple tuple, TupleDesc tupleDesc)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
Datum int4in(PG_FUNCTION_ARGS)
#define JsonContainerSize(jc)
#define JB_ROOT_IS_ARRAY(jbp_)
#define PG_GETARG_JSONB_P(x)
#define JsonContainerIsObject(jc)
JsonbValue * getKeyJsonValueFromContainer(JsonbContainer *container, const char *keyVal, int keyLen, JsonbValue *res)
JsonbIterator * JsonbIteratorInit(JsonbContainer *container)
JsonbIteratorToken JsonbIteratorNext(JsonbIterator **it, JsonbValue *val, bool skipNested)
JsonbValue * getIthJsonbValueFromContainer(JsonbContainer *container, uint32 i)
#define ShareUpdateExclusiveLock
Oid get_multirange_range(Oid multirangeOid)
Oid get_rel_type_id(Oid relid)
char * get_namespace_name(Oid nspid)
bool type_is_multirange(Oid typid)
RangeVar * makeRangeVar(char *schemaname, char *relname, int location)
Datum statext_mcv_import(int elevel, int numattrs, Oid *atttypids, int32 *atttypmods, Oid *atttypcolls, int nitems, Datum *mcv_elems, bool *mcv_nulls, float8 *freqs, float8 *base_freqs)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
void statext_ndistinct_free(MVNDistinct *ndistinct)
MVNDistinct * statext_ndistinct_deserialize(bytea *data)
bool statext_ndistinct_validate(const MVNDistinct *ndistinct, const int2vector *stxkeys, int numexprs, int elevel)
Oid get_namespace_oid(const char *nspname, bool missing_ok)
Oid RangeVarGetRelidExtended(const RangeVar *relation, LOCKMODE lockmode, uint32 flags, RangeVarGetRelidCallback callback, void *callback_arg)
Oid exprType(const Node *expr)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
void fix_opfuncids(Node *node)
FormData_pg_attribute * Form_pg_attribute
static int list_length(const List *l)
static void * list_nth(const List *list, int n)
END_CATALOG_STRUCT typedef FormData_pg_statistic_ext * Form_pg_statistic_ext
static Datum PointerGetDatum(const void *X)
static Datum Int16GetDatum(int16 X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
void * stringToNode(const char *str)
#define RelationGetDescr(relation)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
bool statatt_get_elem_type(Oid atttypid, char atttyptype, Oid *elemtypid, Oid *elem_eq_opr)
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)
void stats_check_required_arg(FunctionCallInfo fcinfo, struct StatsArgInfo *arginfo, int argnum)
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)
#define BTEqualStrategyNumber
void appendStringInfo(StringInfo str, const char *fmt,...)
void initStringInfo(StringInfo str)
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache2(SysCacheIdentifier cacheId, Datum key1, Datum key2)
Datum SysCacheGetAttrNotNull(SysCacheIdentifier cacheId, HeapTuple tup, AttrNumber attributeNumber)
Datum SysCacheGetAttr(SysCacheIdentifier cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
#define SearchSysCacheCopy1(cacheId, key1)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
void CommandCounterIncrement(void)
bool RecoveryInProgress(void)
static zic_t corr[TZ_MAX_LEAPS]