diff options
Diffstat (limited to 'src/pl')
27 files changed, 138 insertions, 126 deletions
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index 7a92f3d8e28..db584c4e7e4 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -1259,19 +1259,19 @@ plperl_sv_to_datum(SV *sv, Oid typid, int32 typmod, if (!type_is_rowtype(typid)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("cannot convert Perl hash to non-composite type %s", - format_type_be(typid)))); + errmsg("cannot convert Perl hash to non-composite type %s", + format_type_be(typid)))); td = lookup_rowtype_tupdesc_noerror(typid, typmod, true); if (td == NULL) { /* Try to look it up based on our result type */ if (fcinfo == NULL || - get_call_result_type(fcinfo, NULL, &td) != TYPEFUNC_COMPOSITE) + get_call_result_type(fcinfo, NULL, &td) != TYPEFUNC_COMPOSITE) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("function returning record called in context " - "that cannot accept type record"))); + errmsg("function returning record called in context " + "that cannot accept type record"))); } ret = plperl_hash_to_datum(sv, td); diff --git a/src/pl/plperl/plperl_helpers.h b/src/pl/plperl/plperl_helpers.h index 6b714e52a14..1b6648be1d1 100644 --- a/src/pl/plperl/plperl_helpers.h +++ b/src/pl/plperl/plperl_helpers.h @@ -7,15 +7,15 @@ static inline char * utf_u2e(const char *utf8_str, size_t len) { - int enc = GetDatabaseEncoding(); + int enc = GetDatabaseEncoding(); char *ret = (char *) pg_do_encoding_conversion((unsigned char *) utf8_str, len, PG_UTF8, enc); /* - * when we are a PG_UTF8 or SQL_ASCII database - * pg_do_encoding_conversion() will not do any conversion or - * verification. we need to do it manually instead. - */ + * when we are a PG_UTF8 or SQL_ASCII database pg_do_encoding_conversion() + * will not do any conversion or verification. we need to do it manually + * instead. + */ if (enc == PG_UTF8 || enc == PG_SQL_ASCII) pg_verify_mbstr_len(PG_UTF8, utf8_str, len, false); @@ -45,7 +45,8 @@ utf_e2u(const char *str) static inline char * sv2cstr(SV *sv) { - char *val, *res; + char *val, + *res; STRLEN len; /* @@ -54,23 +55,26 @@ sv2cstr(SV *sv) * SvPVutf8() croaks nastily on certain things, like typeglobs and * readonly objects such as $^V. That's a perl bug - it's not supposed to * happen. To avoid crashing the backend, we make a copy of the sv before - * passing it to SvPVutf8(). The copy is garbage collected - * when we're done with it. + * passing it to SvPVutf8(). The copy is garbage collected when we're done + * with it. */ if (SvREADONLY(sv) || isGV_with_GP(sv) || (SvTYPE(sv) > SVt_PVLV && SvTYPE(sv) != SVt_PVFM)) sv = newSVsv(sv); else - /* increase the reference count so we can just SvREFCNT_dec() it when - * we are done */ + + /* + * increase the reference count so we can just SvREFCNT_dec() it when + * we are done + */ SvREFCNT_inc_simple_void(sv); val = SvPVutf8(sv, len); /* - * we use perl's length in the event we had an embedded null byte to ensure - * we error out properly + * we use perl's length in the event we had an embedded null byte to + * ensure we error out properly */ res = utf_u2e(val, len); diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index d43b8e0b1a1..5d2f818dacb 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -77,7 +77,7 @@ typedef struct } ExceptionLabelMap; static const ExceptionLabelMap exception_label_map[] = { -#include "plerrcodes.h" /* pgrminclude ignore */ +#include "plerrcodes.h" /* pgrminclude ignore */ {NULL, 0} }; diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 95e74b38dc4..8ca791ce3f4 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -881,8 +881,8 @@ copy_plpgsql_datum(PLpgSQL_datum *datum) /* * These datum records are read-only at runtime, so no need to - * copy them (well, ARRAYELEM contains some cached type data, - * but we'd just as soon centralize the caching anyway) + * copy them (well, ARRAYELEM contains some cached type data, but + * we'd just as soon centralize the caching anyway) */ result = datum; break; @@ -1441,8 +1441,8 @@ exec_stmt_getdiag(PLpgSQL_execstate *estate, PLpgSQL_stmt_getdiag *stmt) */ if (stmt->is_stacked && estate->cur_error == NULL) ereport(ERROR, - (errcode(ERRCODE_STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER), - errmsg("GET STACKED DIAGNOSTICS cannot be used outside an exception handler"))); + (errcode(ERRCODE_STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER), + errmsg("GET STACKED DIAGNOSTICS cannot be used outside an exception handler"))); foreach(lc, stmt->diag_items) { @@ -1481,7 +1481,7 @@ exec_stmt_getdiag(PLpgSQL_execstate *estate, PLpgSQL_stmt_getdiag *stmt) case PLPGSQL_GETDIAG_RETURNED_SQLSTATE: exec_assign_c_string(estate, var, - unpack_sql_state(estate->cur_error->sqlerrcode)); + unpack_sql_state(estate->cur_error->sqlerrcode)); break; case PLPGSQL_GETDIAG_MESSAGE_TEXT: @@ -2676,8 +2676,8 @@ exec_stmt_raise(PLpgSQL_execstate *estate, PLpgSQL_stmt_raise *stmt) ReThrowError(estate->cur_error); /* oops, we're not inside a handler */ ereport(ERROR, - (errcode(ERRCODE_STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER), - errmsg("RAISE without parameters cannot be used outside an exception handler"))); + (errcode(ERRCODE_STACKED_DIAGNOSTICS_ACCESSED_WITHOUT_ACTIVE_HANDLER), + errmsg("RAISE without parameters cannot be used outside an exception handler"))); } if (stmt->condname) @@ -3036,7 +3036,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate, foreach(l2, plansource->query_list) { - Query *q = (Query *) lfirst(l2); + Query *q = (Query *) lfirst(l2); Assert(IsA(q, Query)); if (q->canSetTag) @@ -3288,9 +3288,9 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate, * a functional limitation because CREATE TABLE AS is allowed. */ ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("EXECUTE of SELECT ... INTO is not implemented"), - errhint("You might want to use EXECUTE ... INTO or EXECUTE CREATE TABLE ... AS instead."))); + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("EXECUTE of SELECT ... INTO is not implemented"), + errhint("You might want to use EXECUTE ... INTO or EXECUTE CREATE TABLE ... AS instead."))); break; /* Some SPI errors deserve specific error messages */ @@ -3771,8 +3771,8 @@ exec_assign_value(PLpgSQL_execstate *estate, /* * If type is by-reference, copy the new value (which is - * probably in the eval_econtext) into the procedure's - * memory context. + * probably in the eval_econtext) into the procedure's memory + * context. */ if (!var->datatype->typbyval && !*isNull) newvalue = datumCopy(newvalue, @@ -4051,7 +4051,7 @@ exec_assign_value(PLpgSQL_execstate *estate, if (!OidIsValid(elemtypoid)) ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("subscripted object is not an array"))); + errmsg("subscripted object is not an array"))); /* Collect needed data about the types */ arraytyplen = get_typlen(arraytypoid); @@ -4124,7 +4124,7 @@ exec_assign_value(PLpgSQL_execstate *estate, * array, either, so that's a no-op too. This is all ugly but * corresponds to the current behavior of ExecEvalArrayRef(). */ - if (arrayelem->arraytyplen > 0 && /* fixed-length array? */ + if (arrayelem->arraytyplen > 0 && /* fixed-length array? */ (oldarrayisnull || *isNull)) return; @@ -5358,7 +5358,7 @@ convert_value_to_string(PLpgSQL_execstate *estate, Datum value, Oid valtype) * * Note: the estate's eval_econtext is used for temporary storage, and may * also contain the result Datum if we have to do a conversion to a pass- - * by-reference data type. Be sure to do an exec_eval_cleanup() call when + * by-reference data type. Be sure to do an exec_eval_cleanup() call when * done with the result. * ---------- */ @@ -5708,8 +5708,8 @@ exec_simple_check_plan(PLpgSQL_expr *expr) /* * Initialize to "not simple", and remember the plan generation number we - * last checked. (If we don't get as far as obtaining a plan to check, - * we just leave expr_simple_generation set to 0.) + * last checked. (If we don't get as far as obtaining a plan to check, we + * just leave expr_simple_generation set to 0.) */ expr->expr_simple_expr = NULL; expr->expr_simple_generation = 0; @@ -5722,12 +5722,12 @@ exec_simple_check_plan(PLpgSQL_expr *expr) plansource = (CachedPlanSource *) linitial(expr->plan->plancache_list); /* - * Do some checking on the analyzed-and-rewritten form of the query. - * These checks are basically redundant with the tests in + * Do some checking on the analyzed-and-rewritten form of the query. These + * checks are basically redundant with the tests in * exec_simple_recheck_plan, but the point is to avoid building a plan if - * possible. Since this function is only - * called immediately after creating the CachedPlanSource, we need not - * worry about the query being stale. + * possible. Since this function is only called immediately after + * creating the CachedPlanSource, we need not worry about the query being + * stale. */ /* diff --git a/src/pl/plpython/plpy_cursorobject.c b/src/pl/plpython/plpy_cursorobject.c index e8240b63c90..910e63b1995 100644 --- a/src/pl/plpython/plpy_cursorobject.c +++ b/src/pl/plpython/plpy_cursorobject.c @@ -40,7 +40,7 @@ static PyMethodDef PLy_cursor_methods[] = { static PyTypeObject PLy_CursorType = { PyVarObject_HEAD_INIT(NULL, 0) - "PLyCursor", /* tp_name */ + "PLyCursor", /* tp_name */ sizeof(PLyCursorObject), /* tp_size */ 0, /* tp_itemsize */ @@ -103,7 +103,7 @@ PLy_cursor(PyObject *self, PyObject *args) static PyObject * PLy_cursor_query(const char *query) { - PLyCursorObject *cursor; + PLyCursorObject *cursor; volatile MemoryContext oldcontext; volatile ResourceOwner oldowner; @@ -120,7 +120,7 @@ PLy_cursor_query(const char *query) PG_TRY(); { - PLyExecutionContext *exec_ctx = PLy_current_execution_context(); + PLyExecutionContext *exec_ctx = PLy_current_execution_context(); SPIPlanPtr plan; Portal portal; @@ -157,7 +157,7 @@ PLy_cursor_query(const char *query) static PyObject * PLy_cursor_plan(PyObject *ob, PyObject *args) { - PLyCursorObject *cursor; + PLyCursorObject *cursor; volatile int nargs; int i; PLyPlanObject *plan; @@ -187,8 +187,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); @@ -305,7 +305,7 @@ static void PLy_cursor_dealloc(PyObject *arg) { PLyCursorObject *cursor; - Portal portal; + Portal portal; cursor = (PLyCursorObject *) arg; @@ -328,10 +328,10 @@ static PyObject * PLy_cursor_iternext(PyObject *self) { PLyCursorObject *cursor; - PyObject *ret; + PyObject *ret; volatile MemoryContext oldcontext; volatile ResourceOwner oldowner; - Portal portal; + Portal portal; cursor = (PLyCursorObject *) self; @@ -391,11 +391,11 @@ static PyObject * PLy_cursor_fetch(PyObject *self, PyObject *args) { PLyCursorObject *cursor; - int count; - PLyResultObject *ret; + int count; + PLyResultObject *ret; volatile MemoryContext oldcontext; volatile ResourceOwner oldowner; - Portal portal; + Portal portal; if (!PyArg_ParseTuple(args, "i", &count)) return NULL; @@ -440,7 +440,7 @@ PLy_cursor_fetch(PyObject *self, PyObject *args) if (SPI_processed != 0) { - int i; + int i; Py_DECREF(ret->rows); ret->rows = PyList_New(SPI_processed); @@ -450,6 +450,7 @@ PLy_cursor_fetch(PyObject *self, PyObject *args) PyObject *row = PLyDict_FromTuple(&cursor->result, SPI_tuptable->vals[i], SPI_tuptable->tupdesc); + PyList_SetItem(ret->rows, i, row); } } @@ -477,12 +478,12 @@ PLy_cursor_close(PyObject *self, PyObject *unused) if (!cursor->closed) { - Portal portal = GetPortalByName(cursor->portalname); + Portal portal = GetPortalByName(cursor->portalname); if (!PortalIsValid(portal)) { PLy_exception_set(PyExc_ValueError, - "closing a cursor in an aborted subtransaction"); + "closing a cursor in an aborted subtransaction"); return NULL; } diff --git a/src/pl/plpython/plpy_cursorobject.h b/src/pl/plpython/plpy_cursorobject.h index 1dd9d48fd58..3c28f4f8e71 100644 --- a/src/pl/plpython/plpy_cursorobject.h +++ b/src/pl/plpython/plpy_cursorobject.h @@ -11,7 +11,7 @@ typedef struct PLyCursorObject { PyObject_HEAD - char *portalname; + char *portalname; PLyTypeInfo result; bool closed; } PLyCursorObject; @@ -19,4 +19,4 @@ typedef struct PLyCursorObject extern void PLy_cursor_init_type(void); extern PyObject *PLy_cursor(PyObject *self, PyObject *args); -#endif /* PLPY_CURSOROBJECT_H */ +#endif /* PLPY_CURSOROBJECT_H */ diff --git a/src/pl/plpython/plpy_elog.c b/src/pl/plpython/plpy_elog.c index f7d321289d4..c375ac07fa8 100644 --- a/src/pl/plpython/plpy_elog.c +++ b/src/pl/plpython/plpy_elog.c @@ -16,15 +16,15 @@ #include "plpy_procedure.h" -PyObject *PLy_exc_error = NULL; -PyObject *PLy_exc_fatal = NULL; -PyObject *PLy_exc_spi_error = NULL; +PyObject *PLy_exc_error = NULL; +PyObject *PLy_exc_fatal = NULL; +PyObject *PLy_exc_spi_error = NULL; static void PLy_traceback(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); -static char * get_source_line(const char *src, int lineno); + char **hint, char **query, int *position); +static char *get_source_line(const char *src, int lineno); /* @@ -46,7 +46,7 @@ PLy_elog(int elevel, const char *fmt,...) *val, *tb; const char *primary = NULL; - int sqlerrcode = 0; + int sqlerrcode = 0; char *detail = NULL; char *hint = NULL; char *query = NULL; @@ -98,7 +98,7 @@ PLy_elog(int elevel, const char *fmt,...) { ereport(elevel, (errcode(sqlerrcode ? sqlerrcode : ERRCODE_INTERNAL_ERROR), - 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, @@ -256,7 +256,7 @@ PLy_traceback(char **xmsg, char **tbmsg, int *tb_depth) /* The first frame always points at <module>, skip it. */ if (*tb_depth > 0) { - PLyExecutionContext *exec_ctx = PLy_current_execution_context(); + PLyExecutionContext *exec_ctx = PLy_current_execution_context(); char *proname; char *fname; char *line; diff --git a/src/pl/plpython/plpy_elog.h b/src/pl/plpython/plpy_elog.h index f7223b00568..6b8d485625b 100644 --- a/src/pl/plpython/plpy_elog.h +++ b/src/pl/plpython/plpy_elog.h @@ -10,15 +10,18 @@ extern PyObject *PLy_exc_error; extern PyObject *PLy_exc_fatal; extern PyObject *PLy_exc_spi_error; -extern void PLy_elog(int elevel, const char *fmt,...) +extern void +PLy_elog(int elevel, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); -extern void PLy_exception_set(PyObject *exc, const char *fmt,...) +extern void +PLy_exception_set(PyObject *exc, const char *fmt,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3))); -extern void PLy_exception_set_plural(PyObject *exc, const char *fmt_singular, const char *fmt_plural, - unsigned long n,...) +extern void +PLy_exception_set_plural(PyObject *exc, const char *fmt_singular, const char *fmt_plural, + unsigned long n,...) __attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 5))) __attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 5))); -#endif /* PLPY_ELOG_H */ +#endif /* PLPY_ELOG_H */ diff --git a/src/pl/plpython/plpy_exec.c b/src/pl/plpython/plpy_exec.c index ad30fc0065b..96ee26c35c7 100644 --- a/src/pl/plpython/plpy_exec.c +++ b/src/pl/plpython/plpy_exec.c @@ -30,9 +30,9 @@ static void PLy_function_delete_args(PLyProcedure *proc); static void plpython_return_error_callback(void *arg); static PyObject *PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, - HeapTuple *rv); + HeapTuple *rv); static HeapTuple PLy_modify_tuple(PLyProcedure *proc, PyObject *pltd, - TriggerData *tdata, HeapTuple otup); + TriggerData *tdata, HeapTuple otup); static void plpython_trigger_error_callback(void *arg); static PyObject *PLy_procedure_call(PLyProcedure *proc, char *kargs, PyObject *vargs); @@ -180,7 +180,7 @@ PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc) } else if (proc->result.is_rowtype >= 1) { - TupleDesc desc; + TupleDesc desc; /* make sure it's not an unnamed record */ Assert((proc->result.out.d.typoid == RECORDOID && diff --git a/src/pl/plpython/plpy_exec.h b/src/pl/plpython/plpy_exec.h index f3dec074c13..439a1d801f6 100644 --- a/src/pl/plpython/plpy_exec.h +++ b/src/pl/plpython/plpy_exec.h @@ -10,4 +10,4 @@ extern Datum PLy_exec_function(FunctionCallInfo fcinfo, PLyProcedure *proc); extern HeapTuple PLy_exec_trigger(FunctionCallInfo fcinfo, PLyProcedure *proc); -#endif /* PLPY_EXEC_H */ +#endif /* PLPY_EXEC_H */ diff --git a/src/pl/plpython/plpy_main.c b/src/pl/plpython/plpy_main.c index c126db995ae..494ec37ea7c 100644 --- a/src/pl/plpython/plpy_main.c +++ b/src/pl/plpython/plpy_main.c @@ -73,7 +73,7 @@ static void PLy_pop_execution_context(void); static const int plpython_python_version = PY_MAJOR_VERSION; /* initialize global variables */ -PyObject *PLy_interp_globals = NULL; +PyObject *PLy_interp_globals = NULL; /* this doesn't need to be global; use PLy_current_execution_context() */ static PLyExecutionContext *PLy_execution_contexts = NULL; @@ -284,8 +284,8 @@ plpython_inline_handler(PG_FUNCTION_ARGS) * Push execution context onto stack. It is important that this get * popped again, so avoid putting anything that could throw error between * here and the PG_TRY. (plpython_inline_error_callback doesn't currently - * need the stack entry, but for consistency with plpython_call_handler - * we do it in this order.) + * need the stack entry, but for consistency with plpython_call_handler we + * do it in this order.) */ exec_ctx = PLy_push_execution_context(); @@ -330,7 +330,8 @@ plpython2_inline_handler(PG_FUNCTION_ARGS) } #endif /* PY_MAJOR_VERSION < 3 */ -static bool PLy_procedure_is_trigger(Form_pg_proc procStruct) +static bool +PLy_procedure_is_trigger(Form_pg_proc procStruct) { return (procStruct->prorettype == TRIGGEROID || (procStruct->prorettype == OPAQUEOID && @@ -365,7 +366,7 @@ PLy_current_execution_context(void) static PLyExecutionContext * PLy_push_execution_context(void) { - PLyExecutionContext *context = PLy_malloc(sizeof(PLyExecutionContext)); + PLyExecutionContext *context = PLy_malloc(sizeof(PLyExecutionContext)); context->curr_proc = NULL; context->scratch_ctx = AllocSetContextCreate(TopTransactionContext, @@ -381,7 +382,7 @@ PLy_push_execution_context(void) static void PLy_pop_execution_context(void) { - PLyExecutionContext *context = PLy_execution_contexts; + PLyExecutionContext *context = PLy_execution_contexts; if (context == NULL) elog(ERROR, "no Python function is currently executing"); diff --git a/src/pl/plpython/plpy_main.h b/src/pl/plpython/plpy_main.h index cb214bf83c7..b13e2c21a11 100644 --- a/src/pl/plpython/plpy_main.h +++ b/src/pl/plpython/plpy_main.h @@ -17,12 +17,12 @@ extern PyObject *PLy_interp_globals; */ typedef struct PLyExecutionContext { - PLyProcedure *curr_proc; /* the currently executing procedure */ - MemoryContext scratch_ctx; /* a context for things like type I/O */ + PLyProcedure *curr_proc; /* the currently executing procedure */ + MemoryContext scratch_ctx; /* a context for things like type I/O */ struct PLyExecutionContext *next; /* previous stack level */ } PLyExecutionContext; /* Get the current execution context */ extern PLyExecutionContext *PLy_current_execution_context(void); -#endif /* PLPY_MAIN_H */ +#endif /* PLPY_MAIN_H */ diff --git a/src/pl/plpython/plpy_planobject.h b/src/pl/plpython/plpy_planobject.h index febc5c25ef6..7a89ffc2c18 100644 --- a/src/pl/plpython/plpy_planobject.h +++ b/src/pl/plpython/plpy_planobject.h @@ -23,4 +23,4 @@ extern void PLy_plan_init_type(void); extern PyObject *PLy_plan_new(void); extern bool is_PLyPlanObject(PyObject *ob); -#endif /* PLPY_PLANOBJECT_H */ +#endif /* PLPY_PLANOBJECT_H */ diff --git a/src/pl/plpython/plpy_plpymodule.c b/src/pl/plpython/plpy_plpymodule.c index bc0b9e6f842..37ea2a490d9 100644 --- a/src/pl/plpython/plpy_plpymodule.c +++ b/src/pl/plpython/plpy_plpymodule.c @@ -21,7 +21,7 @@ #include "plpy_subxactobject.h" -HTAB *PLy_spi_exceptions = NULL; +HTAB *PLy_spi_exceptions = NULL; static void PLy_add_exceptions(PyObject *plpy); @@ -137,7 +137,7 @@ PyInit_plpy(void) return m; } -#endif /* PY_MAJOR_VERSION >= 3 */ +#endif /* PY_MAJOR_VERSION >= 3 */ void PLy_init_plpy(void) @@ -145,6 +145,7 @@ PLy_init_plpy(void) PyObject *main_mod, *main_dict, *plpy_mod; + #if PY_MAJOR_VERSION < 3 PyObject *plpy; #endif diff --git a/src/pl/plpython/plpy_plpymodule.h b/src/pl/plpython/plpy_plpymodule.h index 930ecfd1b17..ee089b78a16 100644 --- a/src/pl/plpython/plpy_plpymodule.h +++ b/src/pl/plpython/plpy_plpymodule.h @@ -16,4 +16,4 @@ PyMODINIT_FUNC PyInit_plpy(void); #endif extern void PLy_init_plpy(void); -#endif /* PLPY_PLPYMODULE_H */ +#endif /* PLPY_PLPYMODULE_H */ diff --git a/src/pl/plpython/plpy_procedure.h b/src/pl/plpython/plpy_procedure.h index c7405e064ec..40a0314cdfb 100644 --- a/src/pl/plpython/plpy_procedure.h +++ b/src/pl/plpython/plpy_procedure.h @@ -45,4 +45,4 @@ extern PLyProcedure *PLy_procedure_get(Oid fn_oid, bool is_trigger); extern void PLy_procedure_compile(PLyProcedure *proc, const char *src); extern void PLy_procedure_delete(PLyProcedure *proc); -#endif /* PLPY_PROCEDURE_H */ +#endif /* PLPY_PROCEDURE_H */ diff --git a/src/pl/plpython/plpy_resultobject.c b/src/pl/plpython/plpy_resultobject.c index deaddb7980f..6b01e717c47 100644 --- a/src/pl/plpython/plpy_resultobject.c +++ b/src/pl/plpython/plpy_resultobject.c @@ -24,7 +24,7 @@ static PyObject *PLy_result_slice(PyObject *arg, Py_ssize_t lidx, Py_ssize_t hid static int PLy_result_ass_item(PyObject *arg, Py_ssize_t idx, PyObject *item); static int PLy_result_ass_slice(PyObject *rg, Py_ssize_t lidx, Py_ssize_t hidx, PyObject *slice); static PyObject *PLy_result_subscript(PyObject *arg, PyObject *item); -static int PLy_result_ass_subscript(PyObject* self, PyObject* item, PyObject* value); +static int PLy_result_ass_subscript(PyObject *self, PyObject *item, PyObject *value); static char PLy_result_doc[] = { "Results of a PostgreSQL query" @@ -263,7 +263,7 @@ PLy_result_ass_slice(PyObject *arg, Py_ssize_t lidx, Py_ssize_t hidx, PyObject * static PyObject * PLy_result_subscript(PyObject *arg, PyObject *item) { - PLyResultObject *ob = (PLyResultObject *) arg; + PLyResultObject *ob = (PLyResultObject *) arg; return PyObject_GetItem(ob->rows, item); } @@ -271,7 +271,7 @@ PLy_result_subscript(PyObject *arg, PyObject *item) static int PLy_result_ass_subscript(PyObject *arg, PyObject *item, PyObject *value) { - PLyResultObject *ob = (PLyResultObject *) arg; + PLyResultObject *ob = (PLyResultObject *) arg; return PyObject_SetItem(ob->rows, item, value); } diff --git a/src/pl/plpython/plpy_resultobject.h b/src/pl/plpython/plpy_resultobject.h index c5ba9998874..314510c40ff 100644 --- a/src/pl/plpython/plpy_resultobject.h +++ b/src/pl/plpython/plpy_resultobject.h @@ -13,7 +13,8 @@ typedef struct PLyResultObject PyObject_HEAD /* HeapTuple *tuples; */ PyObject *nrows; /* number of rows returned by query */ - PyObject *rows; /* data rows, or empty list if no data returned */ + PyObject *rows; /* data rows, or empty list if no data + * returned */ PyObject *status; /* query status, SPI_OK_*, or SPI_ERR_* */ TupleDesc tupdesc; } PLyResultObject; @@ -21,4 +22,4 @@ typedef struct PLyResultObject extern void PLy_result_init_type(void); extern PyObject *PLy_result_new(void); -#endif /* PLPY_RESULTOBJECT_H */ +#endif /* PLPY_RESULTOBJECT_H */ diff --git a/src/pl/plpython/plpy_spi.c b/src/pl/plpython/plpy_spi.c index 4bc3d96d589..00156e6658e 100644 --- a/src/pl/plpython/plpy_spi.c +++ b/src/pl/plpython/plpy_spi.c @@ -350,7 +350,7 @@ PLy_spi_execute_query(char *query, long limit) PG_TRY(); { - PLyExecutionContext *exec_ctx = PLy_current_execution_context(); + PLyExecutionContext *exec_ctx = PLy_current_execution_context(); pg_verifymbstr(query, strlen(query), false); rv = SPI_execute(query, exec_ctx->curr_proc->fn_readonly, limit); @@ -456,22 +456,22 @@ PLy_spi_execute_fetch_result(SPITupleTable *tuptable, int rows, int status) * * Usage: * - * MemoryContext oldcontext = CurrentMemoryContext; - * ResourceOwner oldowner = CurrentResourceOwner; + * MemoryContext oldcontext = CurrentMemoryContext; + * ResourceOwner oldowner = CurrentResourceOwner; * - * PLy_spi_subtransaction_begin(oldcontext, oldowner); - * PG_TRY(); - * { - * <call SPI functions> - * PLy_spi_subtransaction_commit(oldcontext, oldowner); - * } - * PG_CATCH(); - * { - * <do cleanup> - * PLy_spi_subtransaction_abort(oldcontext, oldowner); - * return NULL; - * } - * PG_END_TRY(); + * PLy_spi_subtransaction_begin(oldcontext, oldowner); + * PG_TRY(); + * { + * <call SPI functions> + * PLy_spi_subtransaction_commit(oldcontext, oldowner); + * } + * PG_CATCH(); + * { + * <do cleanup> + * PLy_spi_subtransaction_abort(oldcontext, oldowner); + * return NULL; + * } + * PG_END_TRY(); * * These utilities take care of restoring connection to the SPI manager and * setting a Python exception in case of an abort. @@ -493,8 +493,8 @@ PLy_spi_subtransaction_commit(MemoryContext oldcontext, ResourceOwner oldowner) CurrentResourceOwner = oldowner; /* - * AtEOSubXact_SPI() should not have popped any SPI context, but just - * in case it did, make sure we remain connected. + * AtEOSubXact_SPI() should not have popped any SPI context, but just in + * case it did, make sure we remain connected. */ SPI_restore_connection(); } @@ -517,8 +517,8 @@ PLy_spi_subtransaction_abort(MemoryContext oldcontext, ResourceOwner oldowner) CurrentResourceOwner = oldowner; /* - * If AtEOSubXact_SPI() popped any SPI context of the subxact, it will have - * left us in a disconnected state. We need this hack to return to + * If AtEOSubXact_SPI() popped any SPI context of the subxact, it will + * have left us in a disconnected state. We need this hack to return to * connected state. */ SPI_restore_connection(); diff --git a/src/pl/plpython/plpy_spi.h b/src/pl/plpython/plpy_spi.h index f8d31638ec8..b0427947ef4 100644 --- a/src/pl/plpython/plpy_spi.h +++ b/src/pl/plpython/plpy_spi.h @@ -22,4 +22,4 @@ extern void PLy_spi_subtransaction_begin(MemoryContext oldcontext, ResourceOwner extern void PLy_spi_subtransaction_commit(MemoryContext oldcontext, ResourceOwner oldowner); extern void PLy_spi_subtransaction_abort(MemoryContext oldcontext, ResourceOwner oldowner); -#endif /* PLPY_SPI_H */ +#endif /* PLPY_SPI_H */ diff --git a/src/pl/plpython/plpy_subxactobject.c b/src/pl/plpython/plpy_subxactobject.c index 9feeddb7231..2e7ec4fdab4 100644 --- a/src/pl/plpython/plpy_subxactobject.c +++ b/src/pl/plpython/plpy_subxactobject.c @@ -16,7 +16,7 @@ #include "plpy_elog.h" -List *explicit_subtransactions = NIL; +List *explicit_subtransactions = NIL; static void PLy_subtransaction_dealloc(PyObject *subxact); diff --git a/src/pl/plpython/plpy_subxactobject.h b/src/pl/plpython/plpy_subxactobject.h index 7e3002fc2fd..b8591c7bf07 100644 --- a/src/pl/plpython/plpy_subxactobject.h +++ b/src/pl/plpython/plpy_subxactobject.h @@ -26,4 +26,4 @@ typedef struct PLySubtransactionData extern void PLy_subtransaction_init_type(void); extern PyObject *PLy_subtransaction_new(PyObject *self, PyObject *unused); -#endif /* PLPY_SUBXACTOBJECT */ +#endif /* PLPY_SUBXACTOBJECT */ diff --git a/src/pl/plpython/plpy_typeio.c b/src/pl/plpython/plpy_typeio.c index c5f6c4e5a3e..2cc7bbbd4de 100644 --- a/src/pl/plpython/plpy_typeio.c +++ b/src/pl/plpython/plpy_typeio.c @@ -293,8 +293,8 @@ PLyDict_FromTuple(PLyTypeInfo *info, HeapTuple tuple, TupleDesc desc) PG_TRY(); { /* - * Do the work in the scratch context to avoid leaking memory from - * the datatype output function calls. + * Do the work in the scratch context to avoid leaking memory from the + * datatype output function calls. */ MemoryContextSwitchTo(exec_ctx->scratch_ctx); for (i = 0; i < info->in.r.natts; i++) @@ -341,7 +341,7 @@ PLyDict_FromTuple(PLyTypeInfo *info, HeapTuple tuple, TupleDesc desc) Datum PLyObject_ToCompositeDatum(PLyTypeInfo *info, TupleDesc desc, PyObject *plrv) { - Datum datum; + Datum datum; if (PyString_Check(plrv) || PyUnicode_Check(plrv)) datum = PLyString_ToComposite(info, desc, plrv); diff --git a/src/pl/plpython/plpy_typeio.h b/src/pl/plpython/plpy_typeio.h index 11532b8c201..d2dfa66e0b2 100644 --- a/src/pl/plpython/plpy_typeio.h +++ b/src/pl/plpython/plpy_typeio.h @@ -104,4 +104,4 @@ extern Datum PLyObject_ToCompositeDatum(PLyTypeInfo *info, TupleDesc desc, PyObj /* conversion from heap tuples to Python dictionaries */ extern PyObject *PLyDict_FromTuple(PLyTypeInfo *info, HeapTuple tuple, TupleDesc desc); -#endif /* PLPY_TYPEIO_H */ +#endif /* PLPY_TYPEIO_H */ diff --git a/src/pl/plpython/plpy_util.c b/src/pl/plpython/plpy_util.c index 414b9d5445a..9a4901ecb2f 100644 --- a/src/pl/plpython/plpy_util.c +++ b/src/pl/plpython/plpy_util.c @@ -122,4 +122,5 @@ PLyUnicode_FromString(const char *s) return o; } + #endif /* PY_MAJOR_VERSION >= 3 */ diff --git a/src/pl/plpython/plpy_util.h b/src/pl/plpython/plpy_util.h index 9b9eca0050c..f93e8379fb2 100644 --- a/src/pl/plpython/plpy_util.h +++ b/src/pl/plpython/plpy_util.h @@ -18,4 +18,4 @@ extern char *PLyUnicode_AsString(PyObject *unicode); extern PyObject *PLyUnicode_FromString(const char *s); #endif -#endif /* PLPY_UTIL_H */ +#endif /* PLPY_UTIL_H */ diff --git a/src/pl/plpython/plpython.h b/src/pl/plpython/plpython.h index 15ec85e8057..e788cd9a897 100644 --- a/src/pl/plpython/plpython.h +++ b/src/pl/plpython/plpython.h @@ -132,11 +132,11 @@ typedef int Py_ssize_t; #undef vsnprintf #endif #ifdef __GNUC__ -#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__) -#define snprintf(...) pg_snprintf(__VA_ARGS__) +#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__) +#define snprintf(...) pg_snprintf(__VA_ARGS__) #else -#define vsnprintf pg_vsnprintf -#define snprintf pg_snprintf +#define vsnprintf pg_vsnprintf +#define snprintf pg_snprintf #endif /* __GNUC__ */ #endif /* USE_REPL_SNPRINTF */ |