diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2017-06-21 15:35:54 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2017-06-21 15:35:54 -0400 |
commit | 382ceffdf7f620d8f2d50e451b4167d291ae2348 (patch) | |
tree | f558251492f2c6f86e3566f7a82f9d00509122c2 /src/backend/parser/parse_utilcmd.c | |
parent | c7b8998ebbf310a156aa38022555a24d98fdbfb4 (diff) | |
download | postgresql-382ceffdf7f620d8f2d50e451b4167d291ae2348.tar.gz postgresql-382ceffdf7f620d8f2d50e451b4167d291ae2348.zip |
Phase 3 of pgindent updates.
Don't move parenthesized lines to the left, even if that means they
flow past the right margin.
By default, BSD indent lines up statement continuation lines that are
within parentheses so that they start just to the right of the preceding
left parenthesis. However, traditionally, if that resulted in the
continuation line extending to the right of the desired right margin,
then indent would push it left just far enough to not overrun the margin,
if it could do so without making the continuation line start to the left of
the current statement indent. That makes for a weird mix of indentations
unless one has been completely rigid about never violating the 80-column
limit.
This behavior has been pretty universally panned by Postgres developers.
Hence, disable it with indent's new -lpl switch, so that parenthesized
lines are always lined up with the preceding left paren.
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
Diffstat (limited to 'src/backend/parser/parse_utilcmd.c')
-rw-r--r-- | src/backend/parser/parse_utilcmd.c | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 30e7caeb625..ee5f3a3a52c 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -136,7 +136,7 @@ static void transformColumnType(CreateStmtContext *cxt, ColumnDef *column); static void setSchemaName(char *context_schema, char **stmt_schema_name); static void transformPartitionCmd(CreateStmtContext *cxt, PartitionCmd *cmd); static Const *transformPartitionBoundValue(ParseState *pstate, A_Const *con, - const char *colName, Oid colType, int32 colTypmod); + const char *colName, Oid colType, int32 colTypmod); /* @@ -261,7 +261,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString) if (stmt->inhRelations && !stmt->partbound) ereport(ERROR, (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), - errmsg("cannot create partitioned table as inheritance child"))); + errmsg("cannot create partitioned table as inheritance child"))); } /* @@ -452,7 +452,7 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column, */ if (seqtypid) seqstmt->options = lcons(makeDefElem("as", - (Node *) makeTypeNameFromOid(seqtypid, -1), + (Node *) makeTypeNameFromOid(seqtypid, -1), -1), seqstmt->options); @@ -668,12 +668,12 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("multiple identity specifications for column \"%s\" of table \"%s\"", - column->colname, cxt->relation->relname), + column->colname, cxt->relation->relname), parser_errposition(cxt->pstate, constraint->location))); generateSerialExtraStmts(cxt, column, - typeOid, constraint->options, true, + typeOid, constraint->options, true, NULL, NULL); column->identity = constraint->generated_when; @@ -915,7 +915,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla if (cxt->isforeign) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("LIKE is not supported for creating foreign tables"))); + errmsg("LIKE is not supported for creating foreign tables"))); relation = relation_openrv(table_like_clause->relation, AccessShareLock); @@ -1076,7 +1076,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla stmt->objtype = OBJECT_COLUMN; stmt->object = (Node *) list_make3(makeString(cxt->relation->schemaname), - makeString(cxt->relation->relname), + makeString(cxt->relation->relname), makeString(def->colname)); stmt->comment = comment; @@ -1133,7 +1133,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla /* Copy comment on constraint */ if ((table_like_clause->options & CREATE_TABLE_LIKE_COMMENTS) && (comment = GetComment(get_relation_constraint_oid(RelationGetRelid(relation), - n->conname, false), + n->conname, false), ConstraintRelationId, 0)) != NULL) { @@ -1141,7 +1141,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla stmt->objtype = OBJECT_TABCONSTRAINT; stmt->object = (Node *) list_make3(makeString(cxt->relation->schemaname), - makeString(cxt->relation->relname), + makeString(cxt->relation->relname), makeString(n->conname)); stmt->comment = comment; @@ -1546,8 +1546,8 @@ generateClonedIndexStmt(CreateStmtContext *cxt, Relation source_idx, ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot convert whole-row table reference"), - errdetail("Index \"%s\" contains a whole-row table reference.", - RelationGetRelationName(source_idx)))); + errdetail("Index \"%s\" contains a whole-row table reference.", + RelationGetRelationName(source_idx)))); index->whereClause = pred_tree; } @@ -1753,8 +1753,8 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt) if (cxt->pkey != NULL) ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), - errmsg("multiple primary keys for table \"%s\" are not allowed", - cxt->relation->relname), + errmsg("multiple primary keys for table \"%s\" are not allowed", + cxt->relation->relname), parser_errposition(cxt->pstate, constraint->location))); cxt->pkey = index; @@ -1835,8 +1835,8 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt) if (OidIsValid(get_index_constraint(index_oid))) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("index \"%s\" is already associated with a constraint", - index_name), + errmsg("index \"%s\" is already associated with a constraint", + index_name), parser_errposition(cxt->pstate, constraint->location))); /* Perform validity checks on the index */ @@ -1924,7 +1924,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt) } else attform = SystemAttributeDefinition(attnum, - heap_rel->rd_rel->relhasoids); + heap_rel->rd_rel->relhasoids); attname = pstrdup(NameStr(attform->attname)); /* @@ -1942,7 +1942,7 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt) (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("index \"%s\" does not have default sorting behavior", index_name), errdetail("Cannot create a primary key or unique constraint using such an index."), - parser_errposition(cxt->pstate, constraint->location))); + parser_errposition(cxt->pstate, constraint->location))); constraint->keys = lappend(constraint->keys, makeString(attname)); } @@ -2086,13 +2086,13 @@ transformIndexConstraint(Constraint *constraint, CreateStmtContext *cxt) (errcode(ERRCODE_DUPLICATE_COLUMN), errmsg("column \"%s\" appears twice in primary key constraint", key), - parser_errposition(cxt->pstate, constraint->location))); + parser_errposition(cxt->pstate, constraint->location))); else ereport(ERROR, (errcode(ERRCODE_DUPLICATE_COLUMN), - errmsg("column \"%s\" appears twice in unique constraint", - key), - parser_errposition(cxt->pstate, constraint->location))); + errmsg("column \"%s\" appears twice in unique constraint", + key), + parser_errposition(cxt->pstate, constraint->location))); } } @@ -2396,7 +2396,7 @@ transformRuleStmt(RuleStmt *stmt, const char *queryString, /* take care of the where clause */ *whereClause = transformWhereClause(pstate, - (Node *) copyObject(stmt->whereClause), + (Node *) copyObject(stmt->whereClause), EXPR_KIND_WHERE, "WHERE"); /* we have to fix its collations too */ @@ -2787,7 +2787,7 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt, AlterSeqStmt *altseqstmt = makeNode(AlterSeqStmt); altseqstmt->sequence = makeRangeVar(get_namespace_name(get_rel_namespace(seq_relid)), - get_rel_name(seq_relid), + get_rel_name(seq_relid), -1); altseqstmt->options = list_make1(makeDefElem("as", (Node *) makeTypeNameFromOid(typeOid, -1), -1)); altseqstmt->for_identity = true; @@ -2863,7 +2863,7 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt, seqstmt = makeNode(AlterSeqStmt); seq_relid = linitial_oid(seqlist); seqstmt->sequence = makeRangeVar(get_namespace_name(get_rel_namespace(seq_relid)), - get_rel_name(seq_relid), -1); + get_rel_name(seq_relid), -1); seqstmt->options = newseqopts; seqstmt->for_identity = true; seqstmt->missing_ok = false; @@ -3313,8 +3313,8 @@ transformPartitionBound(ParseState *pstate, Relation parent, if (spec->strategy != PARTITION_STRATEGY_LIST) ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), - errmsg("invalid bound specification for a list partition"), - parser_errposition(pstate, exprLocation((Node *) spec)))); + errmsg("invalid bound specification for a list partition"), + parser_errposition(pstate, exprLocation((Node *) spec)))); /* Get the only column's name in case we need to output an error */ if (key->partattrs[0] != 0) @@ -3322,8 +3322,8 @@ transformPartitionBound(ParseState *pstate, Relation parent, key->partattrs[0]); else colname = deparse_expression((Node *) linitial(partexprs), - deparse_context_for(RelationGetRelationName(parent), - RelationGetRelid(parent)), + deparse_context_for(RelationGetRelationName(parent), + RelationGetRelid(parent)), false, false); /* Need its type data too */ coltype = get_partition_col_typid(key, 0); @@ -3370,8 +3370,8 @@ transformPartitionBound(ParseState *pstate, Relation parent, if (spec->strategy != PARTITION_STRATEGY_RANGE) ereport(ERROR, (errcode(ERRCODE_INVALID_TABLE_DEFINITION), - errmsg("invalid bound specification for a range partition"), - parser_errposition(pstate, exprLocation((Node *) spec)))); + errmsg("invalid bound specification for a range partition"), + parser_errposition(pstate, exprLocation((Node *) spec)))); if (list_length(spec->lowerdatums) != partnatts) ereport(ERROR, @@ -3397,8 +3397,8 @@ transformPartitionBound(ParseState *pstate, Relation parent, else if (seen_unbounded) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("cannot specify finite value after UNBOUNDED"), - parser_errposition(pstate, exprLocation((Node *) ldatum)))); + errmsg("cannot specify finite value after UNBOUNDED"), + parser_errposition(pstate, exprLocation((Node *) ldatum)))); } seen_unbounded = false; foreach(cell1, spec->upperdatums) @@ -3411,8 +3411,8 @@ transformPartitionBound(ParseState *pstate, Relation parent, else if (seen_unbounded) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("cannot specify finite value after UNBOUNDED"), - parser_errposition(pstate, exprLocation((Node *) rdatum)))); + errmsg("cannot specify finite value after UNBOUNDED"), + parser_errposition(pstate, exprLocation((Node *) rdatum)))); } /* Transform all the constants */ @@ -3435,8 +3435,8 @@ transformPartitionBound(ParseState *pstate, Relation parent, else { colname = deparse_expression((Node *) list_nth(partexprs, j), - deparse_context_for(RelationGetRelationName(parent), - RelationGetRelid(parent)), + deparse_context_for(RelationGetRelationName(parent), + RelationGetRelid(parent)), false, false); ++j; } @@ -3491,7 +3491,7 @@ transformPartitionBound(ParseState *pstate, Relation parent, */ static Const * transformPartitionBoundValue(ParseState *pstate, A_Const *con, - const char *colName, Oid colType, int32 colTypmod) + const char *colName, Oid colType, int32 colTypmod) { Node *value; @@ -3510,8 +3510,8 @@ transformPartitionBoundValue(ParseState *pstate, A_Const *con, if (value == NULL) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("specified value cannot be cast to type %s for column \"%s\"", - format_type_be(colType), colName), + errmsg("specified value cannot be cast to type %s for column \"%s\"", + format_type_be(colType), colName), parser_errposition(pstate, con->location))); /* Simplify the expression, in case we had a coercion */ @@ -3522,8 +3522,8 @@ transformPartitionBoundValue(ParseState *pstate, A_Const *con, if (!IsA(value, Const)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("specified value cannot be cast to type %s for column \"%s\"", - format_type_be(colType), colName), + errmsg("specified value cannot be cast to type %s for column \"%s\"", + format_type_be(colType), colName), errdetail("The cast requires a non-immutable conversion."), errhint("Try putting the literal value in single quotes."), parser_errposition(pstate, con->location))); |