mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +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:
@ -192,8 +192,8 @@ PLy_cursor_plan(PyObject *ob, PyObject *args)
|
||||
PLy_elog(ERROR, "could not execute plan");
|
||||
sv = PyString_AsString(so);
|
||||
PLy_exception_set_plural(PyExc_TypeError,
|
||||
"Expected sequence of %d argument, got %d: %s",
|
||||
"Expected sequence of %d arguments, got %d: %s",
|
||||
"Expected sequence of %d argument, got %d: %s",
|
||||
"Expected sequence of %d arguments, got %d: %s",
|
||||
plan->nargs,
|
||||
plan->nargs, nargs, sv);
|
||||
Py_DECREF(so);
|
||||
@ -501,7 +501,7 @@ PLy_cursor_close(PyObject *self, PyObject *unused)
|
||||
if (!PortalIsValid(portal))
|
||||
{
|
||||
PLy_exception_set(PyExc_ValueError,
|
||||
"closing a cursor in an aborted subtransaction");
|
||||
"closing a cursor in an aborted subtransaction");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,10 @@ static void PLy_traceback(PyObject *e, PyObject *v, PyObject *tb,
|
||||
char **xmsg, char **tbmsg, int *tb_depth);
|
||||
static void PLy_get_spi_error_data(PyObject *exc, int *sqlerrcode, char **detail,
|
||||
char **hint, char **query, int *position,
|
||||
char **schema_name, char **table_name, char **column_name,
|
||||
char **schema_name, char **table_name, char **column_name,
|
||||
char **datatype_name, char **constraint_name);
|
||||
static void PLy_get_error_data(PyObject *exc, int *sqlerrcode, char **detail,
|
||||
char **hint, char **schema_name, char **table_name, char **column_name,
|
||||
char **hint, char **schema_name, char **table_name, char **column_name,
|
||||
char **datatype_name, char **constraint_name);
|
||||
static char *get_source_line(const char *src, int lineno);
|
||||
|
||||
@ -122,7 +122,7 @@ PLy_elog(int elevel, const char *fmt,...)
|
||||
{
|
||||
ereport(elevel,
|
||||
(errcode(sqlerrcode ? sqlerrcode : ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
|
||||
errmsg_internal("%s", primary ? primary : "no exception data"),
|
||||
errmsg_internal("%s", primary ? primary : "no exception data"),
|
||||
(detail) ? errdetail_internal("%s", detail) : 0,
|
||||
(tb_depth > 0 && tbmsg) ? errcontext("%s", tbmsg) : 0,
|
||||
(hint) ? errhint("%s", hint) : 0,
|
||||
@ -136,8 +136,8 @@ PLy_elog(int elevel, const char *fmt,...)
|
||||
column_name) : 0,
|
||||
(datatype_name) ? err_generic_string(PG_DIAG_DATATYPE_NAME,
|
||||
datatype_name) : 0,
|
||||
(constraint_name) ? err_generic_string(PG_DIAG_CONSTRAINT_NAME,
|
||||
constraint_name) : 0));
|
||||
(constraint_name) ? err_generic_string(PG_DIAG_CONSTRAINT_NAME,
|
||||
constraint_name) : 0));
|
||||
}
|
||||
PG_CATCH();
|
||||
{
|
||||
@ -317,11 +317,11 @@ PLy_traceback(PyObject *e, PyObject *v, PyObject *tb,
|
||||
|
||||
if (proname == NULL)
|
||||
appendStringInfo(
|
||||
&tbstr, "\n PL/Python anonymous code block, line %ld, in %s",
|
||||
&tbstr, "\n PL/Python anonymous code block, line %ld, in %s",
|
||||
plain_lineno - 1, fname);
|
||||
else
|
||||
appendStringInfo(
|
||||
&tbstr, "\n PL/Python function \"%s\", line %ld, in %s",
|
||||
&tbstr, "\n PL/Python function \"%s\", line %ld, in %s",
|
||||
proname, plain_lineno - 1, fname);
|
||||
|
||||
/*
|
||||
|
@ -15,7 +15,7 @@ extern void PLy_elog(int elevel, const char *fmt,...) pg_attribute_printf(2, 3);
|
||||
extern void PLy_exception_set(PyObject *exc, const char *fmt,...) pg_attribute_printf(2, 3);
|
||||
|
||||
extern void PLy_exception_set_plural(PyObject *exc, const char *fmt_singular, const char *fmt_plural,
|
||||
unsigned long n,...) pg_attribute_printf(2, 5) pg_attribute_printf(3, 5);
|
||||
unsigned long n,...) pg_attribute_printf(2, 5) pg_attribute_printf(3, 5);
|
||||
|
||||
extern void PLy_exception_set_with_details(PyObject *excclass, ErrorData *edata);
|
||||
|
||||
|
@ -376,7 +376,7 @@ PLy_exec_trigger(FunctionCallInfo fcinfo, PLyProcedure *proc)
|
||||
{
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATA_EXCEPTION),
|
||||
errmsg("unexpected return value from trigger procedure"),
|
||||
errmsg("unexpected return value from trigger procedure"),
|
||||
errdetail("Expected None or a string.")));
|
||||
srv = NULL; /* keep compiler quiet */
|
||||
}
|
||||
@ -402,7 +402,7 @@ PLy_exec_trigger(FunctionCallInfo fcinfo, PLyProcedure *proc)
|
||||
*/
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_DATA_EXCEPTION),
|
||||
errmsg("unexpected return value from trigger procedure"),
|
||||
errmsg("unexpected return value from trigger procedure"),
|
||||
errdetail("Expected None, \"OK\", \"SKIP\", or \"MODIFY\".")));
|
||||
}
|
||||
}
|
||||
@ -487,7 +487,7 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc)
|
||||
PLy_elog(ERROR, "PyList_SetItem() failed, while setting up arguments");
|
||||
|
||||
if (proc->argnames && proc->argnames[i] &&
|
||||
PyDict_SetItemString(proc->globals, proc->argnames[i], arg) == -1)
|
||||
PyDict_SetItemString(proc->globals, proc->argnames[i], arg) == -1)
|
||||
PLy_elog(ERROR, "PyDict_SetItemString() failed, while setting up arguments");
|
||||
arg = NULL;
|
||||
}
|
||||
@ -554,7 +554,7 @@ PLy_function_save_args(PLyProcedure *proc)
|
||||
if (proc->argnames[i])
|
||||
{
|
||||
result->namedargs[i] = PyDict_GetItemString(proc->globals,
|
||||
proc->argnames[i]);
|
||||
proc->argnames[i]);
|
||||
Py_XINCREF(result->namedargs[i]);
|
||||
}
|
||||
}
|
||||
@ -747,7 +747,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *r
|
||||
Py_DECREF(pltname);
|
||||
|
||||
stroid = DatumGetCString(DirectFunctionCall1(oidout,
|
||||
ObjectIdGetDatum(tdata->tg_relation->rd_id)));
|
||||
ObjectIdGetDatum(tdata->tg_relation->rd_id)));
|
||||
pltrelid = PyString_FromString(stroid);
|
||||
PyDict_SetItemString(pltdata, "relid", pltrelid);
|
||||
Py_DECREF(pltrelid);
|
||||
|
@ -493,7 +493,7 @@ PLy_output(volatile int level, PyObject *self, PyObject *args, PyObject *kw)
|
||||
else
|
||||
{
|
||||
PLy_exception_set(PyExc_TypeError,
|
||||
"'%s' is an invalid keyword argument for this function",
|
||||
"'%s' is an invalid keyword argument for this function",
|
||||
keyword);
|
||||
return NULL;
|
||||
}
|
||||
@ -549,7 +549,7 @@ PLy_output(volatile int level, PyObject *self, PyObject *args, PyObject *kw)
|
||||
(column_name != NULL) ?
|
||||
err_generic_string(PG_DIAG_COLUMN_NAME, column_name) : 0,
|
||||
(constraint_name != NULL) ?
|
||||
err_generic_string(PG_DIAG_CONSTRAINT_NAME, constraint_name) : 0,
|
||||
err_generic_string(PG_DIAG_CONSTRAINT_NAME, constraint_name) : 0,
|
||||
(datatype_name != NULL) ?
|
||||
err_generic_string(PG_DIAG_DATATYPE_NAME, datatype_name) : 0,
|
||||
(table_name != NULL) ?
|
||||
|
@ -215,7 +215,7 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
|
||||
Form_pg_type rvTypeStruct;
|
||||
|
||||
rvTypeTup = SearchSysCache1(TYPEOID,
|
||||
ObjectIdGetDatum(procStruct->prorettype));
|
||||
ObjectIdGetDatum(procStruct->prorettype));
|
||||
if (!HeapTupleIsValid(rvTypeTup))
|
||||
elog(ERROR, "cache lookup failed for type %u",
|
||||
procStruct->prorettype);
|
||||
@ -232,8 +232,8 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
|
||||
procStruct->prorettype != RECORDOID)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("PL/Python functions cannot return type %s",
|
||||
format_type_be(procStruct->prorettype))));
|
||||
errmsg("PL/Python functions cannot return type %s",
|
||||
format_type_be(procStruct->prorettype))));
|
||||
}
|
||||
|
||||
if (rvTypeStruct->typtype == TYPTYPE_COMPOSITE ||
|
||||
@ -313,8 +313,8 @@ PLy_procedure_create(HeapTuple procTup, Oid fn_oid, bool is_trigger)
|
||||
/* Disallow pseudotype argument */
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("PL/Python functions cannot accept type %s",
|
||||
format_type_be(types[i]))));
|
||||
errmsg("PL/Python functions cannot accept type %s",
|
||||
format_type_be(types[i]))));
|
||||
break;
|
||||
case TYPTYPE_COMPOSITE:
|
||||
/* we'll set IO funcs at first call */
|
||||
|
@ -56,7 +56,7 @@ PLy_spi_prepare(PyObject *self, PyObject *args)
|
||||
if (list && (!PySequence_Check(list)))
|
||||
{
|
||||
PLy_exception_set(PyExc_TypeError,
|
||||
"second argument of plpy.prepare must be a sequence");
|
||||
"second argument of plpy.prepare must be a sequence");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -226,8 +226,8 @@ PLy_spi_execute_plan(PyObject *ob, PyObject *list, long limit)
|
||||
PLy_elog(ERROR, "could not execute plan");
|
||||
sv = PyString_AsString(so);
|
||||
PLy_exception_set_plural(PyExc_TypeError,
|
||||
"Expected sequence of %d argument, got %d: %s",
|
||||
"Expected sequence of %d arguments, got %d: %s",
|
||||
"Expected sequence of %d argument, got %d: %s",
|
||||
"Expected sequence of %d arguments, got %d: %s",
|
||||
plan->nargs,
|
||||
plan->nargs, nargs, sv);
|
||||
Py_DECREF(so);
|
||||
@ -570,7 +570,7 @@ PLy_spi_exception_set(PyObject *excclass, ErrorData *edata)
|
||||
|
||||
spidata = Py_BuildValue("(izzzizzzzz)", edata->sqlerrcode, edata->detail, edata->hint,
|
||||
edata->internalquery, edata->internalpos,
|
||||
edata->schema_name, edata->table_name, edata->column_name,
|
||||
edata->schema_name, edata->table_name, edata->column_name,
|
||||
edata->datatype_name, edata->constraint_name);
|
||||
if (!spidata)
|
||||
goto failure;
|
||||
|
@ -683,7 +683,7 @@ PLyList_FromArray_recurse(PLyDatumToOb *elm, int *dims, int ndim, int dim,
|
||||
PyObject *sublist;
|
||||
|
||||
sublist = PLyList_FromArray_recurse(elm, dims, ndim, dim + 1,
|
||||
dataptr_p, bitmap_p, bitmask_p);
|
||||
dataptr_p, bitmap_p, bitmask_p);
|
||||
PyList_SET_ITEM(list, i, sublist);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user