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:
@@ -43,4 +43,4 @@ extern void applyLockingClause(Query *qry, Index rtindex,
|
||||
LockClauseStrength strength,
|
||||
LockWaitPolicy waitPolicy, bool pushedDown);
|
||||
|
||||
#endif /* ANALYZE_H */
|
||||
#endif /* ANALYZE_H */
|
||||
|
@@ -44,8 +44,8 @@ typedef struct base_yy_extra_type
|
||||
*/
|
||||
bool have_lookahead; /* is lookahead info valid? */
|
||||
int lookahead_token; /* one-token lookahead */
|
||||
core_YYSTYPE lookahead_yylval; /* yylval for lookahead token */
|
||||
YYLTYPE lookahead_yylloc; /* yylloc for lookahead token */
|
||||
core_YYSTYPE lookahead_yylval; /* yylval for lookahead token */
|
||||
YYLTYPE lookahead_yylloc; /* yylloc for lookahead token */
|
||||
char *lookahead_end; /* end of current token */
|
||||
char lookahead_hold_char; /* to be put back at *lookahead_end */
|
||||
|
||||
@@ -72,4 +72,4 @@ extern int base_yylex(YYSTYPE *lvalp, YYLTYPE *llocp,
|
||||
extern void parser_init(base_yy_extra_type *yyext);
|
||||
extern int base_yyparse(core_yyscan_t yyscanner);
|
||||
|
||||
#endif /* GRAMPARSE_H */
|
||||
#endif /* GRAMPARSE_H */
|
||||
|
@@ -65,4 +65,4 @@ extern void build_aggregate_finalfn_expr(Oid *agg_input_types,
|
||||
Oid finalfn_oid,
|
||||
Expr **finalfnexpr);
|
||||
|
||||
#endif /* PARSE_AGG_H */
|
||||
#endif /* PARSE_AGG_H */
|
||||
|
@@ -51,4 +51,4 @@ extern List *addTargetToSortList(ParseState *pstate, TargetEntry *tle,
|
||||
extern Index assignSortGroupRef(TargetEntry *tle, List *tlist);
|
||||
extern bool targetIsInSortList(TargetEntry *tle, Oid sortop, List *sortList);
|
||||
|
||||
#endif /* PARSE_CLAUSE_H */
|
||||
#endif /* PARSE_CLAUSE_H */
|
||||
|
@@ -91,4 +91,4 @@ extern CoercionPathType find_coercion_pathway(Oid targetTypeId,
|
||||
extern CoercionPathType find_typmod_coercion_function(Oid typeId,
|
||||
Oid *funcid);
|
||||
|
||||
#endif /* PARSE_COERCE_H */
|
||||
#endif /* PARSE_COERCE_H */
|
||||
|
@@ -24,4 +24,4 @@ extern void assign_expr_collations(ParseState *pstate, Node *expr);
|
||||
|
||||
extern Oid select_common_collation(ParseState *pstate, List *exprs, bool none_ok);
|
||||
|
||||
#endif /* PARSE_COLLATE_H */
|
||||
#endif /* PARSE_COLLATE_H */
|
||||
|
@@ -21,4 +21,4 @@ extern List *transformWithClause(ParseState *pstate, WithClause *withClause);
|
||||
extern void analyzeCTETargetList(ParseState *pstate, CommonTableExpr *cte,
|
||||
List *tlist);
|
||||
|
||||
#endif /* PARSE_CTE_H */
|
||||
#endif /* PARSE_CTE_H */
|
||||
|
@@ -19,4 +19,4 @@
|
||||
extern bool name_matches_visible_ENR(ParseState *pstate, const char *refname);
|
||||
extern EphemeralNamedRelationMetadata get_visible_ENR(ParseState *pstate, const char *refname);
|
||||
|
||||
#endif /* PARSE_ENR_H */
|
||||
#endif /* PARSE_ENR_H */
|
||||
|
@@ -23,4 +23,4 @@ extern Node *transformExpr(ParseState *pstate, Node *expr, ParseExprKind exprKin
|
||||
|
||||
extern const char *ParseExprKindName(ParseExprKind exprKind);
|
||||
|
||||
#endif /* PARSE_EXPR_H */
|
||||
#endif /* PARSE_EXPR_H */
|
||||
|
@@ -70,4 +70,4 @@ extern Oid LookupAggWithArgs(ObjectWithArgs *agg,
|
||||
extern void check_srf_call_placement(ParseState *pstate, Node *last_srf,
|
||||
int location);
|
||||
|
||||
#endif /* PARSE_FUNC_H */
|
||||
#endif /* PARSE_FUNC_H */
|
||||
|
@@ -43,7 +43,7 @@ typedef enum ParseExprKind
|
||||
EXPR_KIND_FILTER, /* FILTER */
|
||||
EXPR_KIND_WINDOW_PARTITION, /* window definition PARTITION BY */
|
||||
EXPR_KIND_WINDOW_ORDER, /* window definition ORDER BY */
|
||||
EXPR_KIND_WINDOW_FRAME_RANGE, /* window frame clause with RANGE */
|
||||
EXPR_KIND_WINDOW_FRAME_RANGE, /* window frame clause with RANGE */
|
||||
EXPR_KIND_WINDOW_FRAME_ROWS, /* window frame clause with ROWS */
|
||||
EXPR_KIND_SELECT_TARGET, /* SELECT target list item */
|
||||
EXPR_KIND_INSERT_TARGET, /* INSERT target list item */
|
||||
@@ -63,11 +63,11 @@ typedef enum ParseExprKind
|
||||
EXPR_KIND_FUNCTION_DEFAULT, /* default parameter value for function */
|
||||
EXPR_KIND_INDEX_EXPRESSION, /* index expression */
|
||||
EXPR_KIND_INDEX_PREDICATE, /* index predicate */
|
||||
EXPR_KIND_ALTER_COL_TRANSFORM, /* transform expr in ALTER COLUMN TYPE */
|
||||
EXPR_KIND_ALTER_COL_TRANSFORM, /* transform expr in ALTER COLUMN TYPE */
|
||||
EXPR_KIND_EXECUTE_PARAMETER, /* parameter value in EXECUTE */
|
||||
EXPR_KIND_TRIGGER_WHEN, /* WHEN condition in CREATE TRIGGER */
|
||||
EXPR_KIND_POLICY, /* USING or WITH CHECK expr in policy */
|
||||
EXPR_KIND_PARTITION_EXPRESSION /* PARTITION BY expression */
|
||||
EXPR_KIND_PARTITION_EXPRESSION /* PARTITION BY expression */
|
||||
} ParseExprKind;
|
||||
|
||||
|
||||
@@ -167,7 +167,7 @@ typedef Node *(*CoerceParamHook) (ParseState *pstate, Param *param,
|
||||
*/
|
||||
struct ParseState
|
||||
{
|
||||
struct ParseState *parentParseState; /* stack link */
|
||||
struct ParseState *parentParseState; /* stack link */
|
||||
const char *p_sourcetext; /* source text, or NULL if not available */
|
||||
List *p_rtable; /* range table so far */
|
||||
List *p_joinexprs; /* JoinExprs for RTE_JOIN p_rtable entries */
|
||||
@@ -175,25 +175,24 @@ struct ParseState
|
||||
* node's fromlist) */
|
||||
List *p_namespace; /* currently-referenceable RTEs (List of
|
||||
* ParseNamespaceItem) */
|
||||
bool p_lateral_active; /* p_lateral_only items visible? */
|
||||
bool p_lateral_active; /* p_lateral_only items visible? */
|
||||
List *p_ctenamespace; /* current namespace for common table exprs */
|
||||
List *p_future_ctes; /* common table exprs not yet in namespace */
|
||||
CommonTableExpr *p_parent_cte; /* this query's containing CTE */
|
||||
Relation p_target_relation; /* INSERT/UPDATE/DELETE target rel */
|
||||
RangeTblEntry *p_target_rangetblentry; /* target rel's RTE */
|
||||
CommonTableExpr *p_parent_cte; /* this query's containing CTE */
|
||||
Relation p_target_relation; /* INSERT/UPDATE/DELETE target rel */
|
||||
RangeTblEntry *p_target_rangetblentry; /* target rel's RTE */
|
||||
bool p_is_insert; /* process assignment like INSERT not UPDATE */
|
||||
List *p_windowdefs; /* raw representations of window clauses */
|
||||
ParseExprKind p_expr_kind; /* what kind of expression we're parsing */
|
||||
int p_next_resno; /* next targetlist resno to assign */
|
||||
List *p_multiassign_exprs; /* junk tlist entries for multiassign */
|
||||
List *p_locking_clause; /* raw FOR UPDATE/FOR SHARE info */
|
||||
List *p_locking_clause; /* raw FOR UPDATE/FOR SHARE info */
|
||||
bool p_locked_from_parent; /* parent has marked this subquery
|
||||
* with FOR UPDATE/FOR SHARE */
|
||||
bool p_resolve_unknowns; /* resolve unknown-type SELECT outputs
|
||||
* as type text */
|
||||
bool p_resolve_unknowns; /* resolve unknown-type SELECT outputs as
|
||||
* type text */
|
||||
|
||||
QueryEnvironment *p_queryEnv; /* curr env, incl refs to enclosing
|
||||
* env */
|
||||
QueryEnvironment *p_queryEnv; /* curr env, incl refs to enclosing env */
|
||||
|
||||
/* Flags telling about things found in the query: */
|
||||
bool p_hasAggs;
|
||||
@@ -212,7 +211,7 @@ struct ParseState
|
||||
PostParseColumnRefHook p_post_columnref_hook;
|
||||
ParseParamRefHook p_paramref_hook;
|
||||
CoerceParamHook p_coerce_param_hook;
|
||||
void *p_ref_hook_state; /* common passthrough link for above */
|
||||
void *p_ref_hook_state; /* common passthrough link for above */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -280,4 +279,4 @@ extern ArrayRef *transformArraySubscripts(ParseState *pstate,
|
||||
Node *assignFrom);
|
||||
extern Const *make_const(ParseState *pstate, Value *value, int location);
|
||||
|
||||
#endif /* PARSE_NODE_H */
|
||||
#endif /* PARSE_NODE_H */
|
||||
|
@@ -64,4 +64,4 @@ extern Expr *make_scalar_array_op(ParseState *pstate, List *opname,
|
||||
bool useOr,
|
||||
Node *ltree, Node *rtree, int location);
|
||||
|
||||
#endif /* PARSE_OPER_H */
|
||||
#endif /* PARSE_OPER_H */
|
||||
|
@@ -22,4 +22,4 @@ extern void parse_variable_parameters(ParseState *pstate,
|
||||
extern void check_variable_parameters(ParseState *pstate, Query *query);
|
||||
extern bool query_contains_extern_params(Query *query);
|
||||
|
||||
#endif /* PARSE_PARAM_H */
|
||||
#endif /* PARSE_PARAM_H */
|
||||
|
@@ -129,4 +129,4 @@ extern Oid attnumTypeId(Relation rd, int attid);
|
||||
extern Oid attnumCollationId(Relation rd, int attid);
|
||||
extern bool isQueryUsingTempRelation(Query *query);
|
||||
|
||||
#endif /* PARSE_RELATION_H */
|
||||
#endif /* PARSE_RELATION_H */
|
||||
|
@@ -43,4 +43,4 @@ extern TupleDesc expandRecordVariable(ParseState *pstate, Var *var,
|
||||
extern char *FigureColname(Node *node);
|
||||
extern char *FigureIndexColname(Node *node);
|
||||
|
||||
#endif /* PARSE_TARGET_H */
|
||||
#endif /* PARSE_TARGET_H */
|
||||
|
@@ -52,4 +52,4 @@ extern void parseTypeString(const char *str, Oid *typeid_p, int32 *typmod_p, boo
|
||||
|
||||
#define ISCOMPLEX(typeid) (typeidTypeRelid(typeid) != InvalidOid)
|
||||
|
||||
#endif /* PARSE_TYPE_H */
|
||||
#endif /* PARSE_TYPE_H */
|
||||
|
@@ -28,4 +28,4 @@ extern List *transformCreateSchemaStmt(CreateSchemaStmt *stmt);
|
||||
extern PartitionBoundSpec *transformPartitionBound(ParseState *pstate, Relation parent,
|
||||
PartitionBoundSpec *spec);
|
||||
|
||||
#endif /* PARSE_UTILCMD_H */
|
||||
#endif /* PARSE_UTILCMD_H */
|
||||
|
@@ -38,4 +38,4 @@ extern List *raw_parser(const char *str);
|
||||
extern List *SystemFuncName(char *name);
|
||||
extern TypeName *SystemTypeName(char *name);
|
||||
|
||||
#endif /* PARSER_H */
|
||||
#endif /* PARSER_H */
|
||||
|
@@ -76,4 +76,4 @@ extern TargetEntry *get_tle_by_resno(List *tlist, AttrNumber resno);
|
||||
|
||||
extern RowMarkClause *get_parse_rowmark(Query *qry, Index rtindex);
|
||||
|
||||
#endif /* PARSETREE_H */
|
||||
#endif /* PARSETREE_H */
|
||||
|
@@ -127,4 +127,4 @@ extern int core_yylex(core_YYSTYPE *lvalp, YYLTYPE *llocp,
|
||||
extern int scanner_errposition(int location, core_yyscan_t yyscanner);
|
||||
extern void scanner_yyerror(const char *message, core_yyscan_t yyscanner) pg_attribute_noreturn();
|
||||
|
||||
#endif /* SCANNER_H */
|
||||
#endif /* SCANNER_H */
|
||||
|
@@ -27,4 +27,4 @@ extern void truncate_identifier(char *ident, int len, bool warn);
|
||||
|
||||
extern bool scanner_isspace(char ch);
|
||||
|
||||
#endif /* SCANSUP_H */
|
||||
#endif /* SCANSUP_H */
|
||||
|
Reference in New Issue
Block a user