diff options
| author | Tom Lane | 2020-05-14 17:06:38 +0000 |
|---|---|---|
| committer | Tom Lane | 2020-05-14 17:06:50 +0000 |
| commit | 5cbfce562f7cd2aab0cdc4694ce298ec3567930e (patch) | |
| tree | 64e722d72fc5f1803cb6f6371d6cf12863e2812f /src/backend/statistics | |
| parent | 1255466f8358ecac29581aa5ecec76628dc2e33c (diff) | |
Initial pgindent and pgperltidy run for v13.
Includes some manual cleanup of places that pgindent messed up,
most of which weren't per project style anyway.
Notably, it seems some people didn't absorb the style rules of
commit c9d297751, because there were a bunch of new occurrences
of function calls with a newline just after the left paren, all
with faulty expectations about how the rest of the call would get
indented.
Diffstat (limited to 'src/backend/statistics')
| -rw-r--r-- | src/backend/statistics/dependencies.c | 14 | ||||
| -rw-r--r-- | src/backend/statistics/extended_stats.c | 72 | ||||
| -rw-r--r-- | src/backend/statistics/mcv.c | 108 |
3 files changed, 102 insertions, 92 deletions
diff --git a/src/backend/statistics/dependencies.c b/src/backend/statistics/dependencies.c index ada1e78f6fd..3e37e2758ca 100644 --- a/src/backend/statistics/dependencies.c +++ b/src/backend/statistics/dependencies.c @@ -800,7 +800,7 @@ dependency_is_compatible_clause(Node *clause, Index relid, AttrNumber *attnum) else if (IsA(clause, ScalarArrayOpExpr)) { /* If it's an scalar array operator, check for Var IN Const. */ - ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) clause; + ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) clause; /* * Reject ALL() variant, we only care about ANY/IN. @@ -827,8 +827,9 @@ dependency_is_compatible_clause(Node *clause, Index relid, AttrNumber *attnum) /* * If it's not an "=" operator, just ignore the clause, as it's not * compatible with functional dependencies. The operator is identified - * simply by looking at which function it uses to estimate selectivity. - * That's a bit strange, but it's what other similar places do. + * simply by looking at which function it uses to estimate + * selectivity. That's a bit strange, but it's what other similar + * places do. */ if (get_oprrest(expr->opno) != F_EQSEL) return false; @@ -929,7 +930,8 @@ static MVDependency * find_strongest_dependency(MVDependencies **dependencies, int ndependencies, Bitmapset *attnums) { - int i, j; + int i, + j; MVDependency *strongest = NULL; /* number of attnums in clauses */ @@ -967,8 +969,8 @@ find_strongest_dependency(MVDependencies **dependencies, int ndependencies, /* * this dependency is stronger, but we must still check that it's - * fully matched to these attnums. We perform this check last as it's - * slightly more expensive than the previous checks. + * fully matched to these attnums. We perform this check last as + * it's slightly more expensive than the previous checks. */ if (dependency_is_fully_matched(dependency, attnums)) strongest = dependency; /* save new best match */ diff --git a/src/backend/statistics/extended_stats.c b/src/backend/statistics/extended_stats.c index d1f818d49a8..c7e16f2f212 100644 --- a/src/backend/statistics/extended_stats.c +++ b/src/backend/statistics/extended_stats.c @@ -75,8 +75,8 @@ static VacAttrStats **lookup_var_attr_stats(Relation rel, Bitmapset *attrs, static void statext_store(Oid relid, MVNDistinct *ndistinct, MVDependencies *dependencies, MCVList *mcv, VacAttrStats **stats); -static int statext_compute_stattarget(int stattarget, - int natts, VacAttrStats **stats); +static int statext_compute_stattarget(int stattarget, + int natts, VacAttrStats **stats); /* * Compute requested extended stats, using the rows sampled for the plain @@ -160,9 +160,9 @@ BuildRelationExtStatistics(Relation onerel, double totalrows, stats); /* - * Don't rebuild statistics objects with statistics target set to 0 (we - * just leave the existing values around, just like we do for regular - * per-column statistics). + * Don't rebuild statistics objects with statistics target set to 0 + * (we just leave the existing values around, just like we do for + * regular per-column statistics). */ if (stattarget == 0) continue; @@ -231,10 +231,10 @@ ComputeExtStatisticsRows(Relation onerel, foreach(lc, lstats) { - StatExtEntry *stat = (StatExtEntry *) lfirst(lc); - int stattarget = stat->stattarget; - VacAttrStats **stats; - int nattrs = bms_num_members(stat->columns); + StatExtEntry *stat = (StatExtEntry *) lfirst(lc); + int stattarget = stat->stattarget; + VacAttrStats **stats; + int nattrs = bms_num_members(stat->columns); /* * Check if we can build this statistics object based on the columns @@ -291,19 +291,19 @@ ComputeExtStatisticsRows(Relation onerel, static int statext_compute_stattarget(int stattarget, int nattrs, VacAttrStats **stats) { - int i; + int i; /* - * If there's statistics target set for the statistics object, use it. - * It may be set to 0 which disables building of that statistic. + * If there's statistics target set for the statistics object, use it. It + * may be set to 0 which disables building of that statistic. */ if (stattarget >= 0) return stattarget; /* * The target for the statistics object is set to -1, in which case we - * look at the maximum target set for any of the attributes the object - * is defined on. + * look at the maximum target set for any of the attributes the object is + * defined on. */ for (i = 0; i < nattrs; i++) { @@ -1041,8 +1041,8 @@ statext_is_compatible_clause_internal(PlannerInfo *root, Node *clause, /* Var IN Array */ if (IsA(clause, ScalarArrayOpExpr)) { - RangeTblEntry *rte = root->simple_rte_array[relid]; - ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) clause; + RangeTblEntry *rte = root->simple_rte_array[relid]; + ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) clause; Var *var; /* Only expressions with two arguments are considered compatible. */ @@ -1287,7 +1287,7 @@ statext_mcv_clauselist_selectivity(PlannerInfo *root, List *clauses, int varReli ListCell *l; Bitmapset **list_attnums; int listidx; - Selectivity sel = 1.0; + Selectivity sel = 1.0; /* check if there's any stats that might be useful for us. */ if (!has_stats_of_kind(rel->statlist, STATS_EXT_MCV)) @@ -1338,7 +1338,10 @@ statext_mcv_clauselist_selectivity(PlannerInfo *root, List *clauses, int varReli stat = choose_best_statistics(rel->statlist, STATS_EXT_MCV, list_attnums, list_length(clauses)); - /* if no (additional) matching stats could be found then we've nothing to do */ + /* + * if no (additional) matching stats could be found then we've nothing + * to do + */ if (!stat) break; @@ -1352,8 +1355,8 @@ statext_mcv_clauselist_selectivity(PlannerInfo *root, List *clauses, int varReli foreach(l, clauses) { /* - * If the clause is compatible with the selected statistics, mark it - * as estimated and add it to the list to estimate. + * If the clause is compatible with the selected statistics, mark + * it as estimated and add it to the list to estimate. */ if (list_attnums[listidx] != NULL && bms_is_subset(list_attnums[listidx], stat->keys)) @@ -1371,15 +1374,15 @@ statext_mcv_clauselist_selectivity(PlannerInfo *root, List *clauses, int varReli /* * First compute "simple" selectivity, i.e. without the extended * statistics, and essentially assuming independence of the - * columns/clauses. We'll then use the various selectivities computed from - * MCV list to improve it. + * columns/clauses. We'll then use the various selectivities computed + * from MCV list to improve it. */ simple_sel = clauselist_selectivity_simple(root, stat_clauses, varRelid, - jointype, sjinfo, NULL); + jointype, sjinfo, NULL); /* - * Now compute the multi-column estimate from the MCV list, along with the - * other selectivities (base & total selectivity). + * Now compute the multi-column estimate from the MCV list, along with + * the other selectivities (base & total selectivity). */ mcv_sel = mcv_clauselist_selectivity(root, stat, stat_clauses, varRelid, jointype, sjinfo, rel, @@ -1393,7 +1396,10 @@ statext_mcv_clauselist_selectivity(PlannerInfo *root, List *clauses, int varReli if (other_sel > 1.0 - mcv_totalsel) other_sel = 1.0 - mcv_totalsel; - /* Overall selectivity is the combination of MCV and non-MCV estimates. */ + /* + * Overall selectivity is the combination of MCV and non-MCV + * estimates. + */ stat_sel = mcv_sel + other_sel; CLAMP_PROBABILITY(stat_sel); @@ -1454,11 +1460,11 @@ statext_clauselist_selectivity(PlannerInfo *root, List *clauses, int varRelid, bool examine_clause_args(List *args, Var **varp, Const **cstp, bool *varonleftp) { - Var *var; - Const *cst; - bool varonleft; - Node *leftop, - *rightop; + Var *var; + Const *cst; + bool varonleft; + Node *leftop, + *rightop; /* enforced by statext_is_compatible_clause_internal */ Assert(list_length(args) == 2); @@ -1473,13 +1479,13 @@ examine_clause_args(List *args, Var **varp, Const **cstp, bool *varonleftp) if (IsA(rightop, RelabelType)) rightop = (Node *) ((RelabelType *) rightop)->arg; - if (IsA(leftop, Var) && IsA(rightop, Const)) + if (IsA(leftop, Var) &&IsA(rightop, Const)) { var = (Var *) leftop; cst = (Const *) rightop; varonleft = true; } - else if (IsA(leftop, Const) && IsA(rightop, Var)) + else if (IsA(leftop, Const) &&IsA(rightop, Var)) { var = (Var *) rightop; cst = (Const *) leftop; diff --git a/src/backend/statistics/mcv.c b/src/backend/statistics/mcv.c index 3147d8fedc6..6a262f15436 100644 --- a/src/backend/statistics/mcv.c +++ b/src/backend/statistics/mcv.c @@ -210,8 +210,8 @@ statext_mcv_build(int numrows, HeapTuple *rows, Bitmapset *attrs, groups = build_distinct_groups(nitems, items, mss, &ngroups); /* - * Maximum number of MCV items to store, based on the statistics target - * we computed for the statistics object (from target set for the object + * Maximum number of MCV items to store, based on the statistics target we + * computed for the statistics object (from target set for the object * itself, attributes and the system default). In any case, we can't keep * more groups than we have available. */ @@ -261,7 +261,7 @@ statext_mcv_build(int numrows, HeapTuple *rows, Bitmapset *attrs, { int j; SortItem key; - MultiSortSupport tmp; + MultiSortSupport tmp; /* frequencies for values in each attribute */ SortItem **freqs; @@ -463,7 +463,7 @@ build_distinct_groups(int numrows, SortItem *items, MultiSortSupport mss, static int sort_item_compare(const void *a, const void *b, void *arg) { - SortSupport ssup = (SortSupport) arg; + SortSupport ssup = (SortSupport) arg; SortItem *ia = (SortItem *) a; SortItem *ib = (SortItem *) b; @@ -499,7 +499,7 @@ build_column_frequencies(SortItem *groups, int ngroups, /* allocate arrays for all columns as a single chunk */ ptr = palloc(MAXALIGN(sizeof(SortItem *) * mss->ndims) + - mss->ndims * MAXALIGN(sizeof(SortItem) * ngroups)); + mss->ndims * MAXALIGN(sizeof(SortItem) * ngroups)); /* initial array of pointers */ result = (SortItem **) ptr; @@ -507,7 +507,7 @@ build_column_frequencies(SortItem *groups, int ngroups, for (dim = 0; dim < mss->ndims; dim++) { - SortSupport ssup = &mss->ssup[dim]; + SortSupport ssup = &mss->ssup[dim]; /* array of values for a single column */ result[dim] = (SortItem *) ptr; @@ -528,15 +528,15 @@ build_column_frequencies(SortItem *groups, int ngroups, /* * Identify distinct values, compute frequency (there might be - * multiple MCV items containing this value, so we need to sum - * counts from all of them. + * multiple MCV items containing this value, so we need to sum counts + * from all of them. */ ncounts[dim] = 1; for (i = 1; i < ngroups; i++) { - if (sort_item_compare(&result[dim][i-1], &result[dim][i], ssup) == 0) + if (sort_item_compare(&result[dim][i - 1], &result[dim][i], ssup) == 0) { - result[dim][ncounts[dim]-1].count += result[dim][i].count; + result[dim][ncounts[dim] - 1].count += result[dim][i].count; continue; } @@ -723,23 +723,23 @@ statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats) */ info[dim].nvalues = ndistinct; - if (info[dim].typbyval) /* by-value data types */ + if (info[dim].typbyval) /* by-value data types */ { info[dim].nbytes = info[dim].nvalues * info[dim].typlen; /* * We copy the data into the MCV item during deserialization, so * we don't need to allocate any extra space. - */ + */ info[dim].nbytes_aligned = 0; } - else if (info[dim].typlen > 0) /* fixed-length by-ref */ + else if (info[dim].typlen > 0) /* fixed-length by-ref */ { /* * We don't care about alignment in the serialized data, so we * pack the data as much as possible. But we also track how much - * data will be needed after deserialization, and in that case - * we need to account for alignment of each item. + * data will be needed after deserialization, and in that case we + * need to account for alignment of each item. * * Note: As the items are fixed-length, we could easily compute * this during deserialization, but we do it here anyway. @@ -765,8 +765,8 @@ statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats) /* serialized length (uint32 length + data) */ len = VARSIZE_ANY_EXHDR(values[dim][i]); - info[dim].nbytes += sizeof(uint32); /* length */ - info[dim].nbytes += len; /* value (no header) */ + info[dim].nbytes += sizeof(uint32); /* length */ + info[dim].nbytes += len; /* value (no header) */ /* * During deserialization we'll build regular varlena values @@ -792,8 +792,8 @@ statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats) /* c-strings include terminator, so +1 byte */ len = strlen(DatumGetCString(values[dim][i])) + 1; - info[dim].nbytes += sizeof(uint32); /* length */ - info[dim].nbytes += len; /* value */ + info[dim].nbytes += sizeof(uint32); /* length */ + info[dim].nbytes += len; /* value */ /* space needed for properly aligned deserialized copies */ info[dim].nbytes_aligned += MAXALIGN(len); @@ -809,9 +809,9 @@ statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats) * whole serialized MCV list (varlena header, MCV header, dimension info * for each attribute, deduplicated values and items). */ - total_length = (3 * sizeof(uint32)) /* magic + type + nitems */ - + sizeof(AttrNumber) /* ndimensions */ - + (ndims * sizeof(Oid)); /* attribute types */ + total_length = (3 * sizeof(uint32)) /* magic + type + nitems */ + + sizeof(AttrNumber) /* ndimensions */ + + (ndims * sizeof(Oid)); /* attribute types */ /* dimension info */ total_length += ndims * sizeof(DimensionInfo); @@ -954,7 +954,8 @@ statext_mcv_serialize(MCVList *mcvlist, VacAttrStats **stats) info[dim].nvalues, sizeof(Datum), compare_scalars_simple, &ssup[dim]); - Assert(value != NULL); /* serialization or deduplication error */ + Assert(value != NULL); /* serialization or deduplication + * error */ /* compute index within the deduplicated array */ index = (uint16) (value - values[dim]); @@ -1147,8 +1148,8 @@ statext_mcv_deserialize(bytea *data) * serialized data - it's not aligned properly, and it may disappear while * we're still using the MCV list, e.g. due to catcache release. * - * We do care about alignment here, because we will allocate all the pieces - * at once, but then use pointers to different parts. + * We do care about alignment here, because we will allocate all the + * pieces at once, but then use pointers to different parts. */ mcvlen = MAXALIGN(offsetof(MCVList, items) + (sizeof(MCVItem) * nitems)); @@ -1291,7 +1292,7 @@ statext_mcv_deserialize(bytea *data) /* finally translate the indexes (for non-NULL only) */ for (dim = 0; dim < ndims; dim++) { - uint16 index; + uint16 index; memcpy(&index, ptr, sizeof(uint16)); ptr += sizeof(uint16); @@ -1377,7 +1378,8 @@ pg_stats_ext_mcvlist_items(PG_FUNCTION_ARGS) /* stuff done on every call of the function */ funcctx = SRF_PERCALL_SETUP(); - if (funcctx->call_cntr < funcctx->max_calls) /* do when there is more left to send */ + if (funcctx->call_cntr < funcctx->max_calls) /* do when there is more + * left to send */ { Datum values[5]; bool nulls[5]; @@ -1400,10 +1402,10 @@ pg_stats_ext_mcvlist_items(PG_FUNCTION_ARGS) { astate_nulls = accumArrayResult(astate_nulls, - BoolGetDatum(item->isnull[i]), - false, - BOOLOID, - CurrentMemoryContext); + BoolGetDatum(item->isnull[i]), + false, + BOOLOID, + CurrentMemoryContext); if (!item->isnull[i]) { @@ -1421,17 +1423,17 @@ pg_stats_ext_mcvlist_items(PG_FUNCTION_ARGS) txt = cstring_to_text(DatumGetPointer(val)); astate_values = accumArrayResult(astate_values, - PointerGetDatum(txt), - false, - TEXTOID, - CurrentMemoryContext); + PointerGetDatum(txt), + false, + TEXTOID, + CurrentMemoryContext); } else astate_values = accumArrayResult(astate_values, - (Datum) 0, - true, - TEXTOID, - CurrentMemoryContext); + (Datum) 0, + true, + TEXTOID, + CurrentMemoryContext); } values[0] = Int32GetDatum(funcctx->call_cntr); @@ -1606,9 +1608,9 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses, MCVItem *item = &mcvlist->items[i]; /* - * When the MCV item or the Const value is NULL we can treat - * this as a mismatch. We must not call the operator because - * of strictness. + * When the MCV item or the Const value is NULL we can + * treat this as a mismatch. We must not call the operator + * because of strictness. */ if (item->isnull[idx] || cst->constisnull) { @@ -1631,10 +1633,10 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses, * * We don't store collations used to build the statistics, * but we can use the collation for the attribute itself, - * as stored in varcollid. We do reset the statistics after - * a type change (including collation change), so this is - * OK. We may need to relax this after allowing extended - * statistics on expressions. + * as stored in varcollid. We do reset the statistics + * after a type change (including collation change), so + * this is OK. We may need to relax this after allowing + * extended statistics on expressions. */ if (varonleft) match = DatumGetBool(FunctionCall2Coll(&opproc, @@ -1654,7 +1656,7 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses, } else if (IsA(clause, ScalarArrayOpExpr)) { - ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) clause; + ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) clause; FmgrInfo opproc; /* valid only after examine_clause_args returns true */ @@ -1707,9 +1709,9 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses, MCVItem *item = &mcvlist->items[i]; /* - * When the MCV item or the Const value is NULL we can treat - * this as a mismatch. We must not call the operator because - * of strictness. + * When the MCV item or the Const value is NULL we can + * treat this as a mismatch. We must not call the operator + * because of strictness. */ if (item->isnull[idx] || cst->constisnull) { @@ -1727,9 +1729,9 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses, for (j = 0; j < num_elems; j++) { - Datum elem_value = elem_values[j]; - bool elem_isnull = elem_nulls[j]; - bool elem_match; + Datum elem_value = elem_values[j]; + bool elem_isnull = elem_nulls[j]; + bool elem_match; /* NULL values always evaluate as not matching. */ if (elem_isnull) |
