mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Phase 2 of pgindent updates.
Change pg_bsd_indent to follow upstream rules for placement of comments
to the right of code, and remove pgindent hack that caused comments
following #endif to not obey the general rule.
Commit e3860ffa4d wasn't actually using
the published version of pg_bsd_indent, but a hacked-up version that
tried to minimize the amount of movement of comments to the right of
code. The situation of interest is where such a comment has to be
moved to the right of its default placement at column 33 because there's
code there. BSD indent has always moved right in units of tab stops
in such cases --- but in the previous incarnation, indent was working
in 8-space tab stops, while now it knows we use 4-space tabs. So the
net result is that in about half the cases, such comments are placed
one tab stop left of before. This is better all around: it leaves
more room on the line for comment text, and it means that in such
cases the comment uniformly starts at the next 4-space tab stop after
the code, rather than sometimes one and sometimes two tabs after.
Also, ensure that comments following #endif are indented the same
as comments following other preprocessor commands such as #else.
That inconsistency turns out to have been self-inflicted damage
from a poorly-thought-through post-indent "fixup" in pgindent.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "access/xlog_internal.h" /* for pg_start/stop_backup */
|
||||
#include "access/xlog_internal.h" /* for pg_start/stop_backup */
|
||||
#include "catalog/catalog.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "lib/stringinfo.h"
|
||||
@@ -273,8 +273,8 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
|
||||
|
||||
/* Send CopyOutResponse message */
|
||||
pq_beginmessage(&buf, 'H');
|
||||
pq_sendbyte(&buf, 0); /* overall format */
|
||||
pq_sendint(&buf, 0, 2); /* natts */
|
||||
pq_sendbyte(&buf, 0); /* overall format */
|
||||
pq_sendint(&buf, 0, 2); /* natts */
|
||||
pq_endmessage(&buf);
|
||||
|
||||
if (ti->path == NULL)
|
||||
@@ -318,7 +318,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
|
||||
Assert(lnext(lc) == NULL);
|
||||
}
|
||||
else
|
||||
pq_putemptymessage('c'); /* CopyDone */
|
||||
pq_putemptymessage('c'); /* CopyDone */
|
||||
}
|
||||
}
|
||||
PG_END_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0);
|
||||
@@ -814,7 +814,7 @@ SendXlogRecPtrResult(XLogRecPtr ptr, TimeLineID tli)
|
||||
pq_sendstring(&buf, "recptr");
|
||||
pq_sendint(&buf, 0, 4); /* table oid */
|
||||
pq_sendint(&buf, 0, 2); /* attnum */
|
||||
pq_sendint(&buf, TEXTOID, 4); /* type oid */
|
||||
pq_sendint(&buf, TEXTOID, 4); /* type oid */
|
||||
pq_sendint(&buf, -1, 2);
|
||||
pq_sendint(&buf, 0, 4);
|
||||
pq_sendint(&buf, 0, 2);
|
||||
@@ -827,7 +827,7 @@ SendXlogRecPtrResult(XLogRecPtr ptr, TimeLineID tli)
|
||||
* int8 may seem like a surprising data type for this, but in theory int4
|
||||
* would not be wide enough for this, as TimeLineID is unsigned.
|
||||
*/
|
||||
pq_sendint(&buf, INT8OID, 4); /* type oid */
|
||||
pq_sendint(&buf, INT8OID, 4); /* type oid */
|
||||
pq_sendint(&buf, -1, 2);
|
||||
pq_sendint(&buf, 0, 4);
|
||||
pq_sendint(&buf, 0, 2);
|
||||
@@ -1115,7 +1115,7 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("tablespaces are not supported on this platform")));
|
||||
continue;
|
||||
#endif /* HAVE_READLINK */
|
||||
#endif /* HAVE_READLINK */
|
||||
}
|
||||
else if (S_ISDIR(statbuf.st_mode))
|
||||
{
|
||||
|
||||
@@ -451,7 +451,7 @@ DecodingContextFindStartpoint(LogicalDecodingContext *ctx)
|
||||
if (err)
|
||||
elog(ERROR, "%s", err);
|
||||
if (!record)
|
||||
elog(ERROR, "no record found"); /* shouldn't happen */
|
||||
elog(ERROR, "no record found"); /* shouldn't happen */
|
||||
|
||||
startptr = InvalidXLogRecPtr;
|
||||
|
||||
@@ -661,7 +661,7 @@ commit_cb_wrapper(ReorderBuffer *cache, ReorderBufferTXN *txn,
|
||||
/* Push callback + info on the error context stack */
|
||||
state.ctx = ctx;
|
||||
state.callback_name = "commit";
|
||||
state.report_location = txn->final_lsn; /* beginning of commit record */
|
||||
state.report_location = txn->final_lsn; /* beginning of commit record */
|
||||
errcallback.callback = output_plugin_error_callback;
|
||||
errcallback.arg = (void *) &state;
|
||||
errcallback.previous = error_context_stack;
|
||||
|
||||
@@ -147,7 +147,7 @@ typedef struct ReplicationStateCtl
|
||||
} ReplicationStateCtl;
|
||||
|
||||
/* external variables */
|
||||
RepOriginId replorigin_session_origin = InvalidRepOriginId; /* assumed identity */
|
||||
RepOriginId replorigin_session_origin = InvalidRepOriginId; /* assumed identity */
|
||||
XLogRecPtr replorigin_session_origin_lsn = InvalidXLogRecPtr;
|
||||
TimestampTz replorigin_session_origin_timestamp = 0;
|
||||
|
||||
|
||||
@@ -194,9 +194,9 @@ logicalrep_write_update(StringInfo out, Relation rel, HeapTuple oldtuple,
|
||||
if (oldtuple != NULL)
|
||||
{
|
||||
if (rel->rd_rel->relreplident == REPLICA_IDENTITY_FULL)
|
||||
pq_sendbyte(out, 'O'); /* old tuple follows */
|
||||
pq_sendbyte(out, 'O'); /* old tuple follows */
|
||||
else
|
||||
pq_sendbyte(out, 'K'); /* old key follows */
|
||||
pq_sendbyte(out, 'K'); /* old key follows */
|
||||
logicalrep_write_tuple(out, rel, oldtuple);
|
||||
}
|
||||
|
||||
@@ -424,12 +424,12 @@ logicalrep_write_tuple(StringInfo out, Relation rel, HeapTuple tuple)
|
||||
|
||||
if (isnull[i])
|
||||
{
|
||||
pq_sendbyte(out, 'n'); /* null column */
|
||||
pq_sendbyte(out, 'n'); /* null column */
|
||||
continue;
|
||||
}
|
||||
else if (att->attlen == -1 && VARATT_IS_EXTERNAL_ONDISK(values[i]))
|
||||
{
|
||||
pq_sendbyte(out, 'u'); /* unchanged toast column */
|
||||
pq_sendbyte(out, 'u'); /* unchanged toast column */
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
#include "replication/logical.h"
|
||||
#include "replication/reorderbuffer.h"
|
||||
#include "replication/slot.h"
|
||||
#include "replication/snapbuild.h" /* just for SnapBuildSnapDecRefcount */
|
||||
#include "replication/snapbuild.h" /* just for SnapBuildSnapDecRefcount */
|
||||
#include "storage/bufmgr.h"
|
||||
#include "storage/fd.h"
|
||||
#include "storage/sinval.h"
|
||||
@@ -124,8 +124,8 @@ typedef struct ReorderBufferToastEnt
|
||||
Size num_chunks; /* number of chunks we've already seen */
|
||||
Size size; /* combined size of chunks seen */
|
||||
dlist_head chunks; /* linked list of chunks */
|
||||
struct varlena *reconstructed; /* reconstructed varlena now pointed
|
||||
* to in main tup */
|
||||
struct varlena *reconstructed; /* reconstructed varlena now pointed to in
|
||||
* main tup */
|
||||
} ReorderBufferToastEnt;
|
||||
|
||||
/* Disk serialization support datastructures */
|
||||
@@ -157,7 +157,7 @@ static const Size max_changes_in_memory = 4096;
|
||||
* major bottleneck, especially when spilling to disk while decoding batch
|
||||
* workloads.
|
||||
*/
|
||||
static const Size max_cached_tuplebufs = 4096 * 2; /* ~8MB */
|
||||
static const Size max_cached_tuplebufs = 4096 * 2; /* ~8MB */
|
||||
|
||||
/* ---------------------------------------
|
||||
* primary reorderbuffer support routines
|
||||
|
||||
@@ -210,7 +210,7 @@ struct SnapBuild
|
||||
TransactionId was_xmax;
|
||||
|
||||
size_t was_xcnt; /* number of used xip entries */
|
||||
size_t was_xcnt_space; /* allocated size of xip */
|
||||
size_t was_xcnt_space; /* allocated size of xip */
|
||||
TransactionId *was_xip; /* running xacts array, xidComparator-sorted */
|
||||
} was_running;
|
||||
|
||||
@@ -336,7 +336,7 @@ AllocateSnapshotBuilder(ReorderBuffer *reorder,
|
||||
/* Other struct members initialized by zeroing via palloc0 above */
|
||||
|
||||
builder->committed.xcnt = 0;
|
||||
builder->committed.xcnt_space = 128; /* arbitrary number */
|
||||
builder->committed.xcnt_space = 128; /* arbitrary number */
|
||||
builder->committed.xip =
|
||||
palloc0(builder->committed.xcnt_space * sizeof(TransactionId));
|
||||
builder->committed.includes_all_transactions = true;
|
||||
@@ -1248,8 +1248,8 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn
|
||||
builder->start_decoding_at = lsn + 1;
|
||||
|
||||
/* As no transactions were running xmin/xmax can be trivially set. */
|
||||
builder->xmin = running->nextXid; /* < are finished */
|
||||
builder->xmax = running->nextXid; /* >= are running */
|
||||
builder->xmin = running->nextXid; /* < are finished */
|
||||
builder->xmax = running->nextXid; /* >= are running */
|
||||
|
||||
/* so we can safely use the faster comparisons */
|
||||
Assert(TransactionIdIsNormal(builder->xmin));
|
||||
@@ -1295,8 +1295,8 @@ SnapBuildFindSnapshot(SnapBuild *builder, XLogRecPtr lsn, xl_running_xacts *runn
|
||||
* currently running transactions have finished. We'll update both
|
||||
* while waiting for the pending transactions to finish.
|
||||
*/
|
||||
builder->xmin = running->nextXid; /* < are finished */
|
||||
builder->xmax = running->nextXid; /* >= are running */
|
||||
builder->xmin = running->nextXid; /* < are finished */
|
||||
builder->xmax = running->nextXid; /* >= are running */
|
||||
|
||||
/* so we can safely use the faster comparisons */
|
||||
Assert(TransactionIdIsNormal(builder->xmin));
|
||||
|
||||
@@ -812,7 +812,7 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
|
||||
* NAMEDATALEN on the remote that matters, but this scheme will also work
|
||||
* reasonably if that is different.)
|
||||
*/
|
||||
StaticAssertStmt(NAMEDATALEN >= 32, "NAMEDATALEN too small"); /* for sanity */
|
||||
StaticAssertStmt(NAMEDATALEN >= 32, "NAMEDATALEN too small"); /* for sanity */
|
||||
slotname = psprintf("%.*s_%u_sync_%u",
|
||||
NAMEDATALEN - 28,
|
||||
MySubscription->slotname,
|
||||
|
||||
@@ -1290,9 +1290,9 @@ send_feedback(XLogRecPtr recvpos, bool force, bool requestReply)
|
||||
resetStringInfo(reply_message);
|
||||
|
||||
pq_sendbyte(reply_message, 'r');
|
||||
pq_sendint64(reply_message, recvpos); /* write */
|
||||
pq_sendint64(reply_message, flushpos); /* flush */
|
||||
pq_sendint64(reply_message, writepos); /* apply */
|
||||
pq_sendint64(reply_message, recvpos); /* write */
|
||||
pq_sendint64(reply_message, flushpos); /* flush */
|
||||
pq_sendint64(reply_message, writepos); /* apply */
|
||||
pq_sendint64(reply_message, now); /* sendTime */
|
||||
pq_sendbyte(reply_message, requestReply); /* replyRequested */
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ typedef struct ReplicationSlotOnDisk
|
||||
#define ReplicationSlotOnDiskV2Size \
|
||||
sizeof(ReplicationSlotOnDisk) - ReplicationSlotOnDiskConstantSize
|
||||
|
||||
#define SLOT_MAGIC 0x1051CA1 /* format identifier */
|
||||
#define SLOT_MAGIC 0x1051CA1 /* format identifier */
|
||||
#define SLOT_VERSION 2 /* version for new files */
|
||||
|
||||
/* Control array for replication slot management */
|
||||
|
||||
@@ -132,7 +132,7 @@ pg_create_logical_replication_slot(PG_FUNCTION_ARGS)
|
||||
* Create logical decoding context, to build the initial snapshot.
|
||||
*/
|
||||
ctx = CreateInitDecodingContext(NameStr(*plugin), NIL,
|
||||
false, /* do not build snapshot */
|
||||
false, /* do not build snapshot */
|
||||
logical_read_local_xlog_page, NULL, NULL,
|
||||
NULL);
|
||||
|
||||
|
||||
@@ -888,7 +888,7 @@ SyncRepGetSyncStandbysPriority(bool *am_sync)
|
||||
if (list_length(result) == SyncRepConfig->num_sync)
|
||||
{
|
||||
list_free(pending);
|
||||
return result; /* Exit if got enough sync standbys */
|
||||
return result; /* Exit if got enough sync standbys */
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -259,8 +259,7 @@ WalReceiverMain(void)
|
||||
walrcv->latch = &MyProc->procLatch;
|
||||
|
||||
/* Properly accept or ignore signals the postmaster might send us */
|
||||
pqsignal(SIGHUP, WalRcvSigHupHandler); /* set flag to read config
|
||||
* file */
|
||||
pqsignal(SIGHUP, WalRcvSigHupHandler); /* set flag to read config file */
|
||||
pqsignal(SIGINT, SIG_IGN);
|
||||
pqsignal(SIGTERM, WalRcvShutdownHandler); /* request shutdown */
|
||||
pqsignal(SIGQUIT, WalRcvQuickDieHandler); /* hard crash time */
|
||||
|
||||
@@ -111,16 +111,16 @@ WalSndCtlData *WalSndCtl = NULL;
|
||||
WalSnd *MyWalSnd = NULL;
|
||||
|
||||
/* Global state */
|
||||
bool am_walsender = false; /* Am I a walsender process? */
|
||||
bool am_cascading_walsender = false; /* Am I cascading WAL to
|
||||
* another standby? */
|
||||
bool am_walsender = false; /* Am I a walsender process? */
|
||||
bool am_cascading_walsender = false; /* Am I cascading WAL to another
|
||||
* standby? */
|
||||
bool am_db_walsender = false; /* Connected to a database? */
|
||||
|
||||
/* User-settable parameters for walsender */
|
||||
int max_wal_senders = 0; /* the maximum number of concurrent
|
||||
* walsenders */
|
||||
int wal_sender_timeout = 60 * 1000; /* maximum time to send one
|
||||
* WAL data message */
|
||||
int wal_sender_timeout = 60 * 1000; /* maximum time to send one WAL
|
||||
* data message */
|
||||
bool log_replication_commands = false;
|
||||
|
||||
/*
|
||||
@@ -450,16 +450,16 @@ SendTimeLineHistory(TimeLineHistoryCmd *cmd)
|
||||
pq_sendstring(&buf, "filename"); /* col name */
|
||||
pq_sendint(&buf, 0, 4); /* table oid */
|
||||
pq_sendint(&buf, 0, 2); /* attnum */
|
||||
pq_sendint(&buf, TEXTOID, 4); /* type oid */
|
||||
pq_sendint(&buf, TEXTOID, 4); /* type oid */
|
||||
pq_sendint(&buf, -1, 2); /* typlen */
|
||||
pq_sendint(&buf, 0, 4); /* typmod */
|
||||
pq_sendint(&buf, 0, 2); /* format code */
|
||||
|
||||
/* second field */
|
||||
pq_sendstring(&buf, "content"); /* col name */
|
||||
pq_sendstring(&buf, "content"); /* col name */
|
||||
pq_sendint(&buf, 0, 4); /* table oid */
|
||||
pq_sendint(&buf, 0, 2); /* attnum */
|
||||
pq_sendint(&buf, BYTEAOID, 4); /* type oid */
|
||||
pq_sendint(&buf, BYTEAOID, 4); /* type oid */
|
||||
pq_sendint(&buf, -1, 2); /* typlen */
|
||||
pq_sendint(&buf, 0, 4); /* typmod */
|
||||
pq_sendint(&buf, 0, 2); /* format code */
|
||||
@@ -1748,7 +1748,7 @@ ProcessStandbyReplyMessage(void)
|
||||
writePtr = pq_getmsgint64(&reply_message);
|
||||
flushPtr = pq_getmsgint64(&reply_message);
|
||||
applyPtr = pq_getmsgint64(&reply_message);
|
||||
(void) pq_getmsgint64(&reply_message); /* sendTime; not used ATM */
|
||||
(void) pq_getmsgint64(&reply_message); /* sendTime; not used ATM */
|
||||
replyRequested = pq_getmsgbyte(&reply_message);
|
||||
|
||||
elog(DEBUG2, "write %X/%X flush %X/%X apply %X/%X%s",
|
||||
@@ -1911,7 +1911,7 @@ ProcessStandbyHSFeedbackMessage(void)
|
||||
* byte. See XLogWalRcvSendHSFeedback() in walreceiver.c for the creation
|
||||
* of this message.
|
||||
*/
|
||||
(void) pq_getmsgint64(&reply_message); /* sendTime; not used ATM */
|
||||
(void) pq_getmsgint64(&reply_message); /* sendTime; not used ATM */
|
||||
feedbackXmin = pq_getmsgint(&reply_message, 4);
|
||||
feedbackEpoch = pq_getmsgint(&reply_message, 4);
|
||||
feedbackCatalogXmin = pq_getmsgint(&reply_message, 4);
|
||||
@@ -1978,7 +1978,7 @@ ProcessStandbyHSFeedbackMessage(void)
|
||||
* XXX: It might make sense to generalize the ephemeral slot concept and
|
||||
* always use the slot mechanism to handle the feedback xmin.
|
||||
*/
|
||||
if (MyReplicationSlot != NULL) /* XXX: persistency configurable? */
|
||||
if (MyReplicationSlot != NULL) /* XXX: persistency configurable? */
|
||||
PhysicalReplicationSlotNewXmin(feedbackXmin, feedbackCatalogXmin);
|
||||
else
|
||||
{
|
||||
@@ -2000,7 +2000,7 @@ ProcessStandbyHSFeedbackMessage(void)
|
||||
static long
|
||||
WalSndComputeSleeptime(TimestampTz now)
|
||||
{
|
||||
long sleeptime = 10000; /* 10 s */
|
||||
long sleeptime = 10000; /* 10 s */
|
||||
|
||||
if (wal_sender_timeout > 0 && last_reply_timestamp > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user