mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +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:
@@ -54,7 +54,7 @@ struct fp_info
|
||||
Oid namespace; /* other stuff from pg_proc */
|
||||
Oid rettype;
|
||||
Oid argtypes[FUNC_MAX_ARGS];
|
||||
char fname[NAMEDATALEN]; /* function name for logging */
|
||||
char fname[NAMEDATALEN]; /* function name for logging */
|
||||
};
|
||||
|
||||
|
||||
@@ -293,7 +293,7 @@ HandleFunctionRequest(StringInfo msgBuf)
|
||||
if (PG_PROTOCOL_MAJOR(FrontendProtocol) < 3)
|
||||
(void) pq_getmsgstring(msgBuf); /* dummy string */
|
||||
|
||||
fid = (Oid) pq_getmsgint(msgBuf, 4); /* function oid */
|
||||
fid = (Oid) pq_getmsgint(msgBuf, 4); /* function oid */
|
||||
|
||||
/*
|
||||
* There used to be a lame attempt at caching lookup info here. Now we
|
||||
|
@@ -153,7 +153,7 @@ static CachedPlanSource *unnamed_stmt_psrc = NULL;
|
||||
/* assorted command-line switches */
|
||||
static const char *userDoption = NULL; /* -D switch */
|
||||
static bool EchoQuery = false; /* -E switch */
|
||||
static bool UseSemiNewlineNewline = false; /* -j switch */
|
||||
static bool UseSemiNewlineNewline = false; /* -j switch */
|
||||
|
||||
/* whether or not, and why, we were canceled by conflict with recovery */
|
||||
static bool RecoveryConflictPending = false;
|
||||
@@ -682,7 +682,7 @@ pg_analyze_and_rewrite_params(RawStmt *parsetree,
|
||||
Query *query;
|
||||
List *querytree_list;
|
||||
|
||||
Assert(query_string != NULL); /* required as of 8.4 */
|
||||
Assert(query_string != NULL); /* required as of 8.4 */
|
||||
|
||||
TRACE_POSTGRESQL_QUERY_REWRITE_START(query_string);
|
||||
|
||||
@@ -1193,9 +1193,9 @@ exec_simple_query(const char *query_string)
|
||||
*/
|
||||
static void
|
||||
exec_parse_message(const char *query_string, /* string to execute */
|
||||
const char *stmt_name, /* name for prepared stmt */
|
||||
Oid *paramTypes, /* parameter types */
|
||||
int numParams) /* number of parameters */
|
||||
const char *stmt_name, /* name for prepared stmt */
|
||||
Oid *paramTypes, /* parameter types */
|
||||
int numParams) /* number of parameters */
|
||||
{
|
||||
MemoryContext unnamed_stmt_context = NULL;
|
||||
MemoryContext oldcontext;
|
||||
@@ -1660,7 +1660,7 @@ exec_bind_message(StringInfo input_message)
|
||||
}
|
||||
else
|
||||
{
|
||||
pbuf.data = NULL; /* keep compiler quiet */
|
||||
pbuf.data = NULL; /* keep compiler quiet */
|
||||
csave = 0;
|
||||
}
|
||||
|
||||
@@ -1694,7 +1694,7 @@ exec_bind_message(StringInfo input_message)
|
||||
if (pstring && pstring != pbuf.data)
|
||||
pfree(pstring);
|
||||
}
|
||||
else if (pformat == 1) /* binary mode */
|
||||
else if (pformat == 1) /* binary mode */
|
||||
{
|
||||
Oid typreceive;
|
||||
Oid typioparam;
|
||||
@@ -2555,7 +2555,7 @@ drop_unnamed_stmt(void)
|
||||
void
|
||||
quickdie(SIGNAL_ARGS)
|
||||
{
|
||||
sigaddset(&BlockSig, SIGQUIT); /* prevent nested calls */
|
||||
sigaddset(&BlockSig, SIGQUIT); /* prevent nested calls */
|
||||
PG_SETMASK(&BlockSig);
|
||||
|
||||
/*
|
||||
@@ -2832,7 +2832,7 @@ ProcessInterrupts(void)
|
||||
if (ProcDiePending)
|
||||
{
|
||||
ProcDiePending = false;
|
||||
QueryCancelPending = false; /* ProcDie trumps QueryCancel */
|
||||
QueryCancelPending = false; /* ProcDie trumps QueryCancel */
|
||||
LockErrorCleanup();
|
||||
/* As in quickdie, don't risk sending to client during auth */
|
||||
if (ClientAuthInProgress && whereToSendOutput == DestRemote)
|
||||
@@ -2883,7 +2883,7 @@ ProcessInterrupts(void)
|
||||
}
|
||||
if (ClientConnectionLost)
|
||||
{
|
||||
QueryCancelPending = false; /* lost connection trumps QueryCancel */
|
||||
QueryCancelPending = false; /* lost connection trumps QueryCancel */
|
||||
LockErrorCleanup();
|
||||
/* don't send to client, we already know the connection to be dead. */
|
||||
whereToSendOutput = DestNone;
|
||||
@@ -2900,7 +2900,7 @@ ProcessInterrupts(void)
|
||||
*/
|
||||
if (RecoveryConflictPending && DoingCommandRead)
|
||||
{
|
||||
QueryCancelPending = false; /* this trumps QueryCancel */
|
||||
QueryCancelPending = false; /* this trumps QueryCancel */
|
||||
RecoveryConflictPending = false;
|
||||
LockErrorCleanup();
|
||||
pgstat_report_recovery_conflict(RecoveryConflictReason);
|
||||
@@ -2950,7 +2950,7 @@ ProcessInterrupts(void)
|
||||
*/
|
||||
if (lock_timeout_occurred && stmt_timeout_occurred &&
|
||||
get_timeout_finish_time(STATEMENT_TIMEOUT) < get_timeout_finish_time(LOCK_TIMEOUT))
|
||||
lock_timeout_occurred = false; /* report stmt timeout */
|
||||
lock_timeout_occurred = false; /* report stmt timeout */
|
||||
|
||||
if (lock_timeout_occurred)
|
||||
{
|
||||
@@ -3050,7 +3050,7 @@ ia64_get_bsp(void)
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#endif /* IA64 */
|
||||
#endif /* IA64 */
|
||||
|
||||
|
||||
/*
|
||||
@@ -3168,7 +3168,7 @@ stack_is_too_deep(void)
|
||||
if (stack_depth > max_stack_depth_bytes &&
|
||||
register_stack_base_ptr != NULL)
|
||||
return true;
|
||||
#endif /* IA64 */
|
||||
#endif /* IA64 */
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -3283,7 +3283,7 @@ get_stats_option_name(const char *arg)
|
||||
switch (arg[0])
|
||||
{
|
||||
case 'p':
|
||||
if (optarg[1] == 'a') /* "parser" */
|
||||
if (optarg[1] == 'a') /* "parser" */
|
||||
return "log_parser_stats";
|
||||
else if (optarg[1] == 'l') /* "planner" */
|
||||
return "log_planner_stats";
|
||||
@@ -3339,7 +3339,7 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx,
|
||||
}
|
||||
else
|
||||
{
|
||||
gucsource = PGC_S_CLIENT; /* switches came from client */
|
||||
gucsource = PGC_S_CLIENT; /* switches came from client */
|
||||
}
|
||||
|
||||
#ifdef HAVE_INT_OPTERR
|
||||
@@ -3640,9 +3640,9 @@ PostgresMain(int argc, char *argv[],
|
||||
WalSndSignals();
|
||||
else
|
||||
{
|
||||
pqsignal(SIGHUP, PostgresSigHupHandler); /* set flag to read
|
||||
* config file */
|
||||
pqsignal(SIGINT, StatementCancelHandler); /* cancel current query */
|
||||
pqsignal(SIGHUP, PostgresSigHupHandler); /* set flag to read config
|
||||
* file */
|
||||
pqsignal(SIGINT, StatementCancelHandler); /* cancel current query */
|
||||
pqsignal(SIGTERM, die); /* cancel current query and exit */
|
||||
|
||||
/*
|
||||
@@ -3651,9 +3651,9 @@ PostgresMain(int argc, char *argv[],
|
||||
* rather than quickdie().
|
||||
*/
|
||||
if (IsUnderPostmaster)
|
||||
pqsignal(SIGQUIT, quickdie); /* hard crash time */
|
||||
pqsignal(SIGQUIT, quickdie); /* hard crash time */
|
||||
else
|
||||
pqsignal(SIGQUIT, die); /* cancel current query and exit */
|
||||
pqsignal(SIGQUIT, die); /* cancel current query and exit */
|
||||
InitializeTimeouts(); /* establishes SIGALRM handler */
|
||||
|
||||
/*
|
||||
@@ -3671,8 +3671,8 @@ PostgresMain(int argc, char *argv[],
|
||||
* Reset some signals that are accepted by postmaster but not by
|
||||
* backend
|
||||
*/
|
||||
pqsignal(SIGCHLD, SIG_DFL); /* system() requires this on some
|
||||
* platforms */
|
||||
pqsignal(SIGCHLD, SIG_DFL); /* system() requires this on some
|
||||
* platforms */
|
||||
}
|
||||
|
||||
pqinitmask();
|
||||
@@ -3856,7 +3856,7 @@ PostgresMain(int argc, char *argv[],
|
||||
* forgetting a timeout cancel.
|
||||
*/
|
||||
disable_all_timeouts(false);
|
||||
QueryCancelPending = false; /* second to avoid race condition */
|
||||
QueryCancelPending = false; /* second to avoid race condition */
|
||||
|
||||
/* Not reading from the client anymore. */
|
||||
DoingCommandRead = false;
|
||||
@@ -4225,7 +4225,7 @@ PostgresMain(int argc, char *argv[],
|
||||
}
|
||||
|
||||
if (whereToSendOutput == DestRemote)
|
||||
pq_putemptymessage('3'); /* CloseComplete */
|
||||
pq_putemptymessage('3'); /* CloseComplete */
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -4468,7 +4468,7 @@ ShowUsage(const char *title)
|
||||
r.ru_nvcsw - Save_r.ru_nvcsw,
|
||||
r.ru_nivcsw - Save_r.ru_nivcsw,
|
||||
r.ru_nvcsw, r.ru_nivcsw);
|
||||
#endif /* HAVE_GETRUSAGE */
|
||||
#endif /* HAVE_GETRUSAGE */
|
||||
|
||||
/* remove trailing newline */
|
||||
if (str.data[str.len - 1] == '\n')
|
||||
|
@@ -76,7 +76,7 @@ CreateQueryDesc(PlannedStmt *plannedstmt,
|
||||
QueryDesc *qd = (QueryDesc *) palloc(sizeof(QueryDesc));
|
||||
|
||||
qd->operation = plannedstmt->commandType; /* operation */
|
||||
qd->plannedstmt = plannedstmt; /* plan */
|
||||
qd->plannedstmt = plannedstmt; /* plan */
|
||||
qd->sourceText = sourceText; /* query text */
|
||||
qd->snapshot = RegisterSnapshot(snapshot); /* snapshot */
|
||||
/* RI check snapshot */
|
||||
@@ -84,8 +84,7 @@ CreateQueryDesc(PlannedStmt *plannedstmt,
|
||||
qd->dest = dest; /* output dest */
|
||||
qd->params = params; /* parameter values passed into query */
|
||||
qd->queryEnv = queryEnv;
|
||||
qd->instrument_options = instrument_options; /* instrumentation
|
||||
* wanted? */
|
||||
qd->instrument_options = instrument_options; /* instrumentation wanted? */
|
||||
|
||||
/* null these fields until set by ExecutorStart */
|
||||
qd->tupDesc = NULL;
|
||||
@@ -939,7 +938,7 @@ PortalRunSelect(Portal portal,
|
||||
if (!ScanDirectionIsNoMovement(direction))
|
||||
{
|
||||
if (nprocessed > 0)
|
||||
portal->atStart = false; /* OK to go backward now */
|
||||
portal->atStart = false; /* OK to go backward now */
|
||||
if (count == 0 || nprocessed < (uint64) count)
|
||||
portal->atEnd = true; /* we retrieved 'em all */
|
||||
portal->portalPos += nprocessed;
|
||||
|
@@ -1183,7 +1183,7 @@ ProcessUtilitySlow(ParseState *pstate,
|
||||
*/
|
||||
switch (stmt->subtype)
|
||||
{
|
||||
case 'T': /* ALTER DOMAIN DEFAULT */
|
||||
case 'T': /* ALTER DOMAIN DEFAULT */
|
||||
|
||||
/*
|
||||
* Recursively alter column default for table and,
|
||||
@@ -1193,30 +1193,30 @@ ProcessUtilitySlow(ParseState *pstate,
|
||||
AlterDomainDefault(stmt->typeName,
|
||||
stmt->def);
|
||||
break;
|
||||
case 'N': /* ALTER DOMAIN DROP NOT NULL */
|
||||
case 'N': /* ALTER DOMAIN DROP NOT NULL */
|
||||
address =
|
||||
AlterDomainNotNull(stmt->typeName,
|
||||
false);
|
||||
break;
|
||||
case 'O': /* ALTER DOMAIN SET NOT NULL */
|
||||
case 'O': /* ALTER DOMAIN SET NOT NULL */
|
||||
address =
|
||||
AlterDomainNotNull(stmt->typeName,
|
||||
true);
|
||||
break;
|
||||
case 'C': /* ADD CONSTRAINT */
|
||||
case 'C': /* ADD CONSTRAINT */
|
||||
address =
|
||||
AlterDomainAddConstraint(stmt->typeName,
|
||||
stmt->def,
|
||||
&secondaryObject);
|
||||
break;
|
||||
case 'X': /* DROP CONSTRAINT */
|
||||
case 'X': /* DROP CONSTRAINT */
|
||||
address =
|
||||
AlterDomainDropConstraint(stmt->typeName,
|
||||
stmt->name,
|
||||
stmt->behavior,
|
||||
stmt->missing_ok);
|
||||
break;
|
||||
case 'V': /* VALIDATE CONSTRAINT */
|
||||
case 'V': /* VALIDATE CONSTRAINT */
|
||||
address =
|
||||
AlterDomainValidateConstraint(stmt->typeName,
|
||||
stmt->name);
|
||||
@@ -1324,14 +1324,14 @@ ProcessUtilitySlow(ParseState *pstate,
|
||||
/* ... and do it */
|
||||
EventTriggerAlterTableStart(parsetree);
|
||||
address =
|
||||
DefineIndex(relid, /* OID of heap relation */
|
||||
DefineIndex(relid, /* OID of heap relation */
|
||||
stmt,
|
||||
InvalidOid, /* no predefined OID */
|
||||
false, /* is_alter_table */
|
||||
true, /* check_rights */
|
||||
true, /* check_not_in_use */
|
||||
false, /* skip_build */
|
||||
false); /* quiet */
|
||||
false, /* is_alter_table */
|
||||
true, /* check_rights */
|
||||
true, /* check_not_in_use */
|
||||
false, /* skip_build */
|
||||
false); /* quiet */
|
||||
|
||||
/*
|
||||
* Add the CREATE INDEX node itself to stash right away;
|
||||
@@ -1403,15 +1403,15 @@ ProcessUtilitySlow(ParseState *pstate,
|
||||
}
|
||||
break;
|
||||
|
||||
case T_CreateEnumStmt: /* CREATE TYPE AS ENUM */
|
||||
case T_CreateEnumStmt: /* CREATE TYPE AS ENUM */
|
||||
address = DefineEnum((CreateEnumStmt *) parsetree);
|
||||
break;
|
||||
|
||||
case T_CreateRangeStmt: /* CREATE TYPE AS RANGE */
|
||||
case T_CreateRangeStmt: /* CREATE TYPE AS RANGE */
|
||||
address = DefineRange((CreateRangeStmt *) parsetree);
|
||||
break;
|
||||
|
||||
case T_AlterEnumStmt: /* ALTER TYPE (enum) */
|
||||
case T_AlterEnumStmt: /* ALTER TYPE (enum) */
|
||||
address = AlterEnum((AlterEnumStmt *) parsetree);
|
||||
break;
|
||||
|
||||
@@ -1594,7 +1594,7 @@ ProcessUtilitySlow(ParseState *pstate,
|
||||
address = CreatePolicy((CreatePolicyStmt *) parsetree);
|
||||
break;
|
||||
|
||||
case T_AlterPolicyStmt: /* ALTER POLICY */
|
||||
case T_AlterPolicyStmt: /* ALTER POLICY */
|
||||
address = AlterPolicy((AlterPolicyStmt *) parsetree);
|
||||
break;
|
||||
|
||||
@@ -1725,7 +1725,7 @@ UtilityReturnsTuples(Node *parsetree)
|
||||
return false;
|
||||
portal = GetPortalByName(stmt->portalname);
|
||||
if (!PortalIsValid(portal))
|
||||
return false; /* not our business to raise error */
|
||||
return false; /* not our business to raise error */
|
||||
return portal->tupDesc ? true : false;
|
||||
}
|
||||
|
||||
@@ -1736,7 +1736,7 @@ UtilityReturnsTuples(Node *parsetree)
|
||||
|
||||
entry = FetchPreparedStatement(stmt->name, false);
|
||||
if (!entry)
|
||||
return false; /* not our business to raise error */
|
||||
return false; /* not our business to raise error */
|
||||
if (entry->plansource->resultDesc)
|
||||
return true;
|
||||
return false;
|
||||
@@ -2887,7 +2887,7 @@ GetCommandLogLevel(Node *parsetree)
|
||||
|
||||
case T_SelectStmt:
|
||||
if (((SelectStmt *) parsetree)->intoClause)
|
||||
lev = LOGSTMT_DDL; /* SELECT INTO */
|
||||
lev = LOGSTMT_DDL; /* SELECT INTO */
|
||||
else
|
||||
lev = LOGSTMT_ALL;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user