diff options
| author | Bruce Momjian | 2017-05-17 20:31:56 +0000 |
|---|---|---|
| committer | Bruce Momjian | 2017-05-17 20:31:56 +0000 |
| commit | a6fd7b7a5f7bf3a8aa3f3d076cf09d922c1c6dd2 (patch) | |
| tree | d10454411c05d459abe06df161ab3c1156c5f477 /src/backend/statistics | |
| parent | 8a943324780259757c77c56cfc597347d1150cdb (diff) | |
Post-PG 10 beta1 pgindent run
perltidy run not included.
Diffstat (limited to 'src/backend/statistics')
| -rw-r--r-- | src/backend/statistics/dependencies.c | 18 | ||||
| -rw-r--r-- | src/backend/statistics/extended_stats.c | 42 | ||||
| -rw-r--r-- | src/backend/statistics/mvdistinct.c | 58 |
3 files changed, 59 insertions, 59 deletions
diff --git a/src/backend/statistics/dependencies.c b/src/backend/statistics/dependencies.c index 0e71f058ad2..793b2da766e 100644 --- a/src/backend/statistics/dependencies.c +++ b/src/backend/statistics/dependencies.c @@ -44,7 +44,7 @@ typedef struct DependencyGeneratorData int current; /* next dependency to return (index) */ AttrNumber ndependencies; /* number of dependencies generated */ AttrNumber *dependencies; /* array of pre-generated dependencies */ -} DependencyGeneratorData; +} DependencyGeneratorData; typedef DependencyGeneratorData *DependencyGenerator; @@ -61,7 +61,7 @@ static bool dependency_is_fully_matched(MVDependency *dependency, static bool dependency_implies_attribute(MVDependency *dependency, AttrNumber attnum); static bool dependency_is_compatible_clause(Node *clause, Index relid, - AttrNumber *attnum); + AttrNumber *attnum); static MVDependency *find_strongest_dependency(StatisticExtInfo *stats, MVDependencies *dependencies, Bitmapset *attnums); @@ -409,7 +409,7 @@ statext_dependencies_build(int numrows, HeapTuple *rows, Bitmapset *attrs, continue; d = (MVDependency *) palloc0(offsetof(MVDependency, attributes) - + k * sizeof(AttrNumber)); + +k * sizeof(AttrNumber)); /* copy the dependency (and keep the indexes into stxkeys) */ d->degree = degree; @@ -431,7 +431,7 @@ statext_dependencies_build(int numrows, HeapTuple *rows, Bitmapset *attrs, dependencies->ndeps++; dependencies = (MVDependencies *) repalloc(dependencies, offsetof(MVDependencies, deps) - + dependencies->ndeps * sizeof(MVDependency)); + +dependencies->ndeps * sizeof(MVDependency)); dependencies->deps[dependencies->ndeps - 1] = d; } @@ -451,7 +451,7 @@ statext_dependencies_build(int numrows, HeapTuple *rows, Bitmapset *attrs, * Serialize list of dependencies into a bytea value. */ bytea * -statext_dependencies_serialize(MVDependencies * dependencies) +statext_dependencies_serialize(MVDependencies *dependencies) { int i; bytea *output; @@ -552,7 +552,7 @@ statext_dependencies_deserialize(bytea *data) /* allocate space for the MCV items */ dependencies = repalloc(dependencies, offsetof(MVDependencies, deps) - + (dependencies->ndeps * sizeof(MVDependency *))); + +(dependencies->ndeps * sizeof(MVDependency *))); for (i = 0; i < dependencies->ndeps; i++) { @@ -573,7 +573,7 @@ statext_dependencies_deserialize(bytea *data) /* now that we know the number of attributes, allocate the dependency */ d = (MVDependency *) palloc0(offsetof(MVDependency, attributes) - + (k * sizeof(AttrNumber))); + +(k * sizeof(AttrNumber))); d->degree = degree; d->nattributes = k; @@ -600,7 +600,7 @@ statext_dependencies_deserialize(bytea *data) * attributes (assuming the clauses are suitable equality clauses) */ static bool -dependency_is_fully_matched(MVDependency * dependency, Bitmapset *attnums) +dependency_is_fully_matched(MVDependency *dependency, Bitmapset *attnums) { int j; @@ -840,7 +840,7 @@ dependency_is_compatible_clause(Node *clause, Index relid, AttrNumber *attnum) * (see the comment in dependencies_clauselist_selectivity). */ static MVDependency * -find_strongest_dependency(StatisticExtInfo * stats, MVDependencies * dependencies, +find_strongest_dependency(StatisticExtInfo *stats, MVDependencies *dependencies, Bitmapset *attnums) { int i; diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index 3f74cee05f8..8d7460c96be 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -40,11 +40,11 @@ */ typedef struct StatExtEntry { - Oid statOid; /* OID of pg_statistic_ext entry */ - char *schema; /* statistics object's schema */ - char *name; /* statistics object's name */ - Bitmapset *columns; /* attribute numbers covered by the object */ - List *types; /* 'char' list of enabled statistic kinds */ + Oid statOid; /* OID of pg_statistic_ext entry */ + char *schema; /* statistics object's schema */ + char *name; /* statistics object's name */ + Bitmapset *columns; /* attribute numbers covered by the object */ + List *types; /* 'char' list of enabled statistic kinds */ } StatExtEntry; @@ -83,15 +83,15 @@ BuildRelationExtStatistics(Relation onerel, double totalrows, foreach(lc, stats) { - StatExtEntry *stat = (StatExtEntry *) lfirst(lc); - MVNDistinct *ndistinct = NULL; + StatExtEntry *stat = (StatExtEntry *) lfirst(lc); + MVNDistinct *ndistinct = NULL; MVDependencies *dependencies = NULL; - VacAttrStats **stats; - ListCell *lc2; + VacAttrStats **stats; + ListCell *lc2; /* - * Check if we can build these stats based on the column analyzed. - * If not, report this fact (except in autovacuum) and move on. + * Check if we can build these stats based on the column analyzed. If + * not, report this fact (except in autovacuum) and move on. */ stats = lookup_var_attr_stats(onerel, stat->columns, natts, vacattrstats); @@ -114,7 +114,7 @@ BuildRelationExtStatistics(Relation onerel, double totalrows, /* compute statistic of each requested type */ foreach(lc2, stat->types) { - char t = (char) lfirst_int(lc2); + char t = (char) lfirst_int(lc2); if (t == STATS_EXT_NDISTINCT) ndistinct = statext_ndistinct_build(totalrows, numrows, rows, @@ -141,7 +141,7 @@ BuildRelationExtStatistics(Relation onerel, double totalrows, bool statext_is_kind_built(HeapTuple htup, char type) { - AttrNumber attnum; + AttrNumber attnum; switch (type) { @@ -168,8 +168,8 @@ fetch_statentries_for_relation(Relation pg_statext, Oid relid) { SysScanDesc scan; ScanKeyData skey; - HeapTuple htup; - List *result = NIL; + HeapTuple htup; + List *result = NIL; /* * Prepare to scan pg_statistic_ext for entries having stxrelid = this @@ -250,7 +250,7 @@ lookup_var_attr_stats(Relation rel, Bitmapset *attrs, /* lookup VacAttrStats info for the requested columns (same attnum) */ while ((x = bms_next_member(attrs, x)) >= 0) { - int j; + int j; stats[i] = NULL; for (j = 0; j < nvacatts; j++) @@ -273,10 +273,10 @@ lookup_var_attr_stats(Relation rel, Bitmapset *attrs, return NULL; } - /* - * Sanity check that the column is not dropped - stats should have - * been removed in this case. - */ + /* + * Sanity check that the column is not dropped - stats should have + * been removed in this case. + */ Assert(!stats[i]->attr->attisdropped); i++; @@ -367,7 +367,7 @@ multi_sort_init(int ndims) void multi_sort_add_dimension(MultiSortSupport mss, int sortdim, Oid oper) { - SortSupport ssup = &mss->ssup[sortdim]; + SortSupport ssup = &mss->ssup[sortdim]; ssup->ssup_cxt = CurrentMemoryContext; ssup->ssup_collation = DEFAULT_COLLATION_OID; diff --git a/src/backend/statistics/mvdistinct.c b/src/backend/statistics/mvdistinct.c index 47b2490abbf..d8d422cd45a 100644 --- a/src/backend/statistics/mvdistinct.c +++ b/src/backend/statistics/mvdistinct.c @@ -37,8 +37,8 @@ static double ndistinct_for_combination(double totalrows, int numrows, - HeapTuple *rows, VacAttrStats **stats, - int k, int *combination); + HeapTuple *rows, VacAttrStats **stats, + int k, int *combination); static double estimate_ndistinct(double totalrows, int numrows, int d, int f1); static int n_choose_k(int n, int k); static int num_combinations(int n); @@ -48,11 +48,11 @@ static int num_combinations(int n); /* internal state for generator of k-combinations of n elements */ typedef struct CombinationGenerator { - int k; /* size of the combination */ - int n; /* total number of elements */ - int current; /* index of the next combination to return */ - int ncombinations; /* number of combinations (size of array) */ - int *combinations; /* array of pre-built combinations */ + int k; /* size of the combination */ + int n; /* total number of elements */ + int current; /* index of the next combination to return */ + int ncombinations; /* number of combinations (size of array) */ + int *combinations; /* array of pre-built combinations */ } CombinationGenerator; static CombinationGenerator *generator_init(int n, int k); @@ -87,7 +87,7 @@ statext_ndistinct_build(double totalrows, int numrows, HeapTuple *rows, itemcnt = 0; for (k = 2; k <= numattrs; k++) { - int *combination; + int *combination; CombinationGenerator *generator; /* generate combinations of K out of N elements */ @@ -96,12 +96,12 @@ statext_ndistinct_build(double totalrows, int numrows, HeapTuple *rows, while ((combination = generator_next(generator))) { MVNDistinctItem *item = &result->items[itemcnt]; - int j; + int j; item->attrs = NULL; for (j = 0; j < k; j++) item->attrs = bms_add_member(item->attrs, - stats[combination[j]]->attr->attnum); + stats[combination[j]]->attr->attnum); item->ndistinct = ndistinct_for_combination(totalrows, numrows, rows, stats, k, combination); @@ -166,12 +166,12 @@ statext_ndistinct_serialize(MVNDistinct *ndistinct) * for each item, including number of items for each. */ len = VARHDRSZ + SizeOfMVNDistinct + - ndistinct->nitems * (offsetof(MVNDistinctItem, attrs) + sizeof(int)); + ndistinct->nitems * (offsetof(MVNDistinctItem, attrs) +sizeof(int)); /* and also include space for the actual attribute numbers */ for (i = 0; i < ndistinct->nitems; i++) { - int nmembers; + int nmembers; nmembers = bms_num_members(ndistinct->items[i].attrs); Assert(nmembers >= 2); @@ -198,8 +198,8 @@ statext_ndistinct_serialize(MVNDistinct *ndistinct) for (i = 0; i < ndistinct->nitems; i++) { MVNDistinctItem item = ndistinct->items[i]; - int nmembers = bms_num_members(item.attrs); - int x; + int nmembers = bms_num_members(item.attrs); + int x; memcpy(tmp, &item.ndistinct, sizeof(double)); tmp += sizeof(double); @@ -230,7 +230,7 @@ statext_ndistinct_deserialize(bytea *data) { int i; Size minimum_size; - MVNDistinct ndist; + MVNDistinct ndist; MVNDistinct *ndistinct; char *tmp; @@ -275,12 +275,12 @@ statext_ndistinct_deserialize(bytea *data) if (VARSIZE_ANY_EXHDR(data) < minimum_size) ereport(ERROR, (errcode(ERRCODE_DATA_CORRUPTED), - errmsg("invalid MVNDistinct size %zd (expected at least %zd)", - VARSIZE_ANY_EXHDR(data), minimum_size))); + errmsg("invalid MVNDistinct size %zd (expected at least %zd)", + VARSIZE_ANY_EXHDR(data), minimum_size))); /* - * Allocate space for the ndistinct items (no space for each item's attnos: - * those live in bitmapsets allocated separately) + * Allocate space for the ndistinct items (no space for each item's + * attnos: those live in bitmapsets allocated separately) */ ndistinct = palloc0(MAXALIGN(SizeOfMVNDistinct) + (ndist.nitems * sizeof(MVNDistinctItem))); @@ -360,8 +360,8 @@ pg_ndistinct_out(PG_FUNCTION_ARGS) for (i = 0; i < ndist->nitems; i++) { MVNDistinctItem item = ndist->items[i]; - int x = -1; - bool first = true; + int x = -1; + bool first = true; if (i > 0) appendStringInfoString(&str, ", "); @@ -449,16 +449,16 @@ ndistinct_for_combination(double totalrows, int numrows, HeapTuple *rows, } /* - * For each dimension, set up sort-support and fill in the values from - * the sample data. + * For each dimension, set up sort-support and fill in the values from the + * sample data. */ for (i = 0; i < k; i++) { - VacAttrStats *colstat = stats[combination[i]]; + VacAttrStats *colstat = stats[combination[i]]; TypeCacheEntry *type; type = lookup_type_cache(colstat->attrtypid, TYPECACHE_LT_OPR); - if (type->lt_opr == InvalidOid) /* shouldn't happen */ + if (type->lt_opr == InvalidOid) /* shouldn't happen */ elog(ERROR, "cache lookup failed for ordering operator for type %u", colstat->attrtypid); @@ -513,7 +513,7 @@ estimate_ndistinct(double totalrows, int numrows, int d, int f1) denom, ndistinct; - numer = (double) numrows * (double) d; + numer = (double) numrows *(double) d; denom = (double) (numrows - f1) + (double) f1 *(double) numrows / totalrows; @@ -594,7 +594,7 @@ generator_init(int n, int k) state->ncombinations = n_choose_k(n, k); - /* pre-allocate space for all combinations*/ + /* pre-allocate space for all combinations */ state->combinations = (int *) palloc(sizeof(int) * k * state->ncombinations); state->current = 0; @@ -657,7 +657,7 @@ generate_combinations_recurse(CombinationGenerator *state, /* If we haven't filled all the elements, simply recurse. */ if (index < state->k) { - int i; + int i; /* * The values have to be in ascending order, so make sure we start @@ -688,7 +688,7 @@ generate_combinations_recurse(CombinationGenerator *state, static void generate_combinations(CombinationGenerator *state) { - int *current = (int *) palloc0(sizeof(int) * state->k); + int *current = (int *) palloc0(sizeof(int) * state->k); generate_combinations_recurse(state, 0, 0, current); |
