8000 Run pgindent on the previous commit. · postgres/postgres@93aca12 · GitHub
[go: up one dir, main page]

Skip to content

Commit 93aca12

Browse files
committed
Run pgindent on the previous commit.
Clean up after rearranging PG_TRY blocks. Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/2954090.1748723636@sss.pgh.pa.us Backpatch-through: 13
1 parent 1c78d55 commit 93aca12

File tree

1 file changed

+133
-133
lines changed

1 file changed

+133
-133
lines changed

src/pl/plpython/plpy_elog.c

Lines changed: 133 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -61,64 +61,64 @@ PLy_elog_impl(int elevel, const char *fmt,...)
6161
/* Use a PG_TRY block to ensure we release the PyObjects just acquired */
6262
PG_TRY();
6363
{
64-
const char *primary = NULL;
65-
int sqlerrcode = 0;
66-
char *detail = NULL;
67-
char *hint = NULL;
68-
char *query = NULL;
69-
int position = 0;
70-
char *schema_name = NULL;
71-
char *table_name = NULL;
72-
char *column_name = NULL;
73-
char *datatype_name = NULL;
74-
char *constraint_name = NULL;
75-
76-
if (exc != NULL)
77-
{
78-
PyErr_NormalizeException(&exc, &val, &tb);
79-
80-
if (PyErr_GivenExceptionMatches(val, PLy_exc_spi_error))
81-
PLy_get_spi_error_data(val, &sqlerrcode,
82-
&detail, &hint, &query, &position,
64+
const char *primary = NULL;
65+
int sqlerrcode = 0;
66+
char *detail = NULL;
67+
char *hint = NULL;
68+
char *query = NULL;
69+
int position = 0;
70+
char *schema_name = NULL;
71+
char *table_name = NULL;
72+
char *column_name = NULL;
73+
char *datatype_name = NULL;
74+
char *constraint_name = NULL;
75+
76+
if (exc != NULL)
77+
{
78+
PyErr_NormalizeException(&exc, &val, &tb);
79+
80+
if (PyErr_GivenExceptionMatches(val, PLy_exc_spi_error))
81+
PLy_get_spi_error_data(val, &sqlerrcode,
82+
&detail, &hint, &query, &position,
83+
&schema_name, &table_name, &column_name,
84+
&datatype_name, &constraint_name);
85+
else if (PyErr_GivenExceptionMatches(val, PLy_exc_error))
86+
PLy_get_error_data(val, &sqlerrcode, &detail, &hint,
8387
&schema_name, &table_name, &column_name,
8488
&datatype_name, &constraint_name);
85-
else if (PyErr_GivenExceptionMatches(val, PLy_exc_error))
86-
PLy_get_error_data(val, &sqlerrcode, &detail, &hint,
87-
&schema_name, &table_name, &column_name,
88-
&datatype_name, &constraint_name);
89-
else if (PyErr_GivenExceptionMatches(val, PLy_exc_fatal))
90-
elevel = FATAL;
91-
}
89+
else if (PyErr_GivenExceptionMatches(val, PLy_exc_fatal))
90+
elevel = FATAL;
91+
}
9292

93-
PLy_traceback(exc, val, tb,
94-
&xmsg, &tbmsg, &tb_depth);
93+
PLy_traceback(exc, val, tb,
94+
&xmsg, &tbmsg, &tb_depth);
9595

96-
if (fmt)
97-
{
98-
for (;;)
96+
if (fmt)
9997
{
100-
va_list ap;
101-
int needed;
102-
103-
errno = save_errno;
104-
va_start(ap, fmt);
105-
needed = appendStringInfoVA(&emsg, dgettext(TEXTDOMAIN, fmt), ap);
106-
va_end(ap);
107-
if (needed == 0)
108-
break;
109-
enlargeStringInfo(&emsg, needed);
110-
}
111-
primary = emsg.data;
98+
for (;;)
99+
{
100+
va_list ap;
101+
int needed;
102+
103+
errno = save_errno;
104+
va_start(ap, fmt);
105+
needed = appendStringInfoVA(&emsg, dgettext(TEXTDOMAIN, fmt), ap);
106+
va_end(ap);
107+
if (needed == 0)
108+
break;
109+
enlargeStringInfo(&emsg, needed);
110+
}
111+
primary = emsg.data;
112112

113-
/* If there's an exception message, it goes in the detail. */
114-
if (xmsg)
115-
detail = xmsg;
116-
}
117-
else
118-
{
119-
if (xmsg)
120-
primary = xmsg;
121-
}
113+
/* If there's an exception message, it goes in the detail. */
114+
if (xmsg)
115+
detail = xmsg;
116+
}
117+
else
118+
{
119+
if (xmsg)
120+
primary = xmsg;
121+
}
122122

123123
ereport(elevel,
124124
(errcode(sqlerrcode ? sqlerrcode : ERRCODE_EXTERNAL_ROUTINE_EXCEPTION),
@@ -195,43 +195,43 @@ PLy_traceback(PyObject *e, PyObject *v, PyObject *tb,
195195
*/
196196
PG_TRY();
197197
{
198-
char *e_type_s = NULL;
199-
char *e_module_s = NULL;
200-
const char *vstr;
201-
StringInfoData xstr;
202-
203-
e_type_o = PyObject_GetAttrString(e, "__name__");
204-
e_module_o = PyObject_GetAttrString(e, "__module__");
205-
if (e_type_o)
206-
e_type_s = PyString_AsString(e_type_o);
207-
if (e_module_o)
208-
e_module_s = PyString_AsString(e_module_o);
209-
210-
if (v && ((vob = PyObject_Str(v)) != NULL))
211-
vstr = PyString_AsString(vob);
212-
else
213-
vstr = "unknown";
198+
char *e_type_s = NULL;
199+
char *e_module_s = NULL;
200+
const char *vstr;
201+
StringInfoData xstr;
202+
203+
e_type_o = PyObject_GetAttrString(e, "__name__");
204+
e_module_o = PyObject_GetAttrString(e, "__module__");
205+
if (e_type_o)
206+
e_type_s = PyString_AsString(e_type_o);
207+
if (e_module_o)
208+
e_module_s = PyString_AsString(e_module_o);
209+
210+
if (v && ((vob = PyObject_Str(v)) != NULL))
211+
vstr = PyString_AsString(vob);
212+
else
213+
vstr = "unknown";
214214

215-
initStringInfo(&xstr);
216-
if (!e_type_s || !e_module_s)
217-
{
218-
if (PyString_Check(e))
219-
/* deprecated string exceptions */
220-
appendStringInfoString(&xstr, PyString_AsString(e));
215+
initStringInfo(&xstr);
216+
if (!e_type_s || !e_module_s)
217+
{
218+
if (PyString_Check(e))
219+
/* deprecated string exceptions */
220+
appendStringInfoString(&xstr, PyString_AsString(e));
221+
else
222+
/* shouldn't happen */
223+
appendStringInfoString(&xstr, "unrecognized exception");
224+
}
225+
/* mimics behavior of traceback.format_exception_only */
226+
else if (strcmp(e_module_s, "builtins") == 0
227+
|| strcmp(e_module_s, "__main__") == 0
228+
|| strcmp(e_module_s, "exceptions") == 0)
229+
appendStringInfo(&xstr, "%s", e_type_s);
221230
else
222-
/* shouldn't happen */
223-
appendStringInfoString(&xstr, "unrecognized exception");
224-
}
225-
/* mimics behavior of traceback.format_exception_only */
226-
else if (strcmp(e_module_s, "builtins") == 0
227-
|| strcmp(e_module_s, "__main__") == 0
228-
|| strcmp(e_module_s, "exceptions") == 0)
229-
appendStringInfo(&xstr, "%s", e_type_s);
230-
else
231-
appendStringInfo(&xstr, "%s.%s", e_module_s, e_type_s);
232-
appendStringInfo(&xstr, ": %s", vstr);
231+
appendStringInfo(&xstr, "%s.%s", e_module_s, e_type_s);
232+
appendStringInfo(&xstr, ": %s", vstr);
233233

234-
*xmsg = xstr.data;
234+
*xmsg = xstr.data;
235235
}
236236
PG_FINALLY();
237237
{
@@ -278,61 +278,61 @@ PLy_traceback(PyObject *e, PyObject *v, PyObject *tb,
278278
if (filename == NULL)
279279
elog(ERROR, "could not get file name from Python code object");
280280

281-
/* The first frame always points at <module>, skip it. */
282-
if (*tb_depth > 0)
283-
{
284-
PLyExecutionContext *exec_ctx = PLy_current_execution_context();
285-
char *proname;
286-
char *fname;
287-
char *line;
288-
char *plain_filename;
289-
long plain_lineno;
290-
291-
/*
292-
* The second frame points at the internal function, but to mimic
293-
* Python error reporting we want to say <module>.
294-
*/
295-
if (*tb_depth == 1)
296-
fname = "<module>";
297-
else
298-
fname = PyString_AsString(name);
281+
/* The first frame always points at <module>, skip it. */
282+
if (*tb_depth > 0)
283+
{
284+
PLyExecutionContext *exec_ctx = PLy_current_execution_context();
285+
char *proname;
286+
char *fname;
287+
char *line;
288+
char *plain_filename;
289+
long plain_lineno;
299290

300-
proname = PLy_procedure_name(exec_ctx->curr_proc);
301-
plain_filename = PyString_AsString(filename);
302-
plain_lineno = PyInt_AsLong(lineno);
291+
/*
292+
* The second frame points at the internal function, but to
293+
* mimic Python error reporting we want to say <module>.
294+
*/
295+
if (*tb_depth == 1)
296+
fname = "<module>";
297+
else
298+
fname = PyString_AsString(name);
299+
300+
proname = PLy_procedure_name(exec_ctx->curr_proc);
301+
plain_filename = PyString_AsString(filename);
302+
plain_lineno = PyInt_AsLong(lineno);
303+
304+
if (proname == NULL)
305+
appendStringInfo(&tbstr, "\n PL/Python anonymous code block, line %ld, in %s",
306+
plain_lineno - 1, fname);
307+
else
308+
appendStringInfo(&tbstr, "\n PL/Python function \"%s\", line %ld, in %s",
309+
proname, plain_lineno - 1, fname);
303310

304-
if (proname == NULL)
305-
appendStringInfo(&tbstr, "\n PL/Python anonymous code block, line %ld, in %s",
306-
plain_lineno - 1, fname);
307-
else
308-
appendStringInfo(&tbstr, "\n PL/Python function \"%s\", line %ld, in %s",
309-
proname, plain_lineno - 1, fname);
310-
311-
/*
312-
* function code object was compiled with "<string>" as the
313-
* filename
314-
*/
315-
if (exec_ctx->curr_proc && plain_filename != NULL &&
316-
strcmp(plain_filename, "<string>") == 0)
317-
{
318311
/*
319-
* If we know the current procedure, append the exact line
320-
* from the source, again mimicking Python's traceback.py
321-
* module behavior. We could store the already line-split
322-
* source to avoid splitting it every time, but producing a
323-
* traceback is not the most important scenario to optimize
324-
* for. But we do not go as far as traceback.py in reading
325-
* the source of imported modules.
312+
* function code object was compiled with "<string>" as the
313+
* filename
326314
*/
327-
line = get_source_line(exec_ctx->curr_proc->src, plain_lineno);
328-
if (line)
315+
if (exec_ctx->curr_proc && plain_filename != NULL &&
316+
strcmp(plain_filename, "<string>") == 0)
329317
{
330-
appendStringInfo(&tbstr, "\n %s", line);
331-
pfree(line);
318+
/*
319+
* If we know the current procedure, append the exact line
320+
* from the source, again mimicking Python's traceback.py
321+
* module behavior. We could store the already line-split
322+
* source to avoid splitting it every time, but producing
323+
* a traceback is not the most important scenario to
324+
* optimize for. But we do not go as far as traceback.py
325+
* in reading the source of imported modules.
326+
*/
327+
line = get_source_line(exec_ctx->curr_proc->src, plain_lineno);
328+
if (line)
329+
{
330+
appendStringInfo(&tbstr, "\n %s", line);
331+
pfree(line);
332+
}
332333
}
333334
}
334335
}
335-
}
336336
PG_FINALLY();
337337
{
338338
Py_XDECREF(frame);

0 commit comments

Comments
 (0)
0