mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Pre-beta mechanical code beautification.
Run pgindent, pgperltidy, and reformat-dat-files. I manually fixed a couple of comments that pgindent uglified.
This commit is contained in:
@@ -391,7 +391,7 @@ contain_mutable_functions_walker(Node *node, void *context)
|
||||
const JsonConstructorExpr *ctor = (JsonConstructorExpr *) node;
|
||||
ListCell *lc;
|
||||
bool is_jsonb =
|
||||
ctor->returning->format->format_type == JS_FORMAT_JSONB;
|
||||
ctor->returning->format->format_type == JS_FORMAT_JSONB;
|
||||
|
||||
/* Check argument_type => json[b] conversions */
|
||||
foreach(lc, ctor->args)
|
||||
@@ -899,7 +899,7 @@ max_parallel_hazard_walker(Node *node, max_parallel_hazard_context *context)
|
||||
/* JsonExpr is parallel-unsafe if subtransactions can be used. */
|
||||
else if (IsA(node, JsonExpr))
|
||||
{
|
||||
JsonExpr *jsexpr = (JsonExpr *) node;
|
||||
JsonExpr *jsexpr = (JsonExpr *) node;
|
||||
|
||||
if (ExecEvalJsonNeedsSubTransaction(jsexpr, NULL))
|
||||
{
|
||||
@@ -3581,7 +3581,7 @@ eval_const_expressions_mutator(Node *node,
|
||||
context->case_val = raw;
|
||||
|
||||
formatted = eval_const_expressions_mutator((Node *) jve->formatted_expr,
|
||||
context);
|
||||
context);
|
||||
|
||||
context->case_val = save_case_val;
|
||||
|
||||
@@ -5315,7 +5315,7 @@ pull_paramids_walker(Node *node, Bitmapset **context)
|
||||
return false;
|
||||
if (IsA(node, Param))
|
||||
{
|
||||
Param *param = (Param *)node;
|
||||
Param *param = (Param *) node;
|
||||
|
||||
*context = bms_add_member(*context, param->paramid);
|
||||
return false;
|
||||
|
@@ -968,102 +968,102 @@ estimate_rel_size(Relation rel, int32 *attr_widths,
|
||||
|
||||
if (RELKIND_HAS_TABLE_AM(rel->rd_rel->relkind))
|
||||
{
|
||||
table_relation_estimate_size(rel, attr_widths, pages, tuples,
|
||||
allvisfrac);
|
||||
table_relation_estimate_size(rel, attr_widths, pages, tuples,
|
||||
allvisfrac);
|
||||
}
|
||||
else if (rel->rd_rel->relkind == RELKIND_INDEX)
|
||||
{
|
||||
/*
|
||||
* XXX: It'd probably be good to move this into a callback, individual
|
||||
* index types e.g. know if they have a metapage.
|
||||
*/
|
||||
|
||||
/* it has storage, ok to call the smgr */
|
||||
curpages = RelationGetNumberOfBlocks(rel);
|
||||
|
||||
/* report estimated # pages */
|
||||
*pages = curpages;
|
||||
/* quick exit if rel is clearly empty */
|
||||
if (curpages == 0)
|
||||
{
|
||||
*tuples = 0;
|
||||
*allvisfrac = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* coerce values in pg_class to more desirable types */
|
||||
relpages = (BlockNumber) rel->rd_rel->relpages;
|
||||
reltuples = (double) rel->rd_rel->reltuples;
|
||||
relallvisible = (BlockNumber) rel->rd_rel->relallvisible;
|
||||
|
||||
/*
|
||||
* Discount the metapage while estimating the number of tuples. This
|
||||
* is a kluge because it assumes more than it ought to about index
|
||||
* structure. Currently it's OK for btree, hash, and GIN indexes but
|
||||
* suspect for GiST indexes.
|
||||
*/
|
||||
if (relpages > 0)
|
||||
{
|
||||
curpages--;
|
||||
relpages--;
|
||||
}
|
||||
|
||||
/* estimate number of tuples from previous tuple density */
|
||||
if (reltuples >= 0 && relpages > 0)
|
||||
density = reltuples / (double) relpages;
|
||||
else
|
||||
{
|
||||
/*
|
||||
* XXX: It'd probably be good to move this into a callback,
|
||||
* individual index types e.g. know if they have a metapage.
|
||||
* If we have no data because the relation was never vacuumed,
|
||||
* estimate tuple width from attribute datatypes. We assume here
|
||||
* that the pages are completely full, which is OK for tables
|
||||
* (since they've presumably not been VACUUMed yet) but is
|
||||
* probably an overestimate for indexes. Fortunately
|
||||
* get_relation_info() can clamp the overestimate to the parent
|
||||
* table's size.
|
||||
*
|
||||
* Note: this code intentionally disregards alignment
|
||||
* considerations, because (a) that would be gilding the lily
|
||||
* considering how crude the estimate is, and (b) it creates
|
||||
* platform dependencies in the default plans which are kind of a
|
||||
* headache for regression testing.
|
||||
*
|
||||
* XXX: Should this logic be more index specific?
|
||||
*/
|
||||
int32 tuple_width;
|
||||
|
||||
/* it has storage, ok to call the smgr */
|
||||
curpages = RelationGetNumberOfBlocks(rel);
|
||||
tuple_width = get_rel_data_width(rel, attr_widths);
|
||||
tuple_width += MAXALIGN(SizeofHeapTupleHeader);
|
||||
tuple_width += sizeof(ItemIdData);
|
||||
/* note: integer division is intentional here */
|
||||
density = (BLCKSZ - SizeOfPageHeaderData) / tuple_width;
|
||||
}
|
||||
*tuples = rint(density * (double) curpages);
|
||||
|
||||
/* report estimated # pages */
|
||||
*pages = curpages;
|
||||
/* quick exit if rel is clearly empty */
|
||||
if (curpages == 0)
|
||||
{
|
||||
*tuples = 0;
|
||||
*allvisfrac = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* coerce values in pg_class to more desirable types */
|
||||
relpages = (BlockNumber) rel->rd_rel->relpages;
|
||||
reltuples = (double) rel->rd_rel->reltuples;
|
||||
relallvisible = (BlockNumber) rel->rd_rel->relallvisible;
|
||||
|
||||
/*
|
||||
* Discount the metapage while estimating the number of tuples.
|
||||
* This is a kluge because it assumes more than it ought to about
|
||||
* index structure. Currently it's OK for btree, hash, and GIN
|
||||
* indexes but suspect for GiST indexes.
|
||||
*/
|
||||
if (relpages > 0)
|
||||
{
|
||||
curpages--;
|
||||
relpages--;
|
||||
}
|
||||
|
||||
/* estimate number of tuples from previous tuple density */
|
||||
if (reltuples >= 0 && relpages > 0)
|
||||
density = reltuples / (double) relpages;
|
||||
else
|
||||
{
|
||||
/*
|
||||
* If we have no data because the relation was never vacuumed,
|
||||
* estimate tuple width from attribute datatypes. We assume
|
||||
* here that the pages are completely full, which is OK for
|
||||
* tables (since they've presumably not been VACUUMed yet) but
|
||||
* is probably an overestimate for indexes. Fortunately
|
||||
* get_relation_info() can clamp the overestimate to the
|
||||
* parent table's size.
|
||||
*
|
||||
* Note: this code intentionally disregards alignment
|
||||
* considerations, because (a) that would be gilding the lily
|
||||
* considering how crude the estimate is, and (b) it creates
|
||||
* platform dependencies in the default plans which are kind
|
||||
* of a headache for regression testing.
|
||||
*
|
||||
* XXX: Should this logic be more index specific?
|
||||
*/
|
||||
int32 tuple_width;
|
||||
|
||||
tuple_width = get_rel_data_width(rel, attr_widths);
|
||||
tuple_width += MAXALIGN(SizeofHeapTupleHeader);
|
||||
tuple_width += sizeof(ItemIdData);
|
||||
/* note: integer division is intentional here */
|
||||
density = (BLCKSZ - SizeOfPageHeaderData) / tuple_width;
|
||||
}
|
||||
*tuples = rint(density * (double) curpages);
|
||||
|
||||
/*
|
||||
* We use relallvisible as-is, rather than scaling it up like we
|
||||
* do for the pages and tuples counts, on the theory that any
|
||||
* pages added since the last VACUUM are most likely not marked
|
||||
* all-visible. But costsize.c wants it converted to a fraction.
|
||||
*/
|
||||
if (relallvisible == 0 || curpages <= 0)
|
||||
*allvisfrac = 0;
|
||||
else if ((double) relallvisible >= curpages)
|
||||
*allvisfrac = 1;
|
||||
else
|
||||
*allvisfrac = (double) relallvisible / curpages;
|
||||
/*
|
||||
* We use relallvisible as-is, rather than scaling it up like we do
|
||||
* for the pages and tuples counts, on the theory that any pages added
|
||||
* since the last VACUUM are most likely not marked all-visible. But
|
||||
* costsize.c wants it converted to a fraction.
|
||||
*/
|
||||
if (relallvisible == 0 || curpages <= 0)
|
||||
*allvisfrac = 0;
|
||||
else if ((double) relallvisible >= curpages)
|
||||
*allvisfrac = 1;
|
||||
else
|
||||
*allvisfrac = (double) relallvisible / curpages;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Just use whatever's in pg_class. This covers foreign tables,
|
||||
* sequences, and also relkinds without storage (shouldn't get
|
||||
* here?); see initializations in AddNewRelationTuple(). Note
|
||||
* that FDW must cope if reltuples is -1!
|
||||
*/
|
||||
*pages = rel->rd_rel->relpages;
|
||||
*tuples = rel->rd_rel->reltuples;
|
||||
*allvisfrac = 0;
|
||||
/*
|
||||
* Just use whatever's in pg_class. This covers foreign tables,
|
||||
* sequences, and also relkinds without storage (shouldn't get here?);
|
||||
* see initializations in AddNewRelationTuple(). Note that FDW must
|
||||
* cope if reltuples is -1!
|
||||
*/
|
||||
*pages = rel->rd_rel->relpages;
|
||||
*tuples = rel->rd_rel->reltuples;
|
||||
*allvisfrac = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user