PostgreSQL Source Code git master
|
#include "postgres.h"
#include <math.h>
#include "catalog/pg_statistic_ext.h"
#include "catalog/pg_statistic_ext_data.h"
#include "lib/stringinfo.h"
#include "statistics/extended_stats_internal.h"
#include "statistics/statistics.h"
#include "utils/fmgrprotos.h"
#include "utils/syscache.h"
#include "utils/typcache.h"
#include "varatt.h"
Go to the source code of this file.
Data Structures | |
struct | CombinationGenerator |
Macros | |
#define | SizeOfHeader (3 * sizeof(uint32)) |
#define | SizeOfItem(natts) (sizeof(double) + sizeof(int) + (natts) * sizeof(AttrNumber)) |
#define | MinSizeOfItem SizeOfItem(2) |
#define | MinSizeOfItems(nitems) (SizeOfHeader + (nitems) * MinSizeOfItem) |
Typedefs | |
typedef struct CombinationGenerator | CombinationGenerator |
#define MinSizeOfItem SizeOfItem(2) |
Definition at line 52 of file mvdistinct.c.
#define MinSizeOfItems | ( | nitems | ) | (SizeOfHeader + (nitems) * MinSizeOfItem) |
Definition at line 55 of file mvdistinct.c.
#define SizeOfHeader (3 * sizeof(uint32)) |
Definition at line 45 of file mvdistinct.c.
#define SizeOfItem | ( | natts | ) | (sizeof(double) + sizeof(int) + (natts) * sizeof(AttrNumber)) |
Definition at line 48 of file mvdistinct.c.
typedef struct CombinationGenerator CombinationGenerator |
|
static |
Definition at line 521 of file mvdistinct.c.
References f1.
Referenced by ndistinct_for_combination().
|
static |
Definition at line 692 of file mvdistinct.c.
References generate_combinations_recurse(), palloc0(), and pfree().
Referenced by generator_init().
|
static |
Definition at line 657 of file mvdistinct.c.
References generate_combinations_recurse(), i, and start.
Referenced by generate_combinations(), and generate_combinations_recurse().
|
static |
Definition at line 642 of file mvdistinct.c.
References pfree().
Referenced by statext_ndistinct_build().
|
static |
Definition at line 589 of file mvdistinct.c.
References Assert, generate_combinations(), n_choose_k(), and palloc().
Referenced by statext_ndistinct_build().
|
static |
Definition at line 627 of file mvdistinct.c.
Referenced by statext_ndistinct_build().
|
static |
Definition at line 550 of file mvdistinct.c.
Referenced by generator_init().
|
static |
Definition at line 425 of file mvdistinct.c.
References VacAttrStats::attrcollid, VacAttrStats::attrtypid, collid, data, elog, ERROR, estimate_ndistinct(), f1, i, InvalidOid, items, j, lookup_type_cache(), multi_sort_add_dimension(), multi_sort_compare(), multi_sort_init(), palloc(), palloc0(), qsort_interruptible(), type, TYPECACHE_LT_OPR, and values.
Referenced by statext_ndistinct_build().
|
static |
Definition at line 575 of file mvdistinct.c.
Referenced by statext_ndistinct_build().
Datum pg_ndistinct_in | ( | PG_FUNCTION_ARGS | ) |
Definition at line 339 of file mvdistinct.c.
References ereport, errcode(), errmsg(), ERROR, and PG_RETURN_VOID.
Datum pg_ndistinct_out | ( | PG_FUNCTION_ARGS | ) |
Definition at line 355 of file mvdistinct.c.
References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), attnum, MVNDistinctItem::attributes, data, i, initStringInfo(), MVNDistinct::items, j, MVNDistinctItem::nattributes, MVNDistinctItem::ndistinct, MVNDistinct::nitems, PG_GETARG_BYTEA_PP, PG_RETURN_CSTRING, statext_ndistinct_deserialize(), and str.
Datum pg_ndistinct_recv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 392 of file mvdistinct.c.
References ereport, errcode(), errmsg(), ERROR, and PG_RETURN_VOID.
Datum pg_ndistinct_send | ( | PG_FUNCTION_ARGS | ) |
MVNDistinct * statext_ndistinct_build | ( | double | totalrows, |
StatsBuildData * | data | ||
) |
Definition at line 88 of file mvdistinct.c.
References Assert, AttributeNumberIsValid, MVNDistinctItem::attributes, data, generator_free(), generator_init(), generator_next(), MVNDistinct::items, items, j, MVNDistinct::magic, MVNDistinctItem::nattributes, MVNDistinctItem::ndistinct, ndistinct_for_combination(), MVNDistinct::nitems, nitems, num_combinations(), palloc(), STATS_NDISTINCT_MAGIC, STATS_NDISTINCT_TYPE_BASIC, and MVNDistinct::type.
Referenced by BuildRelationExtStatistics().
MVNDistinct * statext_ndistinct_deserialize | ( | bytea * | data | ) |
Definition at line 250 of file mvdistinct.c.
References Assert, MVNDistinctItem::attributes, data, elog, ERROR, i, MVNDistinct::items, items, MVNDistinct::magic, MAXALIGN, MinSizeOfItems, MVNDistinctItem::nattributes, MVNDistinctItem::ndistinct, MVNDistinct::nitems, palloc(), palloc0(), SizeOfHeader, STATS_MAX_DIMENSIONS, STATS_NDISTINCT_MAGIC, STATS_NDISTINCT_TYPE_BASIC, MVNDistinct::type, VARDATA_ANY, VARSIZE_ANY, and VARSIZE_ANY_EXHDR.
Referenced by pg_ndistinct_out(), and statext_ndistinct_load().
MVNDistinct * statext_ndistinct_load | ( | Oid | mvoid, |
bool | inh | ||
) |
Definition at line 148 of file mvdistinct.c.
References BoolGetDatum(), DatumGetByteaPP, elog, ERROR, HeapTupleIsValid, ObjectIdGetDatum(), ReleaseSysCache(), SearchSysCache2(), statext_ndistinct_deserialize(), and SysCacheGetAttr().
Referenced by estimate_multivariate_ndistinct().
bytea * statext_ndistinct_serialize | ( | MVNDistinct * | ndistinct | ) |
Definition at line 179 of file mvdistinct.c.
References Assert, MVNDistinctItem::attributes, i, MVNDistinct::items, len, MVNDistinct::magic, MVNDistinctItem::nattributes, MVNDistinctItem::ndistinct, MVNDistinct::nitems, output, palloc(), SET_VARSIZE, SizeOfHeader, SizeOfItem, STATS_NDISTINCT_MAGIC, STATS_NDISTINCT_TYPE_BASIC, MVNDistinct::type, VARDATA, and VARHDRSZ.
Referenced by statext_store().