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

8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list

provided by Andrew.
This commit is contained in:
Bruce Momjian
2009-06-11 14:49:15 +00:00
parent 4e86efb4e5
commit d747140279
654 changed files with 11900 additions and 11387 deletions

View File

@@ -1,7 +1,7 @@
/**********************************************************************
* plperl.c - perl as a procedural language for PostgreSQL
*
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.149 2009/06/06 03:45:36 tgl Exp $
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.150 2009/06/11 14:49:14 momjian Exp $
*
**********************************************************************/
@@ -199,7 +199,7 @@ _PG_init(void)
pg_bindtextdomain(TEXTDOMAIN);
DefineCustomBoolVariable("plperl.use_strict",
gettext_noop("If true, trusted and untrusted Perl code will be compiled in strict mode."),
gettext_noop("If true, trusted and untrusted Perl code will be compiled in strict mode."),
NULL,
&plperl_use_strict,
false,
@@ -273,7 +273,7 @@ _PG_init(void)
#define SAFE_MODULE \
"require Safe; $Safe::VERSION"
/*
/*
* The temporary enabling of the caller opcode here is to work around a
* bug in perl 5.10, which unkindly changed the way its Safe.pm works, without
* notice. It is quite safe, as caller is informational only, and in any case
@@ -398,7 +398,7 @@ plperl_init_interp(void)
static char *embedding[3] = {
"", "-e", PERLBOOT
};
int nargs = 3;
int nargs = 3;
#ifdef WIN32
@@ -455,7 +455,7 @@ plperl_init_interp(void)
/* only call this the first time through, as per perlembed man page */
if (interp_state == INTERP_NONE)
{
char *dummy_env[1] = { NULL };
char *dummy_env[1] = {NULL};
PERL_SYS_INIT3(&nargs, (char ***) &embedding, (char ***) &dummy_env);
}
@@ -548,17 +548,16 @@ plperl_safe_init(void)
eval_pv(SAFE_OK, FALSE);
if (GetDatabaseEncoding() == PG_UTF8)
{
/*
* Fill in just enough information to set up this perl
* function in the safe container and call it.
* For some reason not entirely clear, it prevents errors that
* can arise from the regex code later trying to load
* utf8 modules.
/*
* Fill in just enough information to set up this perl function in
* the safe container and call it. For some reason not entirely
* clear, it prevents errors that can arise from the regex code
* later trying to load utf8 modules.
*/
plperl_proc_desc desc;
plperl_proc_desc desc;
FunctionCallInfoData fcinfo;
SV *ret;
SV *func;
SV *ret;
SV *func;
/* make sure we don't call ourselves recursively */
plperl_safe_init_done = true;
@@ -576,7 +575,7 @@ plperl_safe_init(void)
fcinfo.arg[0] = CStringGetTextDatum("a");
fcinfo.argnull[0] = false;
/* and make the call */
ret = plperl_call_perl_func(&desc, &fcinfo);
}
@@ -1457,7 +1456,7 @@ plperl_trigger_handler(PG_FUNCTION_ARGS)
{
ereport(WARNING,
(errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
errmsg("ignoring modified row in DELETE trigger")));
errmsg("ignoring modified row in DELETE trigger")));
trv = NULL;
}
}
@@ -1465,8 +1464,8 @@ plperl_trigger_handler(PG_FUNCTION_ARGS)
{
ereport(ERROR,
(errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
errmsg("result of PL/Perl trigger function must be undef, "
"\"SKIP\", or \"MODIFY\"")));
errmsg("result of PL/Perl trigger function must be undef, "
"\"SKIP\", or \"MODIFY\"")));
trv = NULL;
}
retval = PointerGetDatum(trv);
@@ -1979,7 +1978,7 @@ plperl_return_next(SV *sv)
if (prodesc->fn_retistuple)
{
HeapTuple tuple;
HeapTuple tuple;
tuple = plperl_build_tuple_result((HV *) SvRV(sv),
current_call_data->attinmeta);

View File

@@ -1,5 +1,5 @@
/*
* $PostgreSQL: pgsql/src/pl/plperl/spi_internal.c,v 1.9 2008/05/17 01:28:25 adunstan Exp $
* $PostgreSQL: pgsql/src/pl/plperl/spi_internal.c,v 1.10 2009/06/11 14:49:14 momjian Exp $
*
*
* This kludge is necessary because of the conflicting

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.135 2009/04/19 18:52:57 tgl Exp $
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.136 2009/06/11 14:49:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -415,8 +415,8 @@ do_compile(FunctionCallInfo fcinfo,
argdtype->ttype != PLPGSQL_TTYPE_ROW)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("PL/pgSQL functions cannot accept type %s",
format_type_be(argtypeid))));
errmsg("PL/pgSQL functions cannot accept type %s",
format_type_be(argtypeid))));
/* Build variable and add to datum list */
argvariable = plpgsql_build_variable(buf, 0,
@@ -534,8 +534,8 @@ do_compile(FunctionCallInfo fcinfo,
else
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("PL/pgSQL functions cannot return type %s",
format_type_be(rettypeid))));
errmsg("PL/pgSQL functions cannot return type %s",
format_type_be(rettypeid))));
}
if (typeStruct->typrelid != InvalidOid ||
@@ -787,8 +787,8 @@ plpgsql_parse_word(const char *word)
plpgsql_convert_ident(word, cp, 1);
/*
* Recognize tg_argv when compiling triggers
* (XXX this sucks, it should be a regular variable in the namestack)
* Recognize tg_argv when compiling triggers (XXX this sucks, it should be
* a regular variable in the namestack)
*/
if (plpgsql_curr_compile->fn_is_trigger)
{
@@ -977,8 +977,8 @@ plpgsql_parse_tripword(const char *word)
plpgsql_convert_ident(word, cp, 3);
/*
* Do a lookup on the compiler's namestack.
* Must find a qualified reference.
* Do a lookup on the compiler's namestack. Must find a qualified
* reference.
*/
ns = plpgsql_ns_lookup(cp[0], cp[1], cp[2], &nnames);
if (ns == NULL || nnames != 2)
@@ -1168,8 +1168,8 @@ plpgsql_parse_dblwordtype(char *word)
pfree(cp[2]);
/*
* Do a lookup on the compiler's namestack. Ensure we scan all levels.
* We don't need to check number of names matched, because we will only
* Do a lookup on the compiler's namestack. Ensure we scan all levels. We
* don't need to check number of names matched, because we will only
* consider scalar variables.
*/
old_nsstate = plpgsql_ns_setlocal(false);
@@ -1755,8 +1755,8 @@ build_datatype(HeapTuple typeTup, int32 typmod)
}
/*
* plpgsql_recognize_err_condition
* Check condition name and translate it to SQLSTATE.
* plpgsql_recognize_err_condition
* Check condition name and translate it to SQLSTATE.
*
* Note: there are some cases where the same condition name has multiple
* entries in the table. We arbitrarily return the first match.

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.242 2009/06/04 18:33:07 tgl Exp $
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.243 2009/06/11 14:49:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -52,7 +52,7 @@ typedef struct
* creates its own "eval_econtext" ExprContext within this estate for
* per-evaluation workspace. eval_econtext is freed at normal function exit,
* and the EState is freed at transaction end (in case of error, we assume
* that the abort mechanisms clean it all up). Furthermore, any exception
* that the abort mechanisms clean it all up). Furthermore, any exception
* block within a function has to have its own eval_econtext separate from
* the containing function's, so that we can clean up ExprContext callbacks
* properly at subtransaction exit. We maintain a stack that tracks the
@@ -65,9 +65,9 @@ typedef struct
*/
typedef struct SimpleEcontextStackEntry
{
ExprContext *stack_econtext; /* a stacked econtext */
SubTransactionId xact_subxid; /* ID for current subxact */
struct SimpleEcontextStackEntry *next; /* next stack entry up */
ExprContext *stack_econtext; /* a stacked econtext */
SubTransactionId xact_subxid; /* ID for current subxact */
struct SimpleEcontextStackEntry *next; /* next stack entry up */
} SimpleEcontextStackEntry;
static EState *simple_eval_estate = NULL;
@@ -94,7 +94,7 @@ static int exec_stmt_getdiag(PLpgSQL_execstate *estate,
static int exec_stmt_if(PLpgSQL_execstate *estate,
PLpgSQL_stmt_if *stmt);
static int exec_stmt_case(PLpgSQL_execstate *estate,
PLpgSQL_stmt_case *stmt);
PLpgSQL_stmt_case *stmt);
static int exec_stmt_loop(PLpgSQL_execstate *estate,
PLpgSQL_stmt_loop *stmt);
static int exec_stmt_while(PLpgSQL_execstate *estate,
@@ -168,7 +168,7 @@ static Datum exec_eval_expr(PLpgSQL_execstate *estate,
static int exec_run_select(PLpgSQL_execstate *estate,
PLpgSQL_expr *expr, long maxtuples, Portal *portalP);
static int exec_for_query(PLpgSQL_execstate *estate, PLpgSQL_stmt_forq *stmt,
Portal portal, bool prefetch_ok);
Portal portal, bool prefetch_ok);
static void eval_expr_params(PLpgSQL_execstate *estate,
PLpgSQL_expr *expr, Datum **p_values, char **p_nulls);
static void exec_move_row(PLpgSQL_execstate *estate,
@@ -197,10 +197,10 @@ static void plpgsql_destroy_econtext(PLpgSQL_execstate *estate);
static void free_var(PLpgSQL_var *var);
static void assign_text_var(PLpgSQL_var *var, const char *str);
static PreparedParamsData *exec_eval_using_params(PLpgSQL_execstate *estate,
List *params);
List *params);
static void free_params_data(PreparedParamsData *ppd);
static Portal exec_dynquery_with_params(PLpgSQL_execstate *estate,
PLpgSQL_expr *query, List *params);
PLpgSQL_expr *query, List *params);
/* ----------
@@ -414,7 +414,7 @@ plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo)
* sure it is labeled with the caller-supplied tuple type.
*/
estate.retval =
PointerGetDatum(SPI_returntuple((HeapTuple)DatumGetPointer(estate.retval),
PointerGetDatum(SPI_returntuple((HeapTuple) DatumGetPointer(estate.retval),
tupdesc));
}
else
@@ -764,7 +764,10 @@ plpgsql_exec_error_callback(void *arg)
*/
if (estate->err_stmt != NULL)
{
/* translator: last %s is a phrase such as "during statement block local variable initialization" */
/*
* translator: last %s is a phrase such as "during statement block
* local variable initialization"
*/
errcontext("PL/pgSQL function \"%s\" line %d %s",
estate->err_func->fn_name,
estate->err_stmt->lineno,
@@ -772,7 +775,10 @@ plpgsql_exec_error_callback(void *arg)
}
else
{
/* translator: last %s is a phrase such as "while storing call arguments into local variables" */
/*
* translator: last %s is a phrase such as "while storing call
* arguments into local variables"
*/
errcontext("PL/pgSQL function \"%s\" %s",
estate->err_func->fn_name,
_(estate->err_text));
@@ -1032,8 +1038,8 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
CurrentResourceOwner = oldowner;
/*
* Revert to outer eval_econtext. (The inner one was automatically
* cleaned up during subxact exit.)
* Revert to outer eval_econtext. (The inner one was
* automatically cleaned up during subxact exit.)
*/
estate->eval_econtext = old_eval_econtext;
@@ -1145,6 +1151,7 @@ exec_stmt_block(PLpgSQL_execstate *estate, PLpgSQL_stmt_block *block)
return rc;
case PLPGSQL_RC_EXIT:
/*
* This is intentionally different from the handling of RC_EXIT
* for loops: to match a block, we require a match by label.
@@ -1451,18 +1458,17 @@ exec_stmt_case(PLpgSQL_execstate *estate, PLpgSQL_stmt_case *stmt)
if (stmt->t_expr != NULL)
{
/* simple case */
Datum t_val;
Oid t_oid;
Datum t_val;
Oid t_oid;
t_val = exec_eval_expr(estate, stmt->t_expr, &isnull, &t_oid);
t_var = (PLpgSQL_var *) estate->datums[stmt->t_varno];
/*
* When expected datatype is different from real, change it.
* Note that what we're modifying here is an execution copy
* of the datum, so this doesn't affect the originally stored
* function parse tree.
* When expected datatype is different from real, change it. Note that
* what we're modifying here is an execution copy of the datum, so
* this doesn't affect the originally stored function parse tree.
*/
if (t_var->datatype->typoid != t_oid)
t_var->datatype = plpgsql_build_datatype(t_oid, -1);
@@ -1481,7 +1487,7 @@ exec_stmt_case(PLpgSQL_execstate *estate, PLpgSQL_stmt_case *stmt)
foreach(l, stmt->case_when_list)
{
PLpgSQL_case_when *cwt = (PLpgSQL_case_when *) lfirst(l);
bool value;
bool value;
value = exec_eval_boolean(estate, cwt->expr, &isnull);
exec_eval_cleanup(estate);
@@ -1904,7 +1910,7 @@ exec_stmt_forc(PLpgSQL_execstate *estate, PLpgSQL_stmt_forc *stmt)
if (curvar->cursor_explicit_argrow < 0)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("arguments given for cursor without arguments")));
errmsg("arguments given for cursor without arguments")));
memset(&set_args, 0, sizeof(set_args));
set_args.cmd_type = PLPGSQL_STMT_EXECSQL;
@@ -2069,7 +2075,7 @@ exec_stmt_return(PLpgSQL_execstate *estate, PLpgSQL_stmt_return *stmt)
estate->retval =
PointerGetDatum(make_tuple_from_row(estate, row,
row->rowtupdesc));
if (DatumGetPointer(estate->retval) == NULL) /* should not happen */
if (DatumGetPointer(estate->retval) == NULL) /* should not happen */
elog(ERROR, "row not compatible with its own tupdesc");
estate->rettupdesc = row->rowtupdesc;
estate->retisnull = false;
@@ -2132,11 +2138,11 @@ static int
exec_stmt_return_next(PLpgSQL_execstate *estate,
PLpgSQL_stmt_return_next *stmt)
{
TupleDesc tupdesc;
int natts;
MemoryContext oldcxt;
HeapTuple tuple = NULL;
bool free_tuple = false;
TupleDesc tupdesc;
int natts;
MemoryContext oldcxt;
HeapTuple tuple = NULL;
bool free_tuple = false;
if (!estate->retisset)
ereport(ERROR,
@@ -2190,10 +2196,10 @@ exec_stmt_return_next(PLpgSQL_execstate *estate,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("record \"%s\" is not assigned yet",
rec->refname),
errdetail("The tuple structure of a not-yet-assigned"
" record is indeterminate.")));
errdetail("The tuple structure of a not-yet-assigned"
" record is indeterminate.")));
validate_tupdesc_compat(tupdesc, rec->tupdesc,
"wrong record type supplied in RETURN NEXT");
"wrong record type supplied in RETURN NEXT");
tuple = rec->tup;
}
break;
@@ -2277,7 +2283,7 @@ exec_stmt_return_query(PLpgSQL_execstate *estate,
PLpgSQL_stmt_return_query *stmt)
{
Portal portal;
uint32 processed = 0;
uint32 processed = 0;
if (!estate->retisset)
ereport(ERROR,
@@ -2301,7 +2307,7 @@ exec_stmt_return_query(PLpgSQL_execstate *estate,
}
validate_tupdesc_compat(estate->rettupdesc, portal->tupDesc,
"structure of query does not match function result type");
"structure of query does not match function result type");
while (true)
{
@@ -2418,10 +2424,10 @@ exec_stmt_raise(PLpgSQL_execstate *estate, PLpgSQL_stmt_raise *stmt)
if (current_param == NULL)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("too few parameters specified for RAISE")));
errmsg("too few parameters specified for RAISE")));
paramvalue = exec_eval_expr(estate,
(PLpgSQL_expr *) lfirst(current_param),
(PLpgSQL_expr *) lfirst(current_param),
&paramisnull,
&paramtypeid);
@@ -2804,6 +2810,7 @@ exec_stmt_execsql(PLpgSQL_execstate *estate,
case SPI_OK_REWRITTEN:
Assert(!stmt->mod_stmt);
/*
* The command was rewritten into another kind of command. It's
* not clear what FOUND would mean in that case (and SPI doesn't
@@ -2975,7 +2982,7 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate,
if (*ptr == 'S' || *ptr == 's')
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("EXECUTE of SELECT ... INTO is not implemented")));
errmsg("EXECUTE of SELECT ... INTO is not implemented")));
break;
}
@@ -3604,8 +3611,8 @@ exec_assign_value(PLpgSQL_execstate *estate,
/*
* Get the number of the records field to change and the
* number of attributes in the tuple. Note: disallow
* system column names because the code below won't cope.
* number of attributes in the tuple. Note: disallow system
* column names because the code below won't cope.
*/
fno = SPI_fnumber(rec->tupdesc, recfield->fieldname);
if (fno <= 0)
@@ -4186,8 +4193,8 @@ exec_for_query(PLpgSQL_execstate *estate, PLpgSQL_stmt_forq *stmt,
elog(ERROR, "unsupported target");
/*
* Fetch the initial tuple(s). If prefetching is allowed then we grab
* a few more rows to avoid multiple trips through executor startup
* Fetch the initial tuple(s). If prefetching is allowed then we grab a
* few more rows to avoid multiple trips through executor startup
* overhead.
*/
SPI_cursor_fetch(portal, true, prefetch_ok ? 10 : 1);
@@ -4195,8 +4202,8 @@ exec_for_query(PLpgSQL_execstate *estate, PLpgSQL_stmt_forq *stmt,
n = SPI_processed;
/*
* If the query didn't return any rows, set the target to NULL and
* fall through with found = false.
* If the query didn't return any rows, set the target to NULL and fall
* through with found = false.
*/
if (n <= 0)
exec_move_row(estate, rec, row, NULL, tuptab->tupdesc);
@@ -4567,12 +4574,13 @@ exec_move_row(PLpgSQL_execstate *estate,
* attributes of the tuple to the variables the row points to.
*
* NOTE: this code used to demand row->nfields ==
* HeapTupleHeaderGetNatts(tup->t_data), but that's wrong. The tuple might
* have more fields than we expected if it's from an inheritance-child
* table of the current table, or it might have fewer if the table has had
* columns added by ALTER TABLE. Ignore extra columns and assume NULL for
* missing columns, the same as heap_getattr would do. We also have to
* skip over dropped columns in either the source or destination.
* HeapTupleHeaderGetNatts(tup->t_data), but that's wrong. The tuple
* might have more fields than we expected if it's from an
* inheritance-child table of the current table, or it might have fewer if
* the table has had columns added by ALTER TABLE. Ignore extra columns
* and assume NULL for missing columns, the same as heap_getattr would do.
* We also have to skip over dropped columns in either the source or
* destination.
*
* If we have no tuple data at all, we'll assign NULL to all columns of
* the row variable.
@@ -5118,7 +5126,7 @@ exec_simple_check_plan(PLpgSQL_expr *expr)
static void
validate_tupdesc_compat(TupleDesc expected, TupleDesc returned, const char *msg)
{
int i;
int i;
const char *dropped_column_type = gettext_noop("N/A (dropped column)");
if (!expected || !returned)
@@ -5139,15 +5147,15 @@ validate_tupdesc_compat(TupleDesc expected, TupleDesc returned, const char *msg)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("%s", _(msg)),
errdetail("Returned type %s does not match expected type "
"%s in column \"%s\".",
OidIsValid(returned->attrs[i]->atttypid) ?
format_type_be(returned->attrs[i]->atttypid) :
_(dropped_column_type),
OidIsValid(expected->attrs[i]->atttypid) ?
format_type_be(expected->attrs[i]->atttypid) :
_(dropped_column_type),
NameStr(expected->attrs[i]->attname))));
errdetail("Returned type %s does not match expected type "
"%s in column \"%s\".",
OidIsValid(returned->attrs[i]->atttypid) ?
format_type_be(returned->attrs[i]->atttypid) :
_(dropped_column_type),
OidIsValid(expected->attrs[i]->atttypid) ?
format_type_be(expected->attrs[i]->atttypid) :
_(dropped_column_type),
NameStr(expected->attrs[i]->attname))));
}
/* ----------
@@ -5343,7 +5351,7 @@ exec_eval_using_params(PLpgSQL_execstate *estate, List *params)
foreach(lc, params)
{
PLpgSQL_expr *param = (PLpgSQL_expr *) lfirst(lc);
bool isnull;
bool isnull;
ppd->values[i] = exec_eval_expr(estate, param,
&isnull,
@@ -5354,8 +5362,8 @@ exec_eval_using_params(PLpgSQL_execstate *estate, List *params)
/* pass-by-ref non null values must be copied into plpgsql context */
if (!isnull)
{
int16 typLen;
bool typByVal;
int16 typLen;
bool typByVal;
get_typlenbyval(ppd->types[i], &typLen, &typByVal);
if (!typByVal)
@@ -5379,7 +5387,7 @@ exec_eval_using_params(PLpgSQL_execstate *estate, List *params)
static void
free_params_data(PreparedParamsData *ppd)
{
int i;
int i;
for (i = 0; i < ppd->nargs; i++)
{
@@ -5409,8 +5417,8 @@ exec_dynquery_with_params(PLpgSQL_execstate *estate, PLpgSQL_expr *dynquery,
char *querystr;
/*
* Evaluate the string expression after the EXECUTE keyword. Its result
* is the querystring we have to execute.
* Evaluate the string expression after the EXECUTE keyword. Its result is
* the querystring we have to execute.
*/
query = exec_eval_expr(estate, dynquery, &isnull, &restype);
if (isnull)
@@ -5424,9 +5432,9 @@ exec_dynquery_with_params(PLpgSQL_execstate *estate, PLpgSQL_expr *dynquery,
exec_eval_cleanup(estate);
/*
* Open an implicit cursor for the query. We use SPI_cursor_open_with_args
* even when there are no params, because this avoids making and freeing
* one copy of the plan.
* Open an implicit cursor for the query. We use
* SPI_cursor_open_with_args even when there are no params, because this
* avoids making and freeing one copy of the plan.
*/
if (params)
{

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.78 2009/04/19 21:50:09 tgl Exp $
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.79 2009/06/11 14:49:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -228,7 +228,7 @@ plpgsql_ns_additem(int itemtype, int itemno, const char *name)
*
* Note that this only searches for variables, not labels.
*
* name1 must be non-NULL. Pass NULL for name2 and/or name3 if parsing a name
* name1 must be non-NULL. Pass NULL for name2 and/or name3 if parsing a name
* with fewer than three components.
*
* If names_used isn't NULL, *names_used receives the number of names
@@ -412,7 +412,7 @@ plpgsql_convert_ident(const char *s, char **output, int numidents)
if (*s != '"') /* should not happen if lexer checked */
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("unterminated \" in identifier: %s", sstart)));
errmsg("unterminated \" in identifier: %s", sstart)));
s++;
*cp = '\0';
/* Truncate to NAMEDATALEN */
@@ -722,7 +722,7 @@ dump_if(PLpgSQL_stmt_if *stmt)
static void
dump_case(PLpgSQL_stmt_case *stmt)
{
ListCell *l;
ListCell *l;
dump_ind();
printf("CASE %d ", stmt->t_varno);
@@ -828,7 +828,7 @@ static void
dump_forc(PLpgSQL_stmt_forc *stmt)
{
dump_ind();
printf("FORC %s ", stmt->rec->refname);
printf("FORC %s ", stmt->rec->refname);
printf("curvar=%d\n", stmt->curvar);
dump_indent += 2;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.112 2009/04/19 21:50:09 tgl Exp $
* $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.113 2009/06/11 14:49:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -405,7 +405,7 @@ typedef struct /* CASE statement */
int lineno;
PLpgSQL_expr *t_expr; /* test expression, or NULL if none */
int t_varno; /* var to store test expression value into */
List *case_when_list; /* List of PLpgSQL_case_when structs */
List *case_when_list; /* List of PLpgSQL_case_when structs */
bool have_else; /* flag needed because list could be empty */
List *else_stmts; /* List of statements */
} PLpgSQL_stmt_case;
@@ -588,7 +588,7 @@ typedef struct
typedef struct
{ /* RAISE statement option */
int opt_type;
int opt_type;
PLpgSQL_expr *expr;
} PLpgSQL_raise_option;
@@ -822,9 +822,9 @@ extern PLpgSQL_variable *plpgsql_build_variable(const char *refname, int lineno,
PLpgSQL_type *dtype,
bool add2namespace);
extern PLpgSQL_rec *plpgsql_build_record(const char *refname, int lineno,
bool add2namespace);
extern int plpgsql_recognize_err_condition(const char *condname,
bool allow_sqlstate);
bool add2namespace);
extern int plpgsql_recognize_err_condition(const char *condname,
bool allow_sqlstate);
extern PLpgSQL_condition *plpgsql_parse_err_condition(char *condname);
extern void plpgsql_adddatum(PLpgSQL_datum *new);
extern int plpgsql_add_initdatums(int **varnos);
@@ -871,7 +871,7 @@ extern void plpgsql_ns_push(const char *label);
extern void plpgsql_ns_pop(void);
extern void plpgsql_ns_additem(int itemtype, int itemno, const char *name);
extern PLpgSQL_nsitem *plpgsql_ns_lookup(const char *name1, const char *name2,
const char *name3, int *names_used);
const char *name3, int *names_used);
extern PLpgSQL_nsitem *plpgsql_ns_lookup_label(const char *name);
extern void plpgsql_ns_rename(char *oldname, char *newname);

View File

@@ -1,7 +1,7 @@
/**********************************************************************
* plpython.c - python as a procedural language for PostgreSQL
*
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.121 2009/06/04 18:33:08 tgl Exp $
* $PostgreSQL: pgsql/src/pl/plpython/plpython.c,v 1.122 2009/06/11 14:49:14 momjian Exp $
*
*********************************************************************
*/
@@ -87,19 +87,19 @@ typedef struct PLyDatumToOb
Oid typoid; /* The OID of the type */
Oid typioparam;
bool typbyval;
} PLyDatumToOb;
} PLyDatumToOb;
typedef struct PLyTupleToOb
{
PLyDatumToOb *atts;
int natts;
} PLyTupleToOb;
} PLyTupleToOb;
typedef union PLyTypeInput
{
PLyDatumToOb d;
PLyTupleToOb r;
} PLyTypeInput;
} PLyTypeInput;
/* convert PyObject to a Postgresql Datum or tuple.
* output from Python
@@ -110,19 +110,19 @@ typedef struct PLyObToDatum
Oid typoid; /* The OID of the type */
Oid typioparam;
bool typbyval;
} PLyObToDatum;
} PLyObToDatum;
typedef struct PLyObToTuple
{
PLyObToDatum *atts;
int natts;
} PLyObToTuple;
} PLyObToTuple;
typedef union PLyTypeOutput
{
PLyObToDatum d;
PLyObToTuple r;
} PLyTypeOutput;
} PLyTypeOutput;
/* all we need to move Postgresql data to Python objects,
* and vis versa
@@ -137,7 +137,7 @@ typedef struct PLyTypeInfo
* is_rowtype can be: -1 not known yet (initial state) 0 scalar datatype
* 1 rowtype 2 rowtype, but I/O functions not set up yet
*/
} PLyTypeInfo;
} PLyTypeInfo;
/* cached procedure data */
@@ -160,7 +160,7 @@ typedef struct PLyProcedure
PyObject *globals; /* data saved across calls, global scope */
PyObject *me; /* PyCObject containing pointer to this
* PLyProcedure */
} PLyProcedure;
} PLyProcedure;
/* Python objects */
@@ -172,16 +172,16 @@ typedef struct PLyPlanObject
Oid *types;
Datum *values;
PLyTypeInfo *args;
} PLyPlanObject;
} PLyPlanObject;
typedef struct PLyResultObject
{
PyObject_HEAD
/* HeapTuple *tuples; */
PyObject * nrows; /* number of rows returned by query */
PyObject *nrows; /* number of rows returned by query */
PyObject *rows; /* data rows, or None if no data returned */
PyObject *status; /* query status, SPI_OK_*, or SPI_ERR_* */
} PLyResultObject;
} PLyResultObject;
/* function declarations */
@@ -205,11 +205,14 @@ static void PLy_init_interp(void);
static void PLy_init_plpy(void);
/* call PyErr_SetString with a vprint interface and translation support */
static void PLy_exception_set(PyObject *, const char *,...)
static void
PLy_exception_set(PyObject *, const char *,...)
__attribute__((format(printf, 2, 3)));
/* same, with pluralized message */
static void PLy_exception_set_plural(PyObject *, const char *, const char *,
unsigned long n,...)
static void
PLy_exception_set_plural(PyObject *, const char *, const char *,
unsigned long n,...)
__attribute__((format(printf, 2, 5)))
__attribute__((format(printf, 3, 5)));
@@ -217,7 +220,8 @@ __attribute__((format(printf, 3, 5)));
static char *PLy_procedure_name(PLyProcedure *);
/* some utility functions */
static void PLy_elog(int, const char *,...)
static void
PLy_elog(int, const char *,...)
__attribute__((format(printf, 2, 3)));
static char *PLy_traceback(int *);
@@ -243,7 +247,7 @@ static PLyProcedure *PLy_procedure_get(FunctionCallInfo fcinfo,
Oid tgreloid);
static PLyProcedure *PLy_procedure_create(HeapTuple procTup, Oid tgreloid,
char *key);
char *key);
static void PLy_procedure_compile(PLyProcedure *, const char *);
static char *PLy_procedure_munge_source(const char *, const char *);
@@ -391,7 +395,7 @@ plpython_call_handler(PG_FUNCTION_ARGS)
* to take no arguments and return an argument of type trigger.
*/
static HeapTuple
PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure *proc)
{
HeapTuple rv = NULL;
PyObject *volatile plargs = NULL;
@@ -467,7 +471,7 @@ PLy_trigger_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
}
static HeapTuple
PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata,
PLy_modify_tuple(PLyProcedure *proc, PyObject *pltd, TriggerData *tdata,
HeapTuple otup)
{
PyObject *volatile plntup;
@@ -493,7 +497,7 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata,
PG_TRY();
{
if ((plntup = PyDict_GetItemString(pltd, "new")) == NULL)
ereport(ERROR,
ereport(ERROR,
(errmsg("TD[\"new\"] deleted, cannot modify row")));
if (!PyDict_Check(plntup))
ereport(ERROR,
@@ -603,7 +607,7 @@ PLy_modify_tuple(PLyProcedure * proc, PyObject * pltd, TriggerData *tdata,
}
static PyObject *
PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple *rv)
PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc, HeapTuple *rv)
{
TriggerData *tdata = (TriggerData *) fcinfo->context;
PyObject *pltname,
@@ -783,7 +787,7 @@ PLy_trigger_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc, HeapTuple *
/* function handler and friends */
static Datum
PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure *proc)
{
Datum rv;
PyObject *volatile plargs = NULL;
@@ -845,7 +849,7 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("returned object cannot be iterated"),
errdetail("PL/Python set-returning functions must return an iterable object.")));
errdetail("PL/Python set-returning functions must return an iterable object.")));
}
/* Fetch next from iterator */
@@ -891,7 +895,7 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
if (plrv != Py_None)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("PL/Python function with return type \"void\" did not return None")));
errmsg("PL/Python function with return type \"void\" did not return None")));
fcinfo->isnull = false;
rv = (Datum) 0;
@@ -964,7 +968,7 @@ PLy_function_handler(FunctionCallInfo fcinfo, PLyProcedure * proc)
}
static PyObject *
PLy_procedure_call(PLyProcedure * proc, char *kargs, PyObject * vargs)
PLy_procedure_call(PLyProcedure *proc, char *kargs, PyObject *vargs)
{
PyObject *rv;
@@ -994,7 +998,7 @@ PLy_procedure_call(PLyProcedure * proc, char *kargs, PyObject * vargs)
}
static PyObject *
PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc)
PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure *proc)
{
PyObject *volatile arg = NULL;
PyObject *volatile args = NULL;
@@ -1060,7 +1064,7 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc)
PLy_elog(ERROR, "PyList_SetItem() failed for PL/Python function \"%s\" while setting up arguments", proc->proname);
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 for PL/Python function \"%s\" while setting up arguments", proc->proname);
arg = NULL;
}
@@ -1079,7 +1083,7 @@ PLy_function_build_args(FunctionCallInfo fcinfo, PLyProcedure * proc)
static void
PLy_function_delete_args(PLyProcedure * proc)
PLy_function_delete_args(PLyProcedure *proc)
{
int i;
@@ -1149,9 +1153,9 @@ PLy_procedure_get(FunctionCallInfo fcinfo, Oid tgreloid)
{
/*
* Input/output conversion for trigger tuples. Use the result
* TypeInfo variable to store the tuple conversion info. We
* do this over again on each call to cover the possibility that
* the relation's tupdesc changed since the trigger was last called.
* TypeInfo variable to store the tuple conversion info. We do this
* over again on each call to cover the possibility that the
* relation's tupdesc changed since the trigger was last called.
* PLy_input_tuple_funcs and PLy_output_tuple_funcs are responsible
* for not doing repetitive work.
*/
@@ -1243,8 +1247,8 @@ PLy_procedure_create(HeapTuple procTup, Oid tgreloid, char *key)
else
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)
@@ -1264,19 +1268,19 @@ PLy_procedure_create(HeapTuple procTup, Oid tgreloid, char *key)
/*
* Now get information required for input conversion of the
* procedure's arguments. Note that we ignore output arguments
* here --- since we don't support returning record, and that was
* already checked above, there's no need to worry about multiple
* output arguments.
* procedure's arguments. Note that we ignore output arguments here
* --- since we don't support returning record, and that was already
* checked above, there's no need to worry about multiple output
* arguments.
*/
if (procStruct->pronargs)
{
Oid *types;
char **names,
*modes;
int i,
pos,
total;
Oid *types;
char **names,
*modes;
int i,
pos,
total;
/* extract argument type info from the pg_proc tuple */
total = get_func_arg_info(procTup, &types, &names, &modes);
@@ -1322,7 +1326,7 @@ PLy_procedure_create(HeapTuple procTup, Oid tgreloid, char *key)
/* Disallow pseudotype argument */
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("PL/Python functions cannot accept type %s",
errmsg("PL/Python functions cannot accept type %s",
format_type_be(types[i]))));
break;
case TYPTYPE_COMPOSITE:
@@ -1375,7 +1379,7 @@ PLy_procedure_create(HeapTuple procTup, Oid tgreloid, char *key)
}
static void
PLy_procedure_compile(PLyProcedure * proc, const char *src)
PLy_procedure_compile(PLyProcedure *proc, const char *src)
{
PyObject *crv = NULL;
char *msrc;
@@ -1465,7 +1469,7 @@ PLy_procedure_munge_source(const char *name, const char *src)
}
static void
PLy_procedure_delete(PLyProcedure * proc)
PLy_procedure_delete(PLyProcedure *proc)
{
int i;
@@ -1498,7 +1502,7 @@ PLy_procedure_delete(PLyProcedure * proc)
* PostgreSQL, and vice versa.
*/
static void
PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
PLy_input_tuple_funcs(PLyTypeInfo *arg, TupleDesc desc)
{
int i;
@@ -1540,7 +1544,7 @@ PLy_input_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
}
static void
PLy_output_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
PLy_output_tuple_funcs(PLyTypeInfo *arg, TupleDesc desc)
{
int i;
@@ -1580,7 +1584,7 @@ PLy_output_tuple_funcs(PLyTypeInfo * arg, TupleDesc desc)
}
static void
PLy_output_datum_func(PLyTypeInfo * arg, HeapTuple typeTup)
PLy_output_datum_func(PLyTypeInfo *arg, HeapTuple typeTup)
{
if (arg->is_rowtype > 0)
elog(ERROR, "PLyTypeInfo struct is initialized for a Tuple");
@@ -1589,7 +1593,7 @@ PLy_output_datum_func(PLyTypeInfo * arg, HeapTuple typeTup)
}
static void
PLy_output_datum_func2(PLyObToDatum * arg, HeapTuple typeTup)
PLy_output_datum_func2(PLyObToDatum *arg, HeapTuple typeTup)
{
Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
@@ -1600,7 +1604,7 @@ PLy_output_datum_func2(PLyObToDatum * arg, HeapTuple typeTup)
}
static void
PLy_input_datum_func(PLyTypeInfo * arg, Oid typeOid, HeapTuple typeTup)
PLy_input_datum_func(PLyTypeInfo *arg, Oid typeOid, HeapTuple typeTup)
{
if (arg->is_rowtype > 0)
elog(ERROR, "PLyTypeInfo struct is initialized for Tuple");
@@ -1609,7 +1613,7 @@ PLy_input_datum_func(PLyTypeInfo * arg, Oid typeOid, HeapTuple typeTup)
}
static void
PLy_input_datum_func2(PLyDatumToOb * arg, Oid typeOid, HeapTuple typeTup)
PLy_input_datum_func2(PLyDatumToOb *arg, Oid typeOid, HeapTuple typeTup)
{
Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
@@ -1644,7 +1648,7 @@ PLy_input_datum_func2(PLyDatumToOb * arg, Oid typeOid, HeapTuple typeTup)
}
static void
PLy_typeinfo_init(PLyTypeInfo * arg)
PLy_typeinfo_init(PLyTypeInfo *arg)
{
arg->is_rowtype = -1;
arg->in.r.natts = arg->out.r.natts = 0;
@@ -1653,7 +1657,7 @@ PLy_typeinfo_init(PLyTypeInfo * arg)
}
static void
PLy_typeinfo_dealloc(PLyTypeInfo * arg)
PLy_typeinfo_dealloc(PLyTypeInfo *arg)
{
if (arg->is_rowtype == 1)
{
@@ -1718,7 +1722,7 @@ PLyString_FromString(const char *src)
}
static PyObject *
PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc)
PLyDict_FromTuple(PLyTypeInfo *info, HeapTuple tuple, TupleDesc desc)
{
PyObject *volatile dict;
int i;
@@ -1775,7 +1779,7 @@ PLyDict_FromTuple(PLyTypeInfo * info, HeapTuple tuple, TupleDesc desc)
static HeapTuple
PLyMapping_ToTuple(PLyTypeInfo * info, PyObject * mapping)
PLyMapping_ToTuple(PLyTypeInfo *info, PyObject *mapping)
{
TupleDesc desc;
HeapTuple tuple;
@@ -1831,7 +1835,7 @@ PLyMapping_ToTuple(PLyTypeInfo * info, PyObject * mapping)
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("key \"%s\" not found in mapping", key),
errhint("To return null in a column, "
"add the value None to the mapping with the key named after the column.")));
"add the value None to the mapping with the key named after the column.")));
Py_XDECREF(value);
value = NULL;
@@ -1855,7 +1859,7 @@ PLyMapping_ToTuple(PLyTypeInfo * info, PyObject * mapping)
static HeapTuple
PLySequence_ToTuple(PLyTypeInfo * info, PyObject * sequence)
PLySequence_ToTuple(PLyTypeInfo *info, PyObject *sequence)
{
TupleDesc desc;
HeapTuple tuple;
@@ -1874,7 +1878,7 @@ PLySequence_ToTuple(PLyTypeInfo * info, PyObject * sequence)
if (PySequence_Length(sequence) != desc->natts)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("length of returned sequence did not match number of columns in row")));
errmsg("length of returned sequence did not match number of columns in row")));
if (info->is_rowtype == 2)
PLy_output_tuple_funcs(info, desc);
@@ -1937,7 +1941,7 @@ PLySequence_ToTuple(PLyTypeInfo * info, PyObject * sequence)
static HeapTuple
PLyObject_ToTuple(PLyTypeInfo * info, PyObject * object)
PLyObject_ToTuple(PLyTypeInfo *info, PyObject *object)
{
TupleDesc desc;
HeapTuple tuple;
@@ -1990,7 +1994,7 @@ PLyObject_ToTuple(PLyTypeInfo * info, PyObject * object)
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("attribute \"%s\" does not exist in Python object", key),
errhint("To return null in a column, "
"let the returned object have an attribute named "
"let the returned object have an attribute named "
"after column with value None.")));
Py_XDECREF(value);
@@ -2175,7 +2179,7 @@ PLy_plan_new(void)
static void
PLy_plan_dealloc(PyObject * arg)
PLy_plan_dealloc(PyObject *arg)
{
PLyPlanObject *ob = (PLyPlanObject *) arg;
@@ -2197,13 +2201,13 @@ PLy_plan_dealloc(PyObject * arg)
static PyObject *
PLy_plan_getattr(PyObject * self, char *name)
PLy_plan_getattr(PyObject *self, char *name)
{
return Py_FindMethod(PLy_plan_methods, self, name);
}
static PyObject *
PLy_plan_status(PyObject * self, PyObject * args)
PLy_plan_status(PyObject *self, PyObject *args)
{
if (PyArg_ParseTuple(args, ""))
{
@@ -2238,7 +2242,7 @@ PLy_result_new(void)
}
static void
PLy_result_dealloc(PyObject * arg)
PLy_result_dealloc(PyObject *arg)
{
PLyResultObject *ob = (PLyResultObject *) arg;
@@ -2250,13 +2254,13 @@ PLy_result_dealloc(PyObject * arg)
}
static PyObject *
PLy_result_getattr(PyObject * self, char *name)
PLy_result_getattr(PyObject *self, char *name)
{
return Py_FindMethod(PLy_result_methods, self, name);
}
static PyObject *
PLy_result_nrows(PyObject * self, PyObject * args)
PLy_result_nrows(PyObject *self, PyObject *args)
{
PLyResultObject *ob = (PLyResultObject *) self;
@@ -2265,7 +2269,7 @@ PLy_result_nrows(PyObject * self, PyObject * args)
}
static PyObject *
PLy_result_status(PyObject * self, PyObject * args)
PLy_result_status(PyObject *self, PyObject *args)
{
PLyResultObject *ob = (PLyResultObject *) self;
@@ -2274,7 +2278,7 @@ PLy_result_status(PyObject * self, PyObject * args)
}
static Py_ssize_t
PLy_result_length(PyObject * arg)
PLy_result_length(PyObject *arg)
{
PLyResultObject *ob = (PLyResultObject *) arg;
@@ -2282,7 +2286,7 @@ PLy_result_length(PyObject * arg)
}
static PyObject *
PLy_result_item(PyObject * arg, Py_ssize_t idx)
PLy_result_item(PyObject *arg, Py_ssize_t idx)
{
PyObject *rv;
PLyResultObject *ob = (PLyResultObject *) arg;
@@ -2294,7 +2298,7 @@ PLy_result_item(PyObject * arg, Py_ssize_t idx)
}
static int
PLy_result_ass_item(PyObject * arg, Py_ssize_t idx, PyObject * item)
PLy_result_ass_item(PyObject *arg, Py_ssize_t idx, PyObject *item)
{
int rv;
PLyResultObject *ob = (PLyResultObject *) arg;
@@ -2305,7 +2309,7 @@ PLy_result_ass_item(PyObject * arg, Py_ssize_t idx, PyObject * item)
}
static PyObject *
PLy_result_slice(PyObject * arg, Py_ssize_t lidx, Py_ssize_t hidx)
PLy_result_slice(PyObject *arg, Py_ssize_t lidx, Py_ssize_t hidx)
{
PyObject *rv;
PLyResultObject *ob = (PLyResultObject *) arg;
@@ -2318,7 +2322,7 @@ PLy_result_slice(PyObject * arg, Py_ssize_t lidx, Py_ssize_t hidx)
}
static int
PLy_result_ass_slice(PyObject * arg, Py_ssize_t lidx, Py_ssize_t hidx, PyObject * slice)
PLy_result_ass_slice(PyObject *arg, Py_ssize_t lidx, Py_ssize_t hidx, PyObject *slice)
{
int rv;
PLyResultObject *ob = (PLyResultObject *) arg;
@@ -2329,7 +2333,7 @@ PLy_result_ass_slice(PyObject * arg, Py_ssize_t lidx, Py_ssize_t hidx, PyObject
/* SPI interface */
static PyObject *
PLy_spi_prepare(PyObject * self, PyObject * args)
PLy_spi_prepare(PyObject *self, PyObject *args)
{
PLyPlanObject *plan;
PyObject *list = NULL;
@@ -2355,7 +2359,7 @@ PLy_spi_prepare(PyObject * self, PyObject * args)
if (list && (!PySequence_Check(list)))
{
PLy_exception_set(PLy_exc_spi_error,
"second argument of plpy.prepare must be a sequence");
"second argument of plpy.prepare must be a sequence");
return NULL;
}
@@ -2470,7 +2474,7 @@ PLy_spi_prepare(PyObject * self, PyObject * args)
* execute(plan=plan, values=(foo, bar), limit=5)
*/
static PyObject *
PLy_spi_execute(PyObject * self, PyObject * args)
PLy_spi_execute(PyObject *self, PyObject *args)
{
char *query;
PyObject *plan;
@@ -2498,7 +2502,7 @@ PLy_spi_execute(PyObject * self, PyObject * args)
}
static PyObject *
PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
PLy_spi_execute_plan(PyObject *ob, PyObject *list, long limit)
{
volatile int nargs;
int i,
@@ -2530,8 +2534,8 @@ PLy_spi_execute_plan(PyObject * ob, PyObject * list, long limit)
PLy_procedure_name(PLy_curr_procedure));
sv = PyString_AsString(so);
PLy_exception_set_plural(PLy_exc_spi_error,
"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);
@@ -2737,7 +2741,7 @@ PLy_spi_execute_fetch_result(SPITupleTable *tuptable, int rows, int status)
FlushErrorState();
if (!PyErr_Occurred())
PLy_exception_set(PLy_exc_error,
"unrecognized error in PLy_spi_execute_fetch_result");
"unrecognized error in PLy_spi_execute_fetch_result");
Py_DECREF(result);
PLy_typeinfo_dealloc(&args);
return NULL;
@@ -2844,50 +2848,50 @@ PLy_init_plpy(void)
static PyObject *PLy_output(volatile int, PyObject *, PyObject *);
static PyObject *
PLy_debug(PyObject * self, PyObject * args)
PLy_debug(PyObject *self, PyObject *args)
{
return PLy_output(DEBUG2, self, args);
}
static PyObject *
PLy_log(PyObject * self, PyObject * args)
PLy_log(PyObject *self, PyObject *args)
{
return PLy_output(LOG, self, args);
}
static PyObject *
PLy_info(PyObject * self, PyObject * args)
PLy_info(PyObject *self, PyObject *args)
{
return PLy_output(INFO, self, args);
}
static PyObject *
PLy_notice(PyObject * self, PyObject * args)
PLy_notice(PyObject *self, PyObject *args)
{
return PLy_output(NOTICE, self, args);
}
static PyObject *
PLy_warning(PyObject * self, PyObject * args)
PLy_warning(PyObject *self, PyObject *args)
{
return PLy_output(WARNING, self, args);
}
static PyObject *
PLy_error(PyObject * self, PyObject * args)
PLy_error(PyObject *self, PyObject *args)
{
return PLy_output(ERROR, self, args);
}
static PyObject *
PLy_fatal(PyObject * self, PyObject * args)
PLy_fatal(PyObject *self, PyObject *args)
{
return PLy_output(FATAL, self, args);
}
static PyObject *
PLy_output(volatile int level, PyObject * self, PyObject * args)
PLy_output(volatile int level, PyObject *self, PyObject *args)
{
PyObject *so;
char *volatile sv;
@@ -2940,7 +2944,7 @@ PLy_output(volatile int level, PyObject * self, PyObject * args)
* NB: this returns the SQL name, not the internal Python procedure name
*/
static char *
PLy_procedure_name(PLyProcedure * proc)
PLy_procedure_name(PLyProcedure *proc)
{
if (proc == NULL)
return "<unknown procedure>";
@@ -2951,7 +2955,7 @@ PLy_procedure_name(PLyProcedure * proc)
* Call PyErr_SetString with a vprint interface and translation support
*/
static void
PLy_exception_set(PyObject * exc, const char *fmt,...)
PLy_exception_set(PyObject *exc, const char *fmt,...)
{
char buf[1024];
va_list ap;

View File

@@ -2,7 +2,7 @@
* pltcl.c - PostgreSQL support for Tcl as
* procedural language (PL)
*
* $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.127 2009/01/21 11:13:14 heikki Exp $
* $PostgreSQL: pgsql/src/pl/tcl/pltcl.c,v 1.128 2009/06/11 14:49:14 momjian Exp $
*
**********************************************************************/
@@ -672,7 +672,7 @@ pltcl_func_handler(PG_FUNCTION_ARGS)
{
UTF_BEGIN;
retval = InputFunctionCall(&prodesc->result_in_func,
UTF_U2E((char *) Tcl_GetStringResult(interp)),
UTF_U2E((char *) Tcl_GetStringResult(interp)),
prodesc->result_typioparam,
-1);
UTF_END;
@@ -1009,10 +1009,10 @@ throw_tcl_error(Tcl_Interp *interp, const char *proname)
{
/*
* Caution is needed here because Tcl_GetVar could overwrite the
* interpreter result (even though it's not really supposed to),
* and we can't control the order of evaluation of ereport arguments.
* Hence, make real sure we have our own copy of the result string
* before invoking Tcl_GetVar.
* interpreter result (even though it's not really supposed to), and we
* can't control the order of evaluation of ereport arguments. Hence, make
* real sure we have our own copy of the result string before invoking
* Tcl_GetVar.
*/
char *emsg;
char *econtext;
@@ -1210,7 +1210,7 @@ compile_pltcl_function(Oid fn_oid, Oid tgreloid)
free(prodesc);
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("PL/Tcl functions cannot return composite types")));
errmsg("PL/Tcl functions cannot return composite types")));
}
perm_fmgr_info(typeStruct->typinput, &(prodesc->result_in_func));
@@ -1416,19 +1416,19 @@ pltcl_elog(ClientData cdata, Tcl_Interp *interp,
if (level == ERROR)
{
/*
* We just pass the error back to Tcl. If it's not caught,
* it'll eventually get converted to a PG error when we reach
* the call handler.
* We just pass the error back to Tcl. If it's not caught, it'll
* eventually get converted to a PG error when we reach the call
* handler.
*/
Tcl_SetResult(interp, (char *) argv[2], TCL_VOLATILE);
return TCL_ERROR;
}
/*
* For non-error messages, just pass 'em to elog(). We do not expect
* that this will fail, but just on the off chance it does, report the
* error back to Tcl. Note we are assuming that elog() can't have any
* internal failures that are so bad as to require a transaction abort.
* For non-error messages, just pass 'em to elog(). We do not expect that
* this will fail, but just on the off chance it does, report the error
* back to Tcl. Note we are assuming that elog() can't have any internal
* failures that are so bad as to require a transaction abort.
*
* This path is also used for FATAL errors, which aren't going to come
* back to us at all.