Fix some localizability issues with existing errcontext() calls.

This commit is contained in:
Tom Lane 2003-07-27 18:38:26 +00:00
parent 2d7a6a9ef2
commit e7f3645171
3 changed files with 34 additions and 22 deletions

View File

@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.61 2003/07/26 23:58:23 momjian Exp $
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.62 2003/07/27 18:38:26 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@ -720,7 +720,7 @@ static void
plpgsql_compile_error_callback(void *arg)
{
if (plpgsql_error_funcname)
errcontext("compile of PL/pgSQL function %s near line %d",
errcontext("compile of PL/pgSQL function \"%s\" near line %d",
plpgsql_error_funcname, plpgsql_error_lineno);
}

View File

@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.88 2003/07/25 23:37:28 tgl Exp $
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.89 2003/07/27 18:38:26 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@ -190,7 +190,7 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo)
/*
* Make local execution copies of all the datums
*/
estate.err_text = "while initialization of execution state";
estate.err_text = gettext_noop("during initialization of execution state");
for (i = 0; i < func->ndatums; i++)
{
switch (func->datums[i]->dtype)
@ -217,9 +217,9 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo)
}
/*
* Put the actual call argument values into the variables
* Store the actual call argument values into the variables
*/
estate.err_text = "while putting call arguments to local variables";
estate.err_text = gettext_noop("while storing call arguments into local variables");
for (i = 0; i < func->fn_nargs; i++)
{
int n = func->fn_argvarnos[i];
@ -259,7 +259,7 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo)
* Initialize the other variables to NULL values for now. The default
* values are set when the blocks are entered.
*/
estate.err_text = "while initializing local variables to NULL";
estate.err_text = gettext_noop("while initializing local variables to NULL");
for (i = estate.found_varno; i < estate.ndatums; i++)
{
switch (estate.datums[i]->dtype)
@ -298,7 +298,7 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo)
if (exec_stmt_block(&estate, func->action) != PLPGSQL_RC_RETURN)
{
estate.err_stmt = NULL;
estate.err_text = "at END of toplevel PL block";
estate.err_text = NULL;
ereport(ERROR,
(errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT),
errmsg("control reached end of function without RETURN")));
@ -308,7 +308,7 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo)
* We got a return value - process it
*/
estate.err_stmt = NULL;
estate.err_text = "while casting return value to function's return type";
estate.err_text = gettext_noop("while casting return value to function's return type");
fcinfo->isnull = estate.retisnull;
@ -425,7 +425,7 @@ plpgsql_exec_trigger(PLpgSQL_function * func,
/*
* Make local execution copies of all the datums
*/
estate.err_text = "while initialization of execution state";
estate.err_text = gettext_noop("during initialization of execution state");
for (i = 0; i < func->ndatums; i++)
{
switch (func->datums[i]->dtype)
@ -556,10 +556,10 @@ plpgsql_exec_trigger(PLpgSQL_function * func,
var->value = Int16GetDatum(trigdata->tg_trigger->tgnargs);
/*
* Put the actual call argument values into the special execution
* Store the actual call argument values into the special execution
* state variables
*/
estate.err_text = "while putting call arguments to local variables";
estate.err_text = gettext_noop("while storing call arguments into local variables");
estate.trig_nargs = trigdata->tg_trigger->tgnargs;
if (estate.trig_nargs == 0)
estate.trig_argv = NULL;
@ -575,7 +575,7 @@ plpgsql_exec_trigger(PLpgSQL_function * func,
* Initialize the other variables to NULL values for now. The default
* values are set when the blocks are entered.
*/
estate.err_text = "while initializing local variables to NULL";
estate.err_text = gettext_noop("while initializing local variables to NULL");
for (i = estate.found_varno; i < estate.ndatums; i++)
{
switch (estate.datums[i]->dtype)
@ -615,7 +615,7 @@ plpgsql_exec_trigger(PLpgSQL_function * func,
if (exec_stmt_block(&estate, func->action) != PLPGSQL_RC_RETURN)
{
estate.err_stmt = NULL;
estate.err_text = "at END of toplevel PL block";
estate.err_text = NULL;
ereport(ERROR,
(errcode(ERRCODE_S_R_E_FUNCTION_EXECUTED_NO_RETURN_STATEMENT),
errmsg("control reached end of trigger procedure without RETURN")));
@ -681,16 +681,28 @@ plpgsql_exec_error_callback(void *arg)
return;
if (estate->err_stmt != NULL)
errcontext("PL/pgSQL function %s line %d at %s",
{
/* translator: last %s is a plpgsql statement type name */
errcontext("PL/pgSQL function \"%s\" line %d at %s",
estate->err_func->fn_name,
estate->err_stmt->lineno,
plpgsql_stmt_typename(estate->err_stmt));
}
else if (estate->err_text != NULL)
errcontext("PL/pgSQL function %s %s",
{
/*
* We don't expend the cycles to run gettext() on err_text unless
* we actually need it. Therefore, places that set up err_text should
* use gettext_noop() to ensure the strings get recorded in the
* message dictionary.
*/
/* 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);
gettext(estate->err_text));
}
else
errcontext("PL/pgSQL function %s",
errcontext("PL/pgSQL function \"%s\"",
estate->err_func->fn_name);
}

View File

@ -1518,16 +1518,16 @@ insert into PField values ('PF1_1', 'should fail due to unique index');
ERROR: duplicate key violates UNIQUE constraint "pfield_name"
update PSlot set backlink = 'WS.not.there' where slotname = 'PS.base.a1';
ERROR: WS.not.there does not exist
CONTEXT: PL/pgSQL function tg_backlink_a line 16 at assignment
CONTEXT: PL/pgSQL function "tg_backlink_a" line 16 at assignment
update PSlot set backlink = 'XX.illegal' where slotname = 'PS.base.a1';
ERROR: illegal backlink beginning with XX
CONTEXT: PL/pgSQL function tg_backlink_a line 16 at assignment
CONTEXT: PL/pgSQL function "tg_backlink_a" line 16 at assignment
update PSlot set slotlink = 'PS.not.there' where slotname = 'PS.base.a1';
ERROR: PS.not.there does not exist
CONTEXT: PL/pgSQL function tg_slotlink_a line 16 at assignment
CONTEXT: PL/pgSQL function "tg_slotlink_a" line 16 at assignment
update PSlot set slotlink = 'XX.illegal' where slotname = 'PS.base.a1';
ERROR: illegal slotlink beginning with XX
CONTEXT: PL/pgSQL function tg_slotlink_a line 16 at assignment
CONTEXT: PL/pgSQL function "tg_slotlink_a" line 16 at assignment
insert into HSlot values ('HS', 'base.hub1', 1, '');
ERROR: duplicate key violates UNIQUE constraint "hslot_name"
insert into HSlot values ('HS', 'base.hub1', 20, '');