1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Run pgindent on 9.2 source tree in preparation for first 9.3

commit-fest.
This commit is contained in:
Bruce Momjian
2012-06-10 15:20:04 -04:00
parent 60801944fa
commit 927d61eeff
494 changed files with 7343 additions and 7046 deletions

View File

@@ -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;
}

View File

@@ -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 */

View File

@@ -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;

View File

@@ -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 */

View File

@@ -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 &&

View File

@@ -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 */

View File

@@ -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");

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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

View File

@@ -16,4 +16,4 @@ PyMODINIT_FUNC PyInit_plpy(void);
#endif
extern void PLy_init_plpy(void);
#endif /* PLPY_PLPYMODULE_H */
#endif /* PLPY_PLPYMODULE_H */

View File

@@ -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 */

View File

@@ -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);
}

View File

@@ -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 */

View File

@@ -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();

View File

@@ -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 */

View File

@@ -16,7 +16,7 @@
#include "plpy_elog.h"
List *explicit_subtransactions = NIL;
List *explicit_subtransactions = NIL;
static void PLy_subtransaction_dealloc(PyObject *subxact);

View File

@@ -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 */

View File

@@ -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);

View File

@@ -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 */

View File

@@ -122,4 +122,5 @@ PLyUnicode_FromString(const char *s)
return o;
}
#endif /* PY_MAJOR_VERSION >= 3 */

View File

@@ -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 */

View File

@@ -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 */