107 errmsg(
"only a single relation is allowed in CREATE STATISTICS")));
109 foreach(cell,
stmt->relations)
116 errmsg(
"only a single relation is allowed in CREATE STATISTICS")));
134 errmsg(
"cannot define statistics for relation \"%s\"",
153 errmsg(
"permission denied: \"%s\" is a system catalog",
201 if (
stmt->if_not_exists)
209 errmsg(
"statistics object \"%s\" already exists, skipping",
217 errmsg(
"statistics object \"%s\" already exists",
namestr)));
228 errmsg(
"cannot have more than %d columns in statistics",
244 foreach(cell,
stmt->exprs)
261 errmsg(
"column \"%s\" does not exist",
269 errmsg(
"statistics creation on system columns is not supported")));
275 errmsg(
"statistics creation on virtual generated columns is not supported")));
282 errmsg(
"column \"%s\" cannot be used in statistics because its type %s has no default btree operator class",
285 attnums[nattnums] =
attForm->attnum;
298 errmsg(
"statistics creation on system columns is not supported")));
304 errmsg(
"statistics creation on virtual generated columns is not supported")));
311 errmsg(
"column \"%s\" cannot be used in statistics because its type %s has no default btree operator class",
338 errmsg(
"statistics creation on system columns is not supported")));
344 errmsg(
"statistics creation on virtual generated columns is not supported")));
361 errmsg(
"expression cannot be used in multivariate statistics because its type %s has no default btree operator class",
382 errmsg(
"when building statistics on a single expression, statistics kinds may not be specified")));
389 foreach(cell,
stmt->stat_types)
411 errmsg(
"unrecognized statistics kind \"%s\"",
440 errmsg(
"extended statistics require at least 2 columns")));
453 for (
i = 1;
i < nattnums;
i++)
455 if (attnums[
i] == attnums[
i - 1])
458 errmsg(
"duplicate column name in statistics definition")));
493 errmsg(
"duplicate expression in statistics definition")));
530 memset(nulls,
false,
sizeof(nulls));
576 for (
i = 0;
i < nattnums;
i++)
668 errmsg(
"statistics target %d is too low",
676 errmsg(
"lowering statistics target to %d",
700 (
errmsg(
"statistics object \"%s.%s\" does not exist, skipping",
704 (
errmsg(
"statistics object \"%s\" does not exist, skipping",
715 elog(
ERROR,
"cache lookup failed for extended statistics object %u",
stxoid);
954 result =
stx->stxrelid;
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
int bms_next_member(const Bitmapset *a, int prevbit)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define Assert(condition)
#define OidIsValid(objectId)
bool IsSystemRelation(Relation relation)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
void recordDependencyOnSingleRelExpr(const ObjectAddress *depender, Node *expr, Oid relId, DependencyType behavior, DependencyType self_behavior, bool reverse_self)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
bool allowSystemTableMods
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_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
char * makeObjectName(const char *name1, const char *name2, const char *label)
void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
int2vector * buildint2vector(const int16 *int2s, int n)
void CacheInvalidateRelcache(Relation relation)
void CacheInvalidateRelcacheByRelid(Oid relid)
List * lappend(List *list, void *datum)
#define ShareUpdateExclusiveLock
char get_attgenerated(Oid relid, AttrNumber attnum)
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
char * get_namespace_name(Oid nspid)
char * pstrdup(const char *in)
void pfree(void *pointer)
void namestrcpy(Name name, const char *str)
char * NameListToString(const List *names)
Oid QualifiedNameGetCreationNamespace(const List *names, char **objname_p)
Oid get_statistics_object_oid(List *names, bool missing_ok)
void DeconstructQualifiedName(const List *names, char **nspname_p, char **objname_p)
Oid exprType(const Node *expr)
#define IsA(nodeptr, _type_)
#define InvokeObjectPostCreateHook(classId, objectId, subId)
#define InvokeObjectPostAlterHook(classId, objectId, subId)
ObjectType get_relkind_objtype(char relkind)
const ObjectAddress InvalidObjectAddress
#define ObjectAddressSet(addr, class_id, object_id)
#define ObjectAddressSubSet(addr, class_id, object_id, object_sub_id)
char * nodeToString(const void *obj)
FormData_pg_attribute * Form_pg_attribute
int errdetail_relkind_not_supported(char relkind)
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
#define lfirst_node(type, lc)
static int list_length(const List *l)
void recordDependencyOnOwner(Oid classId, Oid objectId, Oid owner)
FormData_pg_statistic_ext * Form_pg_statistic_ext
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define qsort(a, b, c, d)
size_t strlcpy(char *dst, const char *src, size_t siz)
static Datum PointerGetDatum(const void *X)
static Datum Int16GetDatum(int16 X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static Datum NameGetDatum(const NameData *X)
static Datum CStringGetDatum(const char *X)
static Datum CharGetDatum(char X)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define RelationGetNamespace(relation)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
#define STATS_MAX_DIMENSIONS
ObjectAddress CreateStatistics(CreateStatsStmt *stmt, bool check_rights)
ObjectAddress AlterStatistics(AlterStatsStmt *stmt)
static char * ChooseExtendedStatisticNameAddition(List *exprs)
void RemoveStatisticsDataById(Oid statsOid, bool inh)
static char * ChooseExtendedStatisticName(const char *name1, const char *name2, const char *label, Oid namespaceid)
void RemoveStatisticsById(Oid statsOid)
static int compare_int16(const void *a, const void *b)
Oid StatisticsGetRelation(Oid statId, bool missing_ok)
#define ERRCODE_DUPLICATE_OBJECT
#define FirstLowInvalidHeapAttributeNumber
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
#define SearchSysCacheExists2(cacheId, key1, key2)
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define MAX_STATISTICS_TARGET
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)