From d474510d1f6c6271dfd41b12e3287e34c7913b08 Mon Sep 17 00:00:00 2001 From: petere Date: Wed, 18 Feb 2009 11:33:04 +0000 Subject: [PATCH] Message wordsmithing --- src/pl/plpgsql/src/gram.y | 22 ++++++++-------- src/pl/plpgsql/src/pl_comp.c | 8 +++--- src/pl/plpgsql/src/pl_exec.c | 48 +++++++++++++++-------------------- src/pl/plpgsql/src/pl_funcs.c | 4 +-- src/pl/plpgsql/src/pl_handler.c | 4 +-- src/pl/plpgsql/src/scan.l | 4 +-- src/test/regress/expected/plpgsql.out | 8 +++--- 7 files changed, 46 insertions(+), 52 deletions(-) diff --git a/src/pl/plpgsql/src/gram.y b/src/pl/plpgsql/src/gram.y index 5599a4bd90..b8815c5dd1 100644 --- a/src/pl/plpgsql/src/gram.y +++ b/src/pl/plpgsql/src/gram.y @@ -1043,7 +1043,7 @@ for_control : if ($2.scalar && $2.row) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("cursor FOR loop must have just one target variable"))); + errmsg("cursor FOR loop must have only one target variable"))); /* create loop's private RECORD variable */ plpgsql_convert_ident($2.name, &varname, 1); @@ -1131,7 +1131,7 @@ for_control : if ($2.scalar && $2.row) ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("integer FOR loop must have just one target variable"))); + errmsg("integer FOR loop must have only one target variable"))); /* create loop's private variable */ plpgsql_convert_ident($2.name, &varname, 1); @@ -1570,7 +1570,7 @@ stmt_open : K_OPEN lno cursor_variable (errcode(ERRCODE_SYNTAX_ERROR), errmsg("syntax error at \"%s\"", yytext), - errdetail("Expected FOR to open a reference cursor."))); + errdetail("Expected \"FOR\", to open a reference cursor."))); } tok = yylex(); @@ -1664,7 +1664,7 @@ cursor_variable : T_SCALAR plpgsql_error_lineno = plpgsql_scanner_lineno(); ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("\"%s\" must be of type cursor or refcursor", + errmsg("variable \"%s\" must be of type cursor or refcursor", ((PLpgSQL_var *) yylval.scalar)->refname))); } $$ = (PLpgSQL_var *) yylval.scalar; @@ -2094,7 +2094,7 @@ read_datatype(int tok) if (parenlevel != 0) yyerror("mismatched parentheses"); else - yyerror("incomplete datatype declaration"); + yyerror("incomplete data type declaration"); } /* Possible followers for datatype in a declaration */ if (tok == K_NOT || tok == K_ASSIGN || tok == K_DEFAULT) @@ -2119,7 +2119,7 @@ read_datatype(int tok) type_name = plpgsql_dstring_get(&ds); if (type_name[0] == '\0') - yyerror("missing datatype declaration"); + yyerror("missing data type declaration"); plpgsql_error_lineno = lno; /* in case of error in parse_datatype */ @@ -2375,11 +2375,11 @@ make_return_stmt(int lineno) break; default: - yyerror("RETURN must specify a record or row variable in function returning tuple"); + yyerror("RETURN must specify a record or row variable in function returning row"); break; } if (yylex() != ';') - yyerror("RETURN must specify a record or row variable in function returning tuple"); + yyerror("RETURN must specify a record or row variable in function returning row"); } else { @@ -2428,11 +2428,11 @@ make_return_next_stmt(int lineno) break; default: - yyerror("RETURN NEXT must specify a record or row variable in function returning tuple"); + yyerror("RETURN NEXT must specify a record or row variable in function returning row"); break; } if (yylex() != ';') - yyerror("RETURN NEXT must specify a record or row variable in function returning tuple"); + yyerror("RETURN NEXT must specify a record or row variable in function returning row"); } else new->expr = plpgsql_read_expression(';', ";"); @@ -2745,7 +2745,7 @@ check_label(const char *yytxt) plpgsql_convert_ident(yytxt, &label_name, 1); if (plpgsql_ns_lookup_label(label_name) == NULL) - yyerror("no such label"); + yyerror("label does not exist"); return label_name; } diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index 768daf98f1..9f9d30eb3f 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -415,7 +415,7 @@ do_compile(FunctionCallInfo fcinfo, argdtype->ttype != PLPGSQL_TTYPE_ROW) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("plpgsql functions cannot take type %s", + errmsg("PL/pgSQL functions cannot accept type %s", format_type_be(argtypeid)))); /* Build variable and add to datum list */ @@ -534,7 +534,7 @@ do_compile(FunctionCallInfo fcinfo, else ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("plpgsql functions cannot return type %s", + errmsg("PL/pgSQL functions cannot return type %s", format_type_be(rettypeid)))); } @@ -576,7 +576,7 @@ do_compile(FunctionCallInfo fcinfo, ereport(ERROR, (errcode(ERRCODE_INVALID_FUNCTION_DEFINITION), errmsg("trigger functions cannot have declared arguments"), - errhint("You probably want to use TG_NARGS and TG_ARGV instead."))); + errhint("The arguments of the trigger can be accessed through TG_NARGS and TG_ARGV instead."))); /* Add the record for referencing NEW */ rec = plpgsql_build_record("new", 0, true); @@ -766,7 +766,7 @@ plpgsql_compile_error_callback(void *arg) } if (plpgsql_error_funcname) - errcontext("compile of PL/pgSQL function \"%s\" near line %d", + errcontext("compilation of PL/pgSQL function \"%s\" near line %d", plpgsql_error_funcname, plpgsql_error_lineno); } diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 21e76020cc..538efc6e30 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -706,7 +706,7 @@ plpgsql_exec_trigger(PLpgSQL_function *func, { validate_tupdesc_compat(trigdata->tg_relation->rd_att, estate.rettupdesc, - "returned tuple structure does not match table of trigger event"); + "returned row structure does not match the structure of the triggering table"); /* Copy tuple to upper executor memory */ rettup = SPI_copytuple((HeapTuple) DatumGetPointer(estate.retval)); } @@ -765,24 +765,18 @@ 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, - gettext(estate->err_text)); + _(estate->err_text)); } 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, - gettext(estate->err_text)); + _(estate->err_text)); } } else if (estate->err_stmt != NULL) @@ -1677,7 +1671,7 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt) if (isnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("lower bound of FOR loop cannot be NULL"))); + errmsg("lower bound of FOR loop cannot be null"))); loop_value = DatumGetInt32(value); exec_eval_cleanup(estate); @@ -1692,7 +1686,7 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt) if (isnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("upper bound of FOR loop cannot be NULL"))); + errmsg("upper bound of FOR loop cannot be null"))); end_value = DatumGetInt32(value); exec_eval_cleanup(estate); @@ -1709,7 +1703,7 @@ exec_stmt_fori(PLpgSQL_execstate *estate, PLpgSQL_stmt_fori *stmt) if (isnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("BY value of FOR loop cannot be NULL"))); + errmsg("BY value of FOR loop cannot be null"))); step_value = DatumGetInt32(value); exec_eval_cleanup(estate); if (step_value <= 0) @@ -2470,7 +2464,7 @@ exec_stmt_raise(PLpgSQL_execstate *estate, PLpgSQL_stmt_raise *stmt) if (optionisnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("RAISE statement option cannot be NULL"))); + errmsg("RAISE statement option cannot be null"))); extval = convert_value_to_string(optionvalue, optiontypeid); @@ -2916,7 +2910,7 @@ exec_stmt_dynexecute(PLpgSQL_execstate *estate, if (isnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("cannot EXECUTE a null querystring"))); + errmsg("query string argument of EXECUTE is null"))); /* Get the C-String representation */ querystr = convert_value_to_string(query, restype); @@ -2981,7 +2975,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 yet"))); + errmsg("EXECUTE of SELECT ... INTO is not implemented"))); break; } @@ -3166,7 +3160,7 @@ exec_stmt_open(PLpgSQL_execstate *estate, PLpgSQL_stmt_open *stmt) if (isnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("cannot EXECUTE a null querystring"))); + errmsg("query string argument of EXECUTE is null"))); /* Get the C-String representation */ querystr = convert_value_to_string(queryD, restype); @@ -3300,7 +3294,7 @@ exec_stmt_fetch(PLpgSQL_execstate *estate, PLpgSQL_stmt_fetch *stmt) if (curvar->isnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("cursor variable \"%s\" is NULL", curvar->refname))); + errmsg("cursor variable \"%s\" is null", curvar->refname))); curname = TextDatumGetCString(curvar->value); portal = SPI_cursor_find(curname); @@ -3321,7 +3315,7 @@ exec_stmt_fetch(PLpgSQL_execstate *estate, PLpgSQL_stmt_fetch *stmt) if (isnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("relative or absolute cursor position is NULL"))); + errmsg("relative or absolute cursor position is null"))); exec_eval_cleanup(estate); } @@ -3396,7 +3390,7 @@ exec_stmt_close(PLpgSQL_execstate *estate, PLpgSQL_stmt_close *stmt) if (curvar->isnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("cursor variable \"%s\" is NULL", curvar->refname))); + errmsg("cursor variable \"%s\" is null", curvar->refname))); curname = TextDatumGetCString(curvar->value); portal = SPI_cursor_find(curname); @@ -3463,7 +3457,7 @@ exec_assign_value(PLpgSQL_execstate *estate, if (*isNull && var->notnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("NULL cannot be assigned to variable \"%s\" declared NOT NULL", + errmsg("null value cannot be assigned to variable \"%s\" declared NOT NULL", var->refname))); /* @@ -3720,8 +3714,8 @@ exec_assign_value(PLpgSQL_execstate *estate, if (nsubscripts >= MAXDIM) ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), - errmsg("number of array dimensions exceeds the maximum allowed, %d", - MAXDIM))); + errmsg("number of array dimensions (%d) exceeds the maximum allowed (%d)", + nsubscripts, MAXDIM))); subscripts[nsubscripts++] = arrayelem->subscript; target = estate->datums[arrayelem->arrayparentno]; } while (target->dtype == PLPGSQL_DTYPE_ARRAYELEM); @@ -3757,7 +3751,7 @@ exec_assign_value(PLpgSQL_execstate *estate, if (subisnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("array subscript in assignment must not be NULL"))); + errmsg("array subscript in assignment must not be null"))); } /* Coerce source value to match array element type. */ @@ -5129,7 +5123,7 @@ static void validate_tupdesc_compat(TupleDesc expected, TupleDesc returned, const char *msg) { int i; - const char *dropped_column_type = gettext_noop("n/a (dropped column)"); + const char *dropped_column_type = gettext_noop("N/A (dropped column)"); if (!expected || !returned) ereport(ERROR, @@ -5402,7 +5396,7 @@ exec_dynquery_with_params(PLpgSQL_execstate *estate, PLpgSQL_expr *dynquery, if (isnull) ereport(ERROR, (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), - errmsg("cannot EXECUTE a null querystring"))); + errmsg("query string argument of EXECUTE is null"))); /* Get the C-String representation */ querystr = convert_value_to_string(query, restype); diff --git a/src/pl/plpgsql/src/pl_funcs.c b/src/pl/plpgsql/src/pl_funcs.c index c91bd6b8d9..c64c22c625 100644 --- a/src/pl/plpgsql/src/pl_funcs.c +++ b/src/pl/plpgsql/src/pl_funcs.c @@ -356,7 +356,7 @@ plpgsql_ns_rename(char *oldname, char *newname) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("there is no variable \"%s\" in the current block", + errmsg("variable \"%s\" does not exist in the current block", oldname))); } @@ -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 name: %s", sstart))); + errmsg("unterminated \" in identifier: %s", sstart))); s++; *cp = '\0'; /* Truncate to NAMEDATALEN */ diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c index 9d21fbdf82..ec8c02d7a1 100644 --- a/src/pl/plpgsql/src/pl_handler.c +++ b/src/pl/plpgsql/src/pl_handler.c @@ -159,7 +159,7 @@ plpgsql_validator(PG_FUNCTION_ARGS) !IsPolymorphicType(proc->prorettype)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("plpgsql functions cannot return type %s", + errmsg("PL/pgSQL functions cannot return type %s", format_type_be(proc->prorettype)))); } @@ -174,7 +174,7 @@ plpgsql_validator(PG_FUNCTION_ARGS) if (!IsPolymorphicType(argtypes[i])) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("plpgsql functions cannot take type %s", + errmsg("PL/pgSQL functions cannot accept type %s", format_type_be(argtypes[i])))); } } diff --git a/src/pl/plpgsql/src/scan.l b/src/pl/plpgsql/src/scan.l index b5b0adb16d..99eb934dfc 100644 --- a/src/pl/plpgsql/src/scan.l +++ b/src/pl/plpgsql/src/scan.l @@ -254,7 +254,7 @@ dump { return O_DUMP; } plpgsql_error_lineno = start_lineno; ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("unterminated comment"))); + errmsg("unterminated /* comment"))); } /* ---------- @@ -293,7 +293,7 @@ dump { return O_DUMP; } plpgsql_error_lineno = start_lineno; ereport(ERROR, (errcode(ERRCODE_DATATYPE_MISMATCH), - errmsg("unterminated string"))); + errmsg("unterminated quoted string"))); } {dolqdelim} { diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out index 0fe279493f..66bd895f70 100644 --- a/src/test/regress/expected/plpgsql.out +++ b/src/test/regress/expected/plpgsql.out @@ -2700,7 +2700,7 @@ begin end loop flbl1; end; $$ language plpgsql; -ERROR: no such label at or near "flbl1" +ERROR: label does not exist at or near "flbl1" LINE 5: end loop flbl1; ^ -- should fail: end label does not match start label @@ -2714,7 +2714,7 @@ begin end; $$ language plpgsql; ERROR: end label "outer_label" differs from block's label "inner_label" -CONTEXT: compile of PL/pgSQL function "end_label3" near line 6 +CONTEXT: compilation of PL/pgSQL function "end_label3" near line 6 -- should fail: end label on a block without a start label create function end_label4() returns void as $$ <> @@ -2725,7 +2725,7 @@ begin end; $$ language plpgsql; ERROR: end label "outer_label" specified for unlabelled block -CONTEXT: compile of PL/pgSQL function "end_label4" near line 5 +CONTEXT: compilation of PL/pgSQL function "end_label4" near line 5 -- using list of scalars in fori and fore stmts create function for_vect() returns void as $proc$ <>declare a integer; b varchar; c varchar; r record; @@ -3266,7 +3266,7 @@ begin end; $$ language plpgsql; ERROR: cursor FOR loop must use a bound cursor variable -CONTEXT: compile of PL/pgSQL function "forc_bad" near line 4 +CONTEXT: compilation of PL/pgSQL function "forc_bad" near line 4 -- test RETURN QUERY EXECUTE create or replace function return_dquery() returns setof int as $$ -- 2.11.4.GIT