mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
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
This commit is contained in:
@ -368,7 +368,7 @@ SendCopyBegin(CopyState cstate)
|
||||
if (cstate->binary)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("COPY BINARY is not supported to stdout or from stdin")));
|
||||
errmsg("COPY BINARY is not supported to stdout or from stdin")));
|
||||
pq_putemptymessage('H');
|
||||
/* grottiness needed for old COPY OUT protocol */
|
||||
pq_startcopyout();
|
||||
@ -402,7 +402,7 @@ ReceiveCopyBegin(CopyState cstate)
|
||||
if (cstate->binary)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("COPY BINARY is not supported to stdout or from stdin")));
|
||||
errmsg("COPY BINARY is not supported to stdout or from stdin")));
|
||||
pq_putemptymessage('G');
|
||||
/* any error in old protocol will make us lose sync */
|
||||
pq_startmsgread();
|
||||
@ -619,7 +619,7 @@ CopyGetData(CopyState cstate, void *databuf, int minread, int maxread)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_QUERY_CANCELED),
|
||||
errmsg("COPY from stdin failed: %s",
|
||||
pq_getmsgstring(cstate->fe_msgbuf))));
|
||||
pq_getmsgstring(cstate->fe_msgbuf))));
|
||||
break;
|
||||
case 'H': /* Flush */
|
||||
case 'S': /* Sync */
|
||||
@ -797,13 +797,13 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
errmsg("must be superuser to COPY to or from an external program"),
|
||||
errhint("Anyone can COPY to stdout or from stdin. "
|
||||
"psql's \\copy command also works for anyone.")));
|
||||
"psql's \\copy command also works for anyone.")));
|
||||
else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
errmsg("must be superuser to COPY to or from a file"),
|
||||
errhint("Anyone can COPY to stdout or from stdin. "
|
||||
"psql's \\copy command also works for anyone.")));
|
||||
"psql's \\copy command also works for anyone.")));
|
||||
}
|
||||
|
||||
if (stmt->relation)
|
||||
@ -863,7 +863,7 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt,
|
||||
if (is_from)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("COPY FROM not supported with row-level security"),
|
||||
errmsg("COPY FROM not supported with row-level security"),
|
||||
errhint("Use INSERT statements instead.")));
|
||||
|
||||
/*
|
||||
@ -1243,14 +1243,14 @@ ProcessCopyOptions(ParseState *pstate,
|
||||
if (strlen(cstate->delim) != 1)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("COPY delimiter must be a single one-byte character")));
|
||||
errmsg("COPY delimiter must be a single one-byte character")));
|
||||
|
||||
/* Disallow end-of-line characters */
|
||||
if (strchr(cstate->delim, '\r') != NULL ||
|
||||
strchr(cstate->delim, '\n') != NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||
errmsg("COPY delimiter cannot be newline or carriage return")));
|
||||
errmsg("COPY delimiter cannot be newline or carriage return")));
|
||||
|
||||
if (strchr(cstate->null_print, '\r') != NULL ||
|
||||
strchr(cstate->null_print, '\n') != NULL)
|
||||
@ -1326,7 +1326,7 @@ ProcessCopyOptions(ParseState *pstate,
|
||||
if (cstate->force_notnull != NIL && !is_from)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("COPY force not null only available using COPY FROM")));
|
||||
errmsg("COPY force not null only available using COPY FROM")));
|
||||
|
||||
/* Check force_null */
|
||||
if (!cstate->csv_mode && cstate->force_null != NIL)
|
||||
@ -1343,7 +1343,7 @@ ProcessCopyOptions(ParseState *pstate,
|
||||
if (strchr(cstate->null_print, cstate->delim[0]) != NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("COPY delimiter must not appear in the NULL specification")));
|
||||
errmsg("COPY delimiter must not appear in the NULL specification")));
|
||||
|
||||
/* Don't allow the CSV quote char to appear in the null string. */
|
||||
if (cstate->csv_mode &&
|
||||
@ -1473,7 +1473,7 @@ BeginCopy(ParseState *pstate,
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("DO INSTEAD NOTHING rules are not supported for COPY")));
|
||||
errmsg("DO INSTEAD NOTHING rules are not supported for COPY")));
|
||||
}
|
||||
else if (list_length(rewritten) > 1)
|
||||
{
|
||||
@ -1491,7 +1491,7 @@ BeginCopy(ParseState *pstate,
|
||||
if (q->querySource == QSRC_NON_INSTEAD_RULE)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("DO ALSO rules are not supported for the COPY")));
|
||||
errmsg("DO ALSO rules are not supported for the COPY")));
|
||||
}
|
||||
|
||||
ereport(ERROR,
|
||||
@ -1551,7 +1551,7 @@ BeginCopy(ParseState *pstate,
|
||||
if (!list_member_oid(plan->relationOids, queryRelId))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("relation referenced by COPY statement has changed")));
|
||||
errmsg("relation referenced by COPY statement has changed")));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1609,8 +1609,8 @@ BeginCopy(ParseState *pstate,
|
||||
if (!list_member_int(cstate->attnumlist, attnum))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("FORCE_QUOTE column \"%s\" not referenced by COPY",
|
||||
NameStr(tupDesc->attrs[attnum - 1]->attname))));
|
||||
errmsg("FORCE_QUOTE column \"%s\" not referenced by COPY",
|
||||
NameStr(tupDesc->attrs[attnum - 1]->attname))));
|
||||
cstate->force_quote_flags[attnum - 1] = true;
|
||||
}
|
||||
}
|
||||
@ -1631,8 +1631,8 @@ BeginCopy(ParseState *pstate,
|
||||
if (!list_member_int(cstate->attnumlist, attnum))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("FORCE_NOT_NULL column \"%s\" not referenced by COPY",
|
||||
NameStr(tupDesc->attrs[attnum - 1]->attname))));
|
||||
errmsg("FORCE_NOT_NULL column \"%s\" not referenced by COPY",
|
||||
NameStr(tupDesc->attrs[attnum - 1]->attname))));
|
||||
cstate->force_notnull_flags[attnum - 1] = true;
|
||||
}
|
||||
}
|
||||
@ -1653,8 +1653,8 @@ BeginCopy(ParseState *pstate,
|
||||
if (!list_member_int(cstate->attnumlist, attnum))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg("FORCE_NULL column \"%s\" not referenced by COPY",
|
||||
NameStr(tupDesc->attrs[attnum - 1]->attname))));
|
||||
errmsg("FORCE_NULL column \"%s\" not referenced by COPY",
|
||||
NameStr(tupDesc->attrs[attnum - 1]->attname))));
|
||||
cstate->force_null_flags[attnum - 1] = true;
|
||||
}
|
||||
}
|
||||
@ -1677,7 +1677,7 @@ BeginCopy(ParseState *pstate,
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
|
||||
errmsg_internal("selected column \"%s\" not referenced by COPY",
|
||||
NameStr(tupDesc->attrs[attnum - 1]->attname))));
|
||||
NameStr(tupDesc->attrs[attnum - 1]->attname))));
|
||||
cstate->convert_select_flags[attnum - 1] = true;
|
||||
}
|
||||
}
|
||||
@ -1841,7 +1841,7 @@ BeginCopyTo(ParseState *pstate,
|
||||
if (!is_absolute_path(filename))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_NAME),
|
||||
errmsg("relative path not allowed for COPY to file")));
|
||||
errmsg("relative path not allowed for COPY to file")));
|
||||
|
||||
oumask = umask(S_IWGRP | S_IWOTH);
|
||||
cstate->copy_file = AllocateFile(cstate->filename, PG_BINARY_W);
|
||||
@ -2009,8 +2009,8 @@ CopyTo(CopyState cstate)
|
||||
*/
|
||||
if (cstate->need_transcoding)
|
||||
cstate->null_print_client = pg_server_to_any(cstate->null_print,
|
||||
cstate->null_print_len,
|
||||
cstate->file_encoding);
|
||||
cstate->null_print_len,
|
||||
cstate->file_encoding);
|
||||
|
||||
/* if a header has been requested send the line */
|
||||
if (cstate->header_line)
|
||||
@ -2120,7 +2120,7 @@ CopyOneRowTo(CopyState cstate, Oid tupleOid, Datum *values, bool *nulls)
|
||||
if (cstate->oids)
|
||||
{
|
||||
string = DatumGetCString(DirectFunctionCall1(oidout,
|
||||
ObjectIdGetDatum(tupleOid)));
|
||||
ObjectIdGetDatum(tupleOid)));
|
||||
CopySendString(cstate, string);
|
||||
need_delim = true;
|
||||
}
|
||||
@ -2418,7 +2418,7 @@ CopyFrom(CopyState cstate)
|
||||
errmsg("cannot perform FREEZE because of prior transaction activity")));
|
||||
|
||||
if (cstate->rel->rd_createSubid != GetCurrentSubTransactionId() &&
|
||||
cstate->rel->rd_newRelfilenodeSubid != GetCurrentSubTransactionId())
|
||||
cstate->rel->rd_newRelfilenodeSubid != GetCurrentSubTransactionId())
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("cannot perform FREEZE because the table was not created or truncated in the current subtransaction")));
|
||||
@ -2556,7 +2556,7 @@ CopyFrom(CopyState cstate)
|
||||
* partition, respectively.
|
||||
*/
|
||||
leaf_part_index = ExecFindPartition(resultRelInfo,
|
||||
cstate->partition_dispatch_info,
|
||||
cstate->partition_dispatch_info,
|
||||
slot,
|
||||
estate);
|
||||
Assert(leaf_part_index >= 0 &&
|
||||
@ -2584,7 +2584,7 @@ CopyFrom(CopyState cstate)
|
||||
if (resultRelInfo->ri_FdwRoutine)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot route inserted tuples to a foreign table")));
|
||||
errmsg("cannot route inserted tuples to a foreign table")));
|
||||
|
||||
/*
|
||||
* For ExecInsertIndexTuples() to work on the partition's indexes
|
||||
@ -2695,7 +2695,7 @@ CopyFrom(CopyState cstate)
|
||||
|
||||
if (resultRelInfo->ri_NumIndices > 0)
|
||||
recheckIndexes = ExecInsertIndexTuples(slot,
|
||||
&(tuple->t_self),
|
||||
&(tuple->t_self),
|
||||
estate,
|
||||
false,
|
||||
NULL,
|
||||
@ -3100,7 +3100,7 @@ BeginCopyFrom(ParseState *pstate,
|
||||
if ((tmp >> 16) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
|
||||
errmsg("unrecognized critical flags in COPY file header")));
|
||||
errmsg("unrecognized critical flags in COPY file header")));
|
||||
/* Header extension length */
|
||||
if (!CopyGetInt32(cstate, &tmp) ||
|
||||
tmp < 0)
|
||||
@ -3268,7 +3268,7 @@ NextCopyFrom(CopyState cstate, ExprContext *econtext,
|
||||
cstate->cur_attname = "oid";
|
||||
cstate->cur_attval = string;
|
||||
*tupleOid = DatumGetObjectId(DirectFunctionCall1(oidin,
|
||||
CStringGetDatum(string)));
|
||||
CStringGetDatum(string)));
|
||||
if (*tupleOid == InvalidOid)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
|
||||
@ -3388,8 +3388,8 @@ NextCopyFrom(CopyState cstate, ExprContext *econtext,
|
||||
loaded_oid =
|
||||
DatumGetObjectId(CopyReadBinaryAttribute(cstate,
|
||||
0,
|
||||
&cstate->oid_in_function,
|
||||
cstate->oid_typioparam,
|
||||
&cstate->oid_in_function,
|
||||
cstate->oid_typioparam,
|
||||
-1,
|
||||
&isnull));
|
||||
if (isnull || loaded_oid == InvalidOid)
|
||||
@ -3717,10 +3717,10 @@ CopyReadLineText(CopyState cstate)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_BAD_COPY_FILE_FORMAT),
|
||||
!cstate->csv_mode ?
|
||||
errmsg("literal carriage return found in data") :
|
||||
errmsg("unquoted carriage return found in data"),
|
||||
errmsg("literal carriage return found in data") :
|
||||
errmsg("unquoted carriage return found in data"),
|
||||
!cstate->csv_mode ?
|
||||
errhint("Use \"\\r\" to represent carriage return.") :
|
||||
errhint("Use \"\\r\" to represent carriage return.") :
|
||||
errhint("Use quoted CSV field to represent carriage return.")));
|
||||
|
||||
/*
|
||||
@ -3737,7 +3737,7 @@ CopyReadLineText(CopyState cstate)
|
||||
errmsg("literal carriage return found in data") :
|
||||
errmsg("unquoted carriage return found in data"),
|
||||
!cstate->csv_mode ?
|
||||
errhint("Use \"\\r\" to represent carriage return.") :
|
||||
errhint("Use \"\\r\" to represent carriage return.") :
|
||||
errhint("Use quoted CSV field to represent carriage return.")));
|
||||
/* If reach here, we have found the line terminator */
|
||||
break;
|
||||
@ -3754,7 +3754,7 @@ CopyReadLineText(CopyState cstate)
|
||||
errmsg("unquoted newline found in data"),
|
||||
!cstate->csv_mode ?
|
||||
errhint("Use \"\\n\" to represent newline.") :
|
||||
errhint("Use quoted CSV field to represent newline.")));
|
||||
errhint("Use quoted CSV field to represent newline.")));
|
||||
cstate->eol_type = EOL_NL; /* in case not set yet */
|
||||
/* If reach here, we have found the line terminator */
|
||||
break;
|
||||
@ -3845,8 +3845,8 @@ CopyReadLineText(CopyState cstate)
|
||||
*/
|
||||
if (prev_raw_ptr > cstate->raw_buf_index)
|
||||
appendBinaryStringInfo(&cstate->line_buf,
|
||||
cstate->raw_buf + cstate->raw_buf_index,
|
||||
prev_raw_ptr - cstate->raw_buf_index);
|
||||
cstate->raw_buf + cstate->raw_buf_index,
|
||||
prev_raw_ptr - cstate->raw_buf_index);
|
||||
cstate->raw_buf_index = raw_buf_ptr;
|
||||
result = true; /* report EOF */
|
||||
break;
|
||||
@ -4682,8 +4682,8 @@ CopyGetAttnums(TupleDesc tupDesc, Relation rel, List *attnamelist)
|
||||
if (rel != NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||
errmsg("column \"%s\" of relation \"%s\" does not exist",
|
||||
name, RelationGetRelationName(rel))));
|
||||
errmsg("column \"%s\" of relation \"%s\" does not exist",
|
||||
name, RelationGetRelationName(rel))));
|
||||
else
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||
|
Reference in New Issue
Block a user