1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +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:
Tom Lane
2022-05-12 15:17:30 -04:00
parent 93909599cd
commit 23e7b38bfe
287 changed files with 5193 additions and 3549 deletions

View File

@ -429,7 +429,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
*/
if (onerel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
{
List *idxs = RelationGetIndexList(onerel);
List *idxs = RelationGetIndexList(onerel);
Irel = NULL;
nindexes = 0;
@ -680,10 +680,10 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
}
/*
* Now report ANALYZE to the cumulative stats system. For regular tables, we do
* it only if not doing inherited stats. For partitioned tables, we only
* do it for inherited stats. (We're never called for not-inherited stats
* on partitioned tables anyway.)
* Now report ANALYZE to the cumulative stats system. For regular tables,
* we do it only if not doing inherited stats. For partitioned tables, we
* only do it for inherited stats. (We're never called for not-inherited
* stats on partitioned tables anyway.)
*
* Reset the changes_since_analyze counter only if we analyzed all
* columns; otherwise, there is still work for auto-analyze to do.

View File

@ -246,8 +246,9 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
/*
* Nondeterministic collations are currently only supported with ICU
* because that's the only case where it can actually make a difference.
* So we can save writing the code for the other providers.
* because that's the only case where it can actually make a
* difference. So we can save writing the code for the other
* providers.
*/
if (!collisdeterministic && collprovider != COLLPROVIDER_ICU)
ereport(ERROR,

View File

@ -345,7 +345,7 @@ defGetCopyHeaderChoice(DefElem *def)
break;
default:
{
char *sval = defGetString(def);
char *sval = defGetString(def);
/*
* The set of strings accepted here should match up with the
@ -365,8 +365,8 @@ defGetCopyHeaderChoice(DefElem *def)
break;
}
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a Boolean value or \"match\"",
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("%s requires a Boolean value or \"match\"",
def->defname)));
return COPY_HEADER_FALSE; /* keep compiler quiet */
}

View File

@ -800,7 +800,8 @@ NextCopyFromRawFields(CopyFromState cstate, char ***fields, int *nfields)
errmsg("column name mismatch in header line field %d: got null value (\"%s\"), expected \"%s\"",
fldnum, cstate->opts.null_print, NameStr(attr->attname))));
if (namestrcmp(&attr->attname, colName) != 0) {
if (namestrcmp(&attr->attname, colName) != 0)
{
ereport(ERROR,
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
errmsg("column name mismatch in header line field %d: got \"%s\", expected \"%s\"",

View File

@ -439,8 +439,8 @@ BeginCopyTo(ParseState *pstate,
* locks on the source table(s).
*/
rewritten = pg_analyze_and_rewrite_fixedparams(raw_query,
pstate->p_sourcetext, NULL, 0,
NULL);
pstate->p_sourcetext, NULL, 0,
NULL);
/* check that we got back something we can work with */
if (rewritten == NIL)
@ -862,7 +862,7 @@ DoCopyTo(CopyToState cstate)
if (cstate->opts.csv_mode)
CopyAttributeOutCSV(cstate, colname, false,
list_length(cstate->attnumlist) == 1);
list_length(cstate->attnumlist) == 1);
else
CopyAttributeOutText(cstate, colname);
}

View File

@ -201,9 +201,9 @@ CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid,
*
* We typically do not read relation data into shared_buffers without
* holding a relation lock. It's unclear what could go wrong if we
* skipped it in this case, because nobody can be modifying either
* the source or destination database at this point, and we have locks
* on both databases, too, but let's take the conservative route.
* skipped it in this case, because nobody can be modifying either the
* source or destination database at this point, and we have locks on
* both databases, too, but let's take the conservative route.
*/
dstrelid.relId = srcrelid.relId = relinfo->reloid;
LockRelationId(&srcrelid, AccessShareLock);
@ -274,9 +274,9 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath)
/*
* We can't use a real relcache entry for a relation in some other
* database, but since we're only going to access the fields related
* to physical storage, a fake one is good enough. If we didn't do this
* and used the smgr layer directly, we would have to worry about
* database, but since we're only going to access the fields related to
* physical storage, a fake one is good enough. If we didn't do this and
* used the smgr layer directly, we would have to worry about
* invalidations.
*/
rel = CreateFakeRelcacheEntry(rnode);
@ -333,10 +333,10 @@ ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid tbid, Oid dbid,
char *srcpath, List *rnodelist,
Snapshot snapshot)
{
BlockNumber blkno = BufferGetBlockNumber(buf);
OffsetNumber offnum;
OffsetNumber maxoff;
HeapTupleData tuple;
BlockNumber blkno = BufferGetBlockNumber(buf);
OffsetNumber offnum;
OffsetNumber maxoff;
HeapTupleData tuple;
maxoff = PageGetMaxOffsetNumber(page);
@ -368,10 +368,10 @@ ScanSourceDatabasePgClassPage(Page page, Buffer buf, Oid tbid, Oid dbid,
CreateDBRelInfo *relinfo;
/*
* ScanSourceDatabasePgClassTuple is in charge of constructing
* a CreateDBRelInfo object for this tuple, but can also decide
* that this tuple isn't something we need to copy. If we do need
* to copy the relation, add it to the list.
* ScanSourceDatabasePgClassTuple is in charge of constructing a
* CreateDBRelInfo object for this tuple, but can also decide that
* this tuple isn't something we need to copy. If we do need to
* copy the relation, add it to the list.
*/
relinfo = ScanSourceDatabasePgClassTuple(&tuple, tbid, dbid,
srcpath);
@ -395,9 +395,9 @@ CreateDBRelInfo *
ScanSourceDatabasePgClassTuple(HeapTupleData *tuple, Oid tbid, Oid dbid,
char *srcpath)
{
CreateDBRelInfo *relinfo;
Form_pg_class classForm;
Oid relfilenode = InvalidOid;
CreateDBRelInfo *relinfo;
Form_pg_class classForm;
Oid relfilenode = InvalidOid;
classForm = (Form_pg_class) GETSTRUCT(tuple);
@ -406,11 +406,11 @@ ScanSourceDatabasePgClassTuple(HeapTupleData *tuple, Oid tbid, Oid dbid,
*
* Shared objects don't need to be copied, because they are shared.
* Objects without storage can't be copied, because there's nothing to
* copy. Temporary relations don't need to be copied either, because
* they are inaccessible outside of the session that created them,
* which must be gone already, and couldn't connect to a different database
* if it still existed. autovacuum will eventually remove the pg_class
* entries as well.
* copy. Temporary relations don't need to be copied either, because they
* are inaccessible outside of the session that created them, which must
* be gone already, and couldn't connect to a different database if it
* still existed. autovacuum will eventually remove the pg_class entries
* as well.
*/
if (classForm->reltablespace == GLOBALTABLESPACE_OID ||
!RELKIND_HAS_STORAGE(classForm->relkind) ||
@ -702,7 +702,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
DefElem *dcollate = NULL;
DefElem *dctype = NULL;
DefElem *diculocale = NULL;
DefElem *dlocprovider = NULL;
DefElem *dlocprovider = NULL;
DefElem *distemplate = NULL;
DefElem *dallowconnections = NULL;
DefElem *dconnlimit = NULL;
@ -824,10 +824,10 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
/*
* We don't normally permit new databases to be created with
* system-assigned OIDs. pg_upgrade tries to preserve database
* OIDs, so we can't allow any database to be created with an
* OID that might be in use in a freshly-initialized cluster
* created by some future version. We assume all such OIDs will
* be from the system-managed OID range.
* OIDs, so we can't allow any database to be created with an OID
* that might be in use in a freshly-initialized cluster created
* by some future version. We assume all such OIDs will be from
* the system-managed OID range.
*
* As an exception, however, we permit any OID to be assigned when
* allow_system_table_mods=on (so that initdb can assign system
@ -1348,15 +1348,15 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
InvokeObjectPostCreateHook(DatabaseRelationId, dboid, 0);
/*
* If we're going to be reading data for the to-be-created database
* into shared_buffers, take a lock on it. Nobody should know that this
* If we're going to be reading data for the to-be-created database into
* shared_buffers, take a lock on it. Nobody should know that this
* database exists yet, but it's good to maintain the invariant that a
* lock an AccessExclusiveLock on the database is sufficient to drop all
* of its buffers without worrying about more being read later.
*
* Note that we need to do this before entering the PG_ENSURE_ERROR_CLEANUP
* block below, because createdb_failure_callback expects this lock to
* be held already.
* Note that we need to do this before entering the
* PG_ENSURE_ERROR_CLEANUP block below, because createdb_failure_callback
* expects this lock to be held already.
*/
if (dbstrategy == CREATEDB_WAL_LOG)
LockSharedObject(DatabaseRelationId, dboid, 0, AccessShareLock);

View File

@ -3833,7 +3833,7 @@ ExplainTargetRel(Plan *plan, Index rti, ExplainState *es)
if (rte->tablefunc)
if (rte->tablefunc->functype == TFT_XMLTABLE)
objectname = "xmltable";
else /* Must be TFT_JSON_TABLE */
else /* Must be TFT_JSON_TABLE */
objectname = "json_table";
else
objectname = NULL;

View File

@ -758,10 +758,10 @@ execute_sql_string(const char *sql)
CommandCounterIncrement();
stmt_list = pg_analyze_and_rewrite_fixedparams(parsetree,
sql,
NULL,
0,
NULL);
sql,
NULL,
0,
NULL);
stmt_list = pg_plan_queries(stmt_list, sql, CURSOR_OPT_PARALLEL_OK, NULL);
foreach(lc2, stmt_list)

View File

@ -332,8 +332,8 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
/*
* Inform cumulative stats system about our activity: basically, we
* truncated the matview and inserted some new data. (The concurrent
* code path above doesn't need to worry about this because the inserts
* and deletes it issues get counted by lower-level code.)
* code path above doesn't need to worry about this because the
* inserts and deletes it issues get counted by lower-level code.)
*/
pgstat_count_truncate(matviewRel);
if (!stmt->skipData)

View File

@ -297,7 +297,7 @@ contain_invalid_rfcolumn_walker(Node *node, rf_context *context)
*/
bool
pub_rf_contains_invalid_column(Oid pubid, Relation relation, List *ancestors,
bool pubviaroot)
bool pubviaroot)
{
HeapTuple rftuple;
Oid relid = RelationGetRelid(relation);
@ -373,7 +373,7 @@ pub_rf_contains_invalid_column(Oid pubid, Relation relation, List *ancestors,
*/
bool
pub_collist_contains_invalid_column(Oid pubid, Relation relation, List *ancestors,
bool pubviaroot)
bool pubviaroot)
{
HeapTuple tuple;
Oid relid = RelationGetRelid(relation);
@ -384,8 +384,8 @@ pub_collist_contains_invalid_column(Oid pubid, Relation relation, List *ancestor
/*
* For a partition, if pubviaroot is true, find the topmost ancestor that
* is published via this publication as we need to use its column list
* for the changes.
* is published via this publication as we need to use its column list for
* the changes.
*
* Note that even though the column list used is for an ancestor, the
* REPLICA IDENTITY used will be for the actual child table.
@ -399,19 +399,19 @@ pub_collist_contains_invalid_column(Oid pubid, Relation relation, List *ancestor
}
tuple = SearchSysCache2(PUBLICATIONRELMAP,
ObjectIdGetDatum(publish_as_relid),
ObjectIdGetDatum(pubid));
ObjectIdGetDatum(publish_as_relid),
ObjectIdGetDatum(pubid));
if (!HeapTupleIsValid(tuple))
return false;
datum = SysCacheGetAttr(PUBLICATIONRELMAP, tuple,
Anum_pg_publication_rel_prattrs,
&isnull);
Anum_pg_publication_rel_prattrs,
&isnull);
if (!isnull)
{
int x;
int x;
Bitmapset *idattrs;
Bitmapset *columns = NULL;
@ -429,8 +429,9 @@ pub_collist_contains_invalid_column(Oid pubid, Relation relation, List *ancestor
/*
* Attnums in the bitmap returned by RelationGetIndexAttrBitmap are
* offset (to handle system columns the usual way), while column list
* does not use offset, so we can't do bms_is_subset(). Instead, we have
* to loop over the idattrs and check all of them are in the list.
* does not use offset, so we can't do bms_is_subset(). Instead, we
* have to loop over the idattrs and check all of them are in the
* list.
*/
x = -1;
while ((x = bms_next_member(idattrs, x)) >= 0)
@ -440,14 +441,14 @@ pub_collist_contains_invalid_column(Oid pubid, Relation relation, List *ancestor
/*
* If pubviaroot is true, we are validating the column list of the
* parent table, but the bitmap contains the replica identity
* information of the child table. The parent/child attnums may not
* match, so translate them to the parent - get the attname from
* the child, and look it up in the parent.
* information of the child table. The parent/child attnums may
* not match, so translate them to the parent - get the attname
* from the child, and look it up in the parent.
*/
if (pubviaroot)
{
/* attribute name in the child table */
char *colname = get_attname(relid, attnum, false);
char *colname = get_attname(relid, attnum, false);
/*
* Determine the attnum for the attribute name in parent (we
@ -720,7 +721,7 @@ TransformPubWhereClauses(List *tables, const char *queryString,
*/
static void
CheckPubRelationColumnList(List *tables, const char *queryString,
bool pubviaroot)
bool pubviaroot)
{
ListCell *lc;
@ -864,7 +865,7 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt)
publish_via_partition_root);
CheckPubRelationColumnList(rels, pstate->p_sourcetext,
publish_via_partition_root);
publish_via_partition_root);
PublicationAddTables(puboid, rels, true, NULL);
CloseTableList(rels);
@ -1198,8 +1199,8 @@ AlterPublicationTables(AlterPublicationStmt *stmt, HeapTuple tup,
/* Transform the int2vector column list to a bitmap. */
columnListDatum = SysCacheGetAttr(PUBLICATIONRELMAP, rftuple,
Anum_pg_publication_rel_prattrs,
&isnull);
Anum_pg_publication_rel_prattrs,
&isnull);
if (!isnull)
oldcolumns = pub_collist_to_bitmapset(NULL, columnListDatum, NULL);
@ -1210,15 +1211,15 @@ AlterPublicationTables(AlterPublicationStmt *stmt, HeapTuple tup,
foreach(newlc, rels)
{
PublicationRelInfo *newpubrel;
Oid newrelid;
Bitmapset *newcolumns = NULL;
Oid newrelid;
Bitmapset *newcolumns = NULL;
newpubrel = (PublicationRelInfo *) lfirst(newlc);
newrelid = RelationGetRelid(newpubrel->relation);
/*
* If the new publication has column list, transform it to
* a bitmap too.
* If the new publication has column list, transform it to a
* bitmap too.
*/
if (newpubrel->columns)
{

View File

@ -258,9 +258,9 @@ CreateStatistics(CreateStatsStmt *stmt)
nattnums++;
ReleaseSysCache(atttuple);
}
else if (IsA(selem->expr, Var)) /* column reference in parens */
else if (IsA(selem->expr, Var)) /* column reference in parens */
{
Var *var = (Var *) selem->expr;
Var *var = (Var *) selem->expr;
TypeCacheEntry *type;
/* Disallow use of system attributes in extended stats */
@ -297,10 +297,11 @@ CreateStatistics(CreateStatsStmt *stmt)
while ((k = bms_next_member(attnums, k)) >= 0)
{
AttrNumber attnum = k + FirstLowInvalidHeapAttributeNumber;
if (attnum <= 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("statistics creation on system columns is not supported")));
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("statistics creation on system columns is not supported")));
}
/*
@ -511,9 +512,9 @@ CreateStatistics(CreateStatsStmt *stmt)
relation_close(statrel, RowExclusiveLock);
/*
* We used to create the pg_statistic_ext_data tuple too, but it's not clear
* what value should the stxdinherit flag have (it depends on whether the rel
* is partitioned, contains data, etc.)
* We used to create the pg_statistic_ext_data tuple too, but it's not
* clear what value should the stxdinherit flag have (it depends on
* whether the rel is partitioned, contains data, etc.)
*/
InvokeObjectPostCreateHook(StatisticExtRelationId, statoid, 0);

View File

@ -1578,13 +1578,13 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
PG_END_TRY();
/*
* Tell the cumulative stats system that the subscription is getting dropped.
* We can safely report dropping the subscription statistics here if the
* subscription is associated with a replication slot since we cannot run
* DROP SUBSCRIPTION inside a transaction block. Subscription statistics
* will be removed later by (auto)vacuum either if it's not associated
* with a replication slot or if the message for dropping the subscription
* gets lost.
* Tell the cumulative stats system that the subscription is getting
* dropped. We can safely report dropping the subscription statistics here
* if the subscription is associated with a replication slot since we
* cannot run DROP SUBSCRIPTION inside a transaction block. Subscription
* statistics will be removed later by (auto)vacuum either if it's not
* associated with a replication slot or if the message for dropping the
* subscription gets lost.
*/
if (slotname)
pgstat_drop_subscription(subid);

View File

@ -495,8 +495,8 @@ static ObjectAddress addFkRecurseReferenced(List **wqueue, Constraint *fkconstra
bool old_check_ok,
Oid parentDelTrigger, Oid parentUpdTrigger);
static void validateFkOnDeleteSetColumns(int numfks, const int16 *fkattnums,
int numfksetcols, const int16 *fksetcolsattnums,
List *fksetcols);
int numfksetcols, const int16 *fksetcolsattnums,
List *fksetcols);
static void addFkRecurseReferencing(List **wqueue, Constraint *fkconstraint,
Relation rel, Relation pkrel, Oid indexOid, Oid parentConstr,
int numfks, int16 *pkattnum, int16 *fkattnum,
@ -5579,7 +5579,7 @@ ATRewriteTables(AlterTableStmt *parsetree, List **wqueue, LOCKMODE lockmode,
foreach(lc, seqlist)
{
Oid seq_relid = lfirst_oid(lc);
Oid seq_relid = lfirst_oid(lc);
SequenceChangePersistence(seq_relid, tab->newrelpersistence);
}
@ -9448,8 +9448,8 @@ validateFkOnDeleteSetColumns(int numfks, const int16 *fkattnums,
{
for (int i = 0; i < numfksetcols; i++)
{
int16 setcol_attnum = fksetcolsattnums[i];
bool seen = false;
int16 setcol_attnum = fksetcolsattnums[i];
bool seen = false;
for (int j = 0; j < numfks; j++)
{
@ -9462,7 +9462,8 @@ validateFkOnDeleteSetColumns(int numfks, const int16 *fkattnums,
if (!seen)
{
char *col = strVal(list_nth(fksetcols, i));
char *col = strVal(list_nth(fksetcols, i));
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
errmsg("column \"%s\" referenced in ON DELETE SET action must be part of foreign key", col)));
@ -15890,6 +15891,7 @@ relation_mark_replica_identity(Relation rel, char ri_type, Oid indexOid,
CatalogTupleUpdate(pg_index, &pg_index_tuple->t_self, pg_index_tuple);
InvokeObjectPostAlterHookArg(IndexRelationId, thisIndexOid, 0,
InvalidOid, is_internal);
/*
* Invalidate the relcache for the table, so that after we commit
* all sessions will refresh the table's replica identity index
@ -17931,12 +17933,12 @@ ATExecAttachPartition(List **wqueue, Relation rel, PartitionCmd *cmd,
/*
* If the partition we just attached is partitioned itself, invalidate
* relcache for all descendent partitions too to ensure that their
* rd_partcheck expression trees are rebuilt; partitions already locked
* at the beginning of this function.
* rd_partcheck expression trees are rebuilt; partitions already locked at
* the beginning of this function.
*/
if (attachrel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
{
ListCell *l;
ListCell *l;
foreach(l, attachrel_children)
{
@ -18652,13 +18654,13 @@ DetachPartitionFinalize(Relation rel, Relation partRel, bool concurrent,
/*
* If the partition we just detached is partitioned itself, invalidate
* relcache for all descendent partitions too to ensure that their
* rd_partcheck expression trees are rebuilt; must lock partitions
* before doing so, using the same lockmode as what partRel has been
* locked with by the caller.
* rd_partcheck expression trees are rebuilt; must lock partitions before
* doing so, using the same lockmode as what partRel has been locked with
* by the caller.
*/
if (partRel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
{
List *children;
List *children;
children = find_all_inheritors(RelationGetRelid(partRel),
AccessExclusiveLock, NULL);

View File

@ -89,7 +89,7 @@ char *default_tablespace = NULL;
char *temp_tablespaces = NULL;
bool allow_in_place_tablespaces = false;
Oid binary_upgrade_next_pg_tablespace_oid = InvalidOid;
Oid binary_upgrade_next_pg_tablespace_oid = InvalidOid;
static void create_tablespace_directories(const char *location,
const Oid tablespaceoid);

View File

@ -798,11 +798,11 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt)
*/
if (drolemembers)
{
List *rolemembers = (List *) drolemembers->arg;
List *rolemembers = (List *) drolemembers->arg;
CommandCounterIncrement();
if (stmt->action == +1) /* add members to role */
if (stmt->action == +1) /* add members to role */
AddRoleMems(rolename, roleid,
rolemembers, roleSpecsToIds(rolemembers),
GetUserId(), false);

View File

@ -1409,7 +1409,7 @@ vac_update_relstats(Relation relation,
*frozenxid_updated = false;
if (TransactionIdIsNormal(frozenxid) && oldfrozenxid != frozenxid)
{
bool update = false;
bool update = false;
if (TransactionIdPrecedes(oldfrozenxid, frozenxid))
update = true;
@ -1432,7 +1432,7 @@ vac_update_relstats(Relation relation,
*minmulti_updated = false;
if (MultiXactIdIsValid(minmulti) && oldminmulti != minmulti)
{
bool update = false;
bool update = false;
if (MultiXactIdPrecedes(oldminmulti, minmulti))
update = true;

View File

@ -112,7 +112,7 @@ typedef enum PVIndVacStatus
PARALLEL_INDVAC_STATUS_NEED_BULKDELETE,
PARALLEL_INDVAC_STATUS_NEED_CLEANUP,
PARALLEL_INDVAC_STATUS_COMPLETED
} PVIndVacStatus;
} PVIndVacStatus;
/*
* Struct for index vacuum statistics of an index that is used for parallel vacuum.