1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-06 07:49:08 +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

@@ -312,7 +312,7 @@ AddWALInfoToBackupManifest(backup_manifest_info *manifest, XLogRecPtr startptr,
* Finalize the backup manifest, and send it to the client.
*/
void
SendBackupManifest(backup_manifest_info *manifest, bbsink * sink)
SendBackupManifest(backup_manifest_info *manifest, bbsink *sink)
{
uint8 checksumbuf[PG_SHA256_DIGEST_LENGTH];
char checksumstringbuf[PG_SHA256_DIGEST_STRING_LENGTH];

View File

@@ -124,18 +124,18 @@ bbsink_copystream_begin_backup(bbsink *sink)
{
bbsink_copystream *mysink = (bbsink_copystream *) sink;
bbsink_state *state = sink->bbs_state;
char *buf;
char *buf;
/*
* Initialize buffer. We ultimately want to send the archive and manifest
* data by means of CopyData messages where the payload portion of each
* message begins with a type byte. However, basebackup.c expects the
* buffer to be aligned, so we can't just allocate one extra byte for the
* type byte. Instead, allocate enough extra bytes that the portion of
* the buffer we reveal to our callers can be aligned, while leaving room
* to slip the type byte in just beforehand. That will allow us to ship
* the data with a single call to pq_putmessage and without needing any
* extra copying.
* type byte. Instead, allocate enough extra bytes that the portion of the
* buffer we reveal to our callers can be aligned, while leaving room to
* slip the type byte in just beforehand. That will allow us to ship the
* data with a single call to pq_putmessage and without needing any extra
* copying.
*/
buf = palloc(mysink->base.bbs_buffer_length + MAXIMUM_ALIGNOF);
mysink->msgbuffer = buf + (MAXIMUM_ALIGNOF - 1);

View File

@@ -68,7 +68,7 @@ bbsink_gzip_new(bbsink *next, pg_compress_specification *compress)
return NULL; /* keep compiler quiet */
#else
bbsink_gzip *sink;
int compresslevel;
int compresslevel;
Assert(next != NULL);
@@ -118,8 +118,8 @@ static void
bbsink_gzip_begin_archive(bbsink *sink, const char *archive_name)
{
bbsink_gzip *mysink = (bbsink_gzip *) sink;
char *gz_archive_name;
z_stream *zs = &mysink->zstream;
char *gz_archive_name;
z_stream *zs = &mysink->zstream;
/* Initialize compressor object. */
memset(zs, 0, sizeof(z_stream));
@@ -129,10 +129,10 @@ bbsink_gzip_begin_archive(bbsink *sink, const char *archive_name)
zs->avail_out = sink->bbs_next->bbs_buffer_length;
/*
* We need to use deflateInit2() rather than deflateInit() here so that
* we can request a gzip header rather than a zlib header. Otherwise, we
* want to supply the same values that would have been used by default
* if we had just called deflateInit().
* We need to use deflateInit2() rather than deflateInit() here so that we
* can request a gzip header rather than a zlib header. Otherwise, we want
* to supply the same values that would have been used by default if we
* had just called deflateInit().
*
* Per the documentation for deflateInit2, the third argument must be
* Z_DEFLATED; the fourth argument is the number of "window bits", by
@@ -147,9 +147,8 @@ bbsink_gzip_begin_archive(bbsink *sink, const char *archive_name)
errmsg("could not initialize compression library"));
/*
* Add ".gz" to the archive name. Note that the pg_basebackup -z
* produces archives named ".tar.gz" rather than ".tgz", so we match
* that here.
* Add ".gz" to the archive name. Note that the pg_basebackup -z produces
* archives named ".tar.gz" rather than ".tgz", so we match that here.
*/
gz_archive_name = psprintf("%s.gz", archive_name);
Assert(sink->bbs_next != NULL);
@@ -172,7 +171,7 @@ static void
bbsink_gzip_archive_contents(bbsink *sink, size_t len)
{
bbsink_gzip *mysink = (bbsink_gzip *) sink;
z_stream *zs = &mysink->zstream;
z_stream *zs = &mysink->zstream;
/* Compress data from input buffer. */
zs->next_in = (uint8 *) mysink->base.bbs_buffer;
@@ -180,7 +179,7 @@ bbsink_gzip_archive_contents(bbsink *sink, size_t len)
while (zs->avail_in > 0)
{
int res;
int res;
/* Write output data into unused portion of output buffer. */
Assert(mysink->bytes_written < mysink->base.bbs_next->bbs_buffer_length);
@@ -230,7 +229,7 @@ static void
bbsink_gzip_end_archive(bbsink *sink)
{
bbsink_gzip *mysink = (bbsink_gzip *) sink;
z_stream *zs = &mysink->zstream;
z_stream *zs = &mysink->zstream;
/* There is no more data available. */
zs->next_in = (uint8 *) mysink->base.bbs_buffer;
@@ -238,7 +237,7 @@ bbsink_gzip_end_archive(bbsink *sink)
while (1)
{
int res;
int res;
/* Write output data into unused portion of output buffer. */
Assert(mysink->bytes_written < mysink->base.bbs_next->bbs_buffer_length);
@@ -248,8 +247,8 @@ bbsink_gzip_end_archive(bbsink *sink)
mysink->base.bbs_next->bbs_buffer_length - mysink->bytes_written;
/*
* As bbsink_gzip_archive_contents, but pass Z_FINISH since there
* is no more input.
* As bbsink_gzip_archive_contents, but pass Z_FINISH since there is
* no more input.
*/
res = deflate(zs, Z_FINISH);
if (res == Z_STREAM_ERROR)
@@ -260,8 +259,8 @@ bbsink_gzip_end_archive(bbsink *sink)
mysink->base.bbs_next->bbs_buffer_length - zs->avail_out;
/*
* Apparently we had no data in the output buffer and deflate()
* was not able to add any. We must be done.
* Apparently we had no data in the output buffer and deflate() was
* not able to add any. We must be done.
*/
if (mysink->bytes_written == 0)
break;

View File

@@ -68,7 +68,7 @@ bbsink_lz4_new(bbsink *next, pg_compress_specification *compress)
return NULL; /* keep compiler quiet */
#else
bbsink_lz4 *sink;
int compresslevel;
int compresslevel;
Assert(next != NULL);

View File

@@ -77,10 +77,11 @@ bbsink_server_new(bbsink *next, char *pathname)
/*
* It's not a good idea to store your backups in the same directory that
* you're backing up. If we allowed a relative path here, that could easily
* happen accidentally, so we don't. The user could still accomplish the
* same thing by including the absolute path to $PGDATA in the pathname,
* but that's likely an intentional bad decision rather than an accident.
* you're backing up. If we allowed a relative path here, that could
* easily happen accidentally, so we don't. The user could still
* accomplish the same thing by including the absolute path to $PGDATA in
* the pathname, but that's likely an intentional bad decision rather than
* an accident.
*/
if (!is_absolute_path(pathname))
ereport(ERROR,
@@ -90,14 +91,15 @@ bbsink_server_new(bbsink *next, char *pathname)
switch (pg_check_dir(pathname))
{
case 0:
/*
* Does not exist, so create it using the same permissions we'd use
* for a new subdirectory of the data directory itself.
* Does not exist, so create it using the same permissions we'd
* use for a new subdirectory of the data directory itself.
*/
if (MakePGDirectory(pathname) < 0)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not create directory \"%s\": %m", pathname)));
(errcode_for_file_access(),
errmsg("could not create directory \"%s\": %m", pathname)));
break;
case 1:

View File

@@ -80,9 +80,9 @@ BaseBackupAddTarget(char *name,
/*
* We found one, so update it.
*
* It is probably not a great idea to call BaseBackupAddTarget
* for the same name multiple times, but if it happens, this
* seems like the sanest behavior.
* It is probably not a great idea to call BaseBackupAddTarget for
* the same name multiple times, but if it happens, this seems
* like the sanest behavior.
*/
ttype->check_detail = check_detail;
ttype->get_sink = get_sink;
@@ -91,9 +91,9 @@ BaseBackupAddTarget(char *name,
}
/*
* We use TopMemoryContext for allocations here to make sure that the
* data we need doesn't vanish under us; that's also why we copy the
* target name into a newly-allocated chunk of memory.
* We use TopMemoryContext for allocations here to make sure that the data
* we need doesn't vanish under us; that's also why we copy the target
* name into a newly-allocated chunk of memory.
*/
oldcontext = MemoryContextSwitchTo(TopMemoryContext);
ttype = palloc(sizeof(BaseBackupTargetType));

View File

@@ -108,9 +108,9 @@ bbsink_zstd_begin_backup(bbsink *sink)
if ((compress->options & PG_COMPRESSION_OPTION_WORKERS) != 0)
{
/*
* On older versions of libzstd, this option does not exist, and trying
* to set it will fail. Similarly for newer versions if they are
* compiled without threading support.
* On older versions of libzstd, this option does not exist, and
* trying to set it will fail. Similarly for newer versions if they
* are compiled without threading support.
*/
ret = ZSTD_CCtx_setParameter(mysink->cctx, ZSTD_c_nbWorkers,
compress->workers);

View File

@@ -92,7 +92,7 @@ LogicalDecodingProcessRecord(LogicalDecodingContext *ctx, XLogReaderState *recor
{
XLogRecordBuffer buf;
TransactionId txid;
RmgrData rmgr;
RmgrData rmgr;
buf.origptr = ctx->reader->ReadRecPtr;
buf.endptr = ctx->reader->EndRecPtr;

View File

@@ -344,9 +344,9 @@ retry:
}
/*
* We don't allow to invoke more sync workers once we have reached the sync
* worker limit per subscription. So, just return silently as we might get
* here because of an otherwise harmless race condition.
* We don't allow to invoke more sync workers once we have reached the
* sync worker limit per subscription. So, just return silently as we
* might get here because of an otherwise harmless race condition.
*/
if (OidIsValid(relid) && nsyncworkers >= max_sync_workers_per_subscription)
{

View File

@@ -646,8 +646,8 @@ ReorderBufferTXNByXid(ReorderBuffer *rb, TransactionId xid, bool create,
}
/*
* If the cache wasn't hit or it yielded a "does-not-exist" and we want
* to create an entry.
* If the cache wasn't hit or it yielded a "does-not-exist" and we want to
* create an entry.
*/
/* search the lookup table */

View File

@@ -786,11 +786,11 @@ fetch_remote_table_info(char *nspname, char *relname,
/*
* Fetch info about column lists for the relation (from all the
* publications). We unnest the int2vector values, because that
* makes it easier to combine lists by simply adding the attnums
* to a new bitmap (without having to parse the int2vector data).
* This preserves NULL values, so that if one of the publications
* has no column list, we'll know that.
* publications). We unnest the int2vector values, because that makes
* it easier to combine lists by simply adding the attnums to a new
* bitmap (without having to parse the int2vector data). This
* preserves NULL values, so that if one of the publications has no
* column list, we'll know that.
*/
resetStringInfo(&cmd);
appendStringInfo(&cmd,
@@ -816,15 +816,15 @@ fetch_remote_table_info(char *nspname, char *relname,
nspname, relname, pubres->err)));
/*
* Merge the column lists (from different publications) by creating
* a single bitmap with all the attnums. If we find a NULL value,
* that means one of the publications has no column list for the
* table we're syncing.
* Merge the column lists (from different publications) by creating a
* single bitmap with all the attnums. If we find a NULL value, that
* means one of the publications has no column list for the table
* we're syncing.
*/
slot = MakeSingleTupleTableSlot(pubres->tupledesc, &TTSOpsMinimalTuple);
while (tuplestore_gettupleslot(pubres->tuplestore, true, false, slot))
{
Datum cfval = slot_getattr(slot, 1, &isnull);
Datum cfval = slot_getattr(slot, 1, &isnull);
/* NULL means empty column list, so we're done. */
if (isnull)
@@ -835,7 +835,7 @@ fetch_remote_table_info(char *nspname, char *relname,
}
included_cols = bms_add_member(included_cols,
DatumGetInt16(cfval));
DatumGetInt16(cfval));
ExecClearTuple(slot);
}
@@ -1056,8 +1056,8 @@ copy_table(Relation rel)
quote_qualified_identifier(lrel.nspname, lrel.relname));
/*
* XXX Do we need to list the columns in all cases? Maybe we're replicating
* all columns?
* XXX Do we need to list the columns in all cases? Maybe we're
* replicating all columns?
*/
for (int i = 0; i < lrel.natts; i++)
{
@@ -1321,10 +1321,10 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
/*
* COPY FROM does not honor RLS policies. That is not a problem for
* subscriptions owned by roles with BYPASSRLS privilege (or superuser, who
* has it implicitly), but other roles should not be able to circumvent
* RLS. Disallow logical replication into RLS enabled relations for such
* roles.
* subscriptions owned by roles with BYPASSRLS privilege (or superuser,
* who has it implicitly), but other roles should not be able to
* circumvent RLS. Disallow logical replication into RLS enabled
* relations for such roles.
*/
if (check_enable_rls(RelationGetRelid(rel), InvalidOid, false) == RLS_ENABLED)
ereport(ERROR,

View File

@@ -1608,8 +1608,8 @@ GetRelationIdentityOrPK(Relation rel)
static void
TargetPrivilegesCheck(Relation rel, AclMode mode)
{
Oid relid;
AclResult aclresult;
Oid relid;
AclResult aclresult;
relid = RelationGetRelid(rel);
aclresult = pg_class_aclcheck(relid, GetUserId(), mode);

View File

@@ -174,8 +174,8 @@ typedef struct RelationSyncEntry
Bitmapset *columns;
/*
* Private context to store additional data for this entry - state for
* the row filter expressions, column list, etc.
* Private context to store additional data for this entry - state for the
* row filter expressions, column list, etc.
*/
MemoryContext entry_cxt;
} RelationSyncEntry;
@@ -206,9 +206,8 @@ typedef struct RelationSyncEntry
*/
typedef struct PGOutputTxnData
{
bool sent_begin_txn; /* flag indicating whether BEGIN has
* been sent */
} PGOutputTxnData;
bool sent_begin_txn; /* flag indicating whether BEGIN has been sent */
} PGOutputTxnData;
/* Map used to remember which relation schemas we sent. */
static HTAB *RelationSyncCache = NULL;
@@ -511,9 +510,9 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
* using bandwidth on something with little/no use for logical replication.
*/
static void
pgoutput_begin_txn(LogicalDecodingContext * ctx, ReorderBufferTXN * txn)
pgoutput_begin_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
{
PGOutputTxnData *txndata = MemoryContextAllocZero(ctx->context,
PGOutputTxnData *txndata = MemoryContextAllocZero(ctx->context,
sizeof(PGOutputTxnData));
txn->output_plugin_private = txndata;
@@ -987,7 +986,8 @@ pgoutput_column_list_init(PGOutputData *data, List *publications,
*
* All the given publication-table mappings must be checked.
*
* Multiple publications might have multiple column lists for this relation.
* Multiple publications might have multiple column lists for this
* relation.
*
* FOR ALL TABLES and FOR ALL TABLES IN SCHEMA implies "don't use column
* list" so it takes precedence.
@@ -1005,8 +1005,9 @@ pgoutput_column_list_init(PGOutputData *data, List *publications,
bool pub_no_list = true;
/*
* If the publication is FOR ALL TABLES then it is treated the same as if
* there are no column lists (even if other publications have a list).
* If the publication is FOR ALL TABLES then it is treated the same as
* if there are no column lists (even if other publications have a
* list).
*/
if (!pub->alltables)
{
@@ -1014,8 +1015,8 @@ pgoutput_column_list_init(PGOutputData *data, List *publications,
* Check for the presence of a column list in this publication.
*
* Note: If we find no pg_publication_rel row, it's a publication
* defined for a whole schema, so it can't have a column list, just
* like a FOR ALL TABLES publication.
* defined for a whole schema, so it can't have a column list,
* just like a FOR ALL TABLES publication.
*/
cftuple = SearchSysCache2(PUBLICATIONRELMAP,
ObjectIdGetDatum(entry->publish_as_relid),
@@ -1221,9 +1222,9 @@ pgoutput_row_filter(Relation relation, TupleTableSlot *old_slot,
* For updates, we can have only a new tuple when none of the replica
* identity columns changed and none of those columns have external data
* but we still need to evaluate the row filter for the new tuple as the
* existing values of those columns might not match the filter. Also, users
* can use constant expressions in the row filter, so we anyway need to
* evaluate it for the new tuple.
* existing values of those columns might not match the filter. Also,
* users can use constant expressions in the row filter, so we anyway need
* to evaluate it for the new tuple.
*
* For deletes, we only have the old tuple.
*/
@@ -1674,8 +1675,7 @@ pgoutput_message(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
xid = txn->xid;
/*
* Output BEGIN if we haven't yet. Avoid for non-transactional
* messages.
* Output BEGIN if we haven't yet. Avoid for non-transactional messages.
*/
if (transactional)
{
@@ -2079,15 +2079,15 @@ get_rel_sync_entry(PGOutputData *data, Relation relation)
/*
* Under what relid should we publish changes in this publication?
* We'll use the top-most relid across all publications. Also track
* the ancestor level for this publication.
* We'll use the top-most relid across all publications. Also
* track the ancestor level for this publication.
*/
Oid pub_relid = relid;
int ancestor_level = 0;
Oid pub_relid = relid;
int ancestor_level = 0;
/*
* If this is a FOR ALL TABLES publication, pick the partition root
* and set the ancestor level accordingly.
* If this is a FOR ALL TABLES publication, pick the partition
* root and set the ancestor level accordingly.
*/
if (pub->alltables)
{
@@ -2156,18 +2156,18 @@ get_rel_sync_entry(PGOutputData *data, Relation relation)
/*
* We want to publish the changes as the top-most ancestor
* across all publications. So we need to check if the
* already calculated level is higher than the new one. If
* yes, we can ignore the new value (as it's a child).
* Otherwise the new value is an ancestor, so we keep it.
* across all publications. So we need to check if the already
* calculated level is higher than the new one. If yes, we can
* ignore the new value (as it's a child). Otherwise the new
* value is an ancestor, so we keep it.
*/
if (publish_ancestor_level > ancestor_level)
continue;
/*
* If we found an ancestor higher up in the tree, discard
* the list of publications through which we replicate it,
* and use the new ancestor.
* If we found an ancestor higher up in the tree, discard the
* list of publications through which we replicate it, and use
* the new ancestor.
*/
if (publish_ancestor_level < ancestor_level)
{

View File

@@ -504,8 +504,8 @@ retry:
MyReplicationSlot = s;
/*
* The call to pgstat_acquire_replslot() protects against stats for
* a different slot, from before a restart or such, being present during
* The call to pgstat_acquire_replslot() protects against stats for a
* different slot, from before a restart or such, being present during
* pgstat_report_replslot().
*/
if (SlotIsLogical(s))

View File

@@ -1406,9 +1406,9 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
if (!has_privs_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS))
{
/*
* Only superusers and roles with privileges of pg_read_all_stats
* can see details. Other users only get the pid value to know whether
* it is a WAL receiver, but no details.
* Only superusers and roles with privileges of pg_read_all_stats can
* see details. Other users only get the pid value to know whether it
* is a WAL receiver, but no details.
*/
MemSet(&nulls[1], true, sizeof(bool) * (tupdesc->natts - 1));
}

View File

@@ -1505,9 +1505,9 @@ WalSndUpdateProgress(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId
* When skipping empty transactions in synchronous replication, we send a
* keepalive message to avoid delaying such transactions.
*
* It is okay to check sync_standbys_defined flag without lock here as
* in the worst case we will just send an extra keepalive message when it
* is really not required.
* It is okay to check sync_standbys_defined flag without lock here as in
* the worst case we will just send an extra keepalive message when it is
* really not required.
*/
if (skipped_xact &&
SyncRepRequested() &&