21#include "utils/fmgrprotos.h"
33#define ARRAY_WIDTH_THRESHOLD 0x10000
117 elog(
ERROR,
"array_typanalyze was invoked for non-array type %u",
284 elements_tab =
hash_create(
"Analyzed elements table",
343 &elem_values, &elem_nulls, &num_elems);
350 for (
j = 0;
j < num_elems;
j++)
440 elog(
ERROR,
"insufficient pg_statistic slots for array stats");
488 elog(
DEBUG3,
"compute_array_stats: target # mces = %d, "
489 "bucket width = %d, "
491 "usable entries = %d",
777 return (*t2)->
frequency - (*t1)->frequency;
801 if ((*t1)->count < (*t2)->count)
803 else if ((*t1)->count == (*t2)->count)
#define DatumGetArrayTypeP(X)
Datum array_typanalyze(PG_FUNCTION_ARGS)
static int trackitem_compare_frequencies_desc(const void *e1, const void *e2, void *arg)
static void compute_array_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, int samplerows, double totalrows)
static int trackitem_compare_element(const void *e1, const void *e2, void *arg)
static int element_match(const void *key1, const void *key2, Size keysize)
static uint32 element_hash(const void *key, Size keysize)
#define ARRAY_WIDTH_THRESHOLD
static int countitem_compare_count(const void *e1, const void *e2, void *arg)
static int element_compare(const void *key1, const void *key2)
static ArrayAnalyzeExtraData * array_extra_data
static void prune_element_hashtable(HTAB *elements_tab, int b_current)
void deconstruct_array(const ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
#define Assert(condition)
#define OidIsValid(objectId)
bool std_typanalyze(VacAttrStats *stats)
Datum datumCopy(Datum value, bool typByVal, int typLen)
Size toast_raw_datum_size(Datum value)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)
void * hash_seq_search(HASH_SEQ_STATUS *status)
int64 hash_get_num_entries(HTAB *hashp)
void hash_seq_init(HASH_SEQ_STATUS *status, HTAB *hashp)
#define palloc_object(type)
#define palloc_array(type, count)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
Datum FunctionCall1Coll(FmgrInfo *flinfo, Oid collation, Datum arg1)
#define PG_GETARG_POINTER(n)
#define PG_RETURN_BOOL(x)
Oid get_base_element_type(Oid typid)
void * MemoryContextAlloc(MemoryContext context, Size size)
void pfree(void *pointer)
MemoryContext CurrentMemoryContext
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
#define STATISTIC_NUM_SLOTS
void qsort_interruptible(void *base, size_t nel, size_t elsize, qsort_arg_comparator cmp, void *arg)
static uint32 DatumGetUInt32(Datum X)
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
static int32 DatumGetInt32(Datum X)
int16 stakind[STATISTIC_NUM_SLOTS]
MemoryContext anl_context
Oid statypid[STATISTIC_NUM_SLOTS]
Oid staop[STATISTIC_NUM_SLOTS]
Oid stacoll[STATISTIC_NUM_SLOTS]
char statypalign[STATISTIC_NUM_SLOTS]
float4 * stanumbers[STATISTIC_NUM_SLOTS]
bool statypbyval[STATISTIC_NUM_SLOTS]
int16 statyplen[STATISTIC_NUM_SLOTS]
int numvalues[STATISTIC_NUM_SLOTS]
Datum * stavalues[STATISTIC_NUM_SLOTS]
int numnumbers[STATISTIC_NUM_SLOTS]
AnalyzeAttrComputeStatsFunc compute_stats
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define TYPECACHE_HASH_PROC_FINFO
#define TYPECACHE_CMP_PROC_FINFO
void vacuum_delay_point(bool is_analyze)
Datum(* AnalyzeAttrFetchFunc)(VacAttrStatsP stats, int rownum, bool *isNull)
void(* AnalyzeAttrComputeStatsFunc)(VacAttrStatsP stats, AnalyzeAttrFetchFunc fetchfunc, int samplerows, double totalrows)