Commit 3b04893f authored by Tom Lane's avatar Tom Lane

Error message editing in src/pl. The plpython module could use another

look ... I'm not real certain which errors are strictly internal and which
are likely to be provoked by users.
parent 400fedc8
#include "postgres.h"
#include "utils/elog.h"
/*
* This kludge is necessary because of the conflicting
* definitions of 'DEBUG' between postgres and perl.
......
......@@ -33,7 +33,7 @@
* ENHANCEMENTS, OR MODIFICATIONS.
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.36 2003/04/20 21:15:34 tgl Exp $
* $Header: /cvsroot/pgsql/src/pl/plperl/plperl.c,v 1.37 2003/07/25 23:37:28 tgl Exp $
*
**********************************************************************/
......@@ -47,7 +47,6 @@
/* postgreSQL stuff */
#include "executor/spi.h"
#include "commands/trigger.h"
#include "utils/elog.h"
#include "fmgr.h"
#include "access/heapam.h"
#include "tcop/tcopprot.h"
......@@ -193,7 +192,7 @@ plperl_init_interp(void)
plperl_interp = perl_alloc();
if (!plperl_interp)
elog(ERROR, "plperl_init_interp(): could not allocate perl interpreter");
elog(ERROR, "could not allocate perl interpreter");
perl_construct(plperl_interp);
perl_parse(plperl_interp, plperl_init_shared_libs, 3, embedding, NULL);
......@@ -232,7 +231,7 @@ plperl_call_handler(PG_FUNCTION_ARGS)
* Connect to SPI manager
************************************************************/
if (SPI_connect() != SPI_OK_CONNECT)
elog(ERROR, "plperl: cannot connect to SPI manager");
elog(ERROR, "could not connect to SPI manager");
/************************************************************
* Determine if called as function or trigger and
......@@ -240,7 +239,9 @@ plperl_call_handler(PG_FUNCTION_ARGS)
************************************************************/
if (CALLED_AS_TRIGGER(fcinfo))
{
elog(ERROR, "plperl: can't use perl in triggers yet.");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot use perl in triggers yet")));
/*
* retval = PointerGetDatum(plperl_trigger_handler(fcinfo));
......@@ -286,7 +287,7 @@ plperl_create_sub(char *s, bool trusted)
PUTBACK;
FREETMPS;
LEAVE;
elog(ERROR, "plperl: didn't get a return item from mksafefunc");
elog(ERROR, "didn't get a return item from mksafefunc");
}
if (SvTRUE(ERRSV))
......@@ -314,7 +315,7 @@ plperl_create_sub(char *s, bool trusted)
* subref is our responsibility because it is not mortal
*/
SvREFCNT_dec(subref);
elog(ERROR, "plperl_create_sub: didn't get a code ref");
elog(ERROR, "didn't get a code ref");
}
PUTBACK;
......@@ -406,7 +407,7 @@ plperl_call_perl_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo)
PUTBACK;
FREETMPS;
LEAVE;
elog(ERROR, "plperl: didn't get a return item from function");
elog(ERROR, "didn't get a return item from function");
}
if (SvTRUE(ERRSV))
......@@ -415,7 +416,7 @@ plperl_call_perl_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo)
PUTBACK;
FREETMPS;
LEAVE;
elog(ERROR, "plperl: error from function: %s", SvPV(ERRSV, PL_na));
elog(ERROR, "error from function: %s", SvPV(ERRSV, PL_na));
}
retval = newSVsv(POPs);
......@@ -453,7 +454,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
* because SPI_finish would free it).
************************************************************/
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "plperl: SPI_finish() failed");
elog(ERROR, "SPI_finish() failed");
if (!(perlret && SvOK(perlret)))
{
......@@ -493,7 +494,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
ObjectIdGetDatum(fn_oid),
0, 0, 0);
if (!HeapTupleIsValid(procTup))
elog(ERROR, "plperl: cache lookup for proc %u failed", fn_oid);
elog(ERROR, "cache lookup failed for function %u", fn_oid);
procStruct = (Form_pg_proc) GETSTRUCT(procTup);
/************************************************************
......@@ -551,7 +552,9 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
************************************************************/
prodesc = (plperl_proc_desc *) malloc(sizeof(plperl_proc_desc));
if (prodesc == NULL)
elog(ERROR, "plperl: out of memory");
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
MemSet(prodesc, 0, sizeof(plperl_proc_desc));
prodesc->proname = strdup(internal_proname);
prodesc->fn_xmin = HeapTupleHeaderGetXmin(procTup->t_data);
......@@ -567,7 +570,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{
free(prodesc->proname);
free(prodesc);
elog(ERROR, "plperl: cache lookup for language %u failed",
elog(ERROR, "cache lookup failed for language %u",
procStruct->prolang);
}
langStruct = (Form_pg_language) GETSTRUCT(langTup);
......@@ -587,7 +590,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{
free(prodesc->proname);
free(prodesc);
elog(ERROR, "plperl: cache lookup for return type %u failed",
elog(ERROR, "cache lookup failed for type %u",
procStruct->prorettype);
}
typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
......@@ -601,16 +604,18 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{
free(prodesc->proname);
free(prodesc);
elog(ERROR, "plperl functions cannot return type %s"
"\n\texcept when used as triggers",
format_type_be(procStruct->prorettype));
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("trigger functions may only be called as triggers")));
}
else
{
free(prodesc->proname);
free(prodesc);
elog(ERROR, "plperl functions cannot return type %s",
format_type_be(procStruct->prorettype));
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plperl functions cannot return type %s",
format_type_be(procStruct->prorettype))));
}
}
......@@ -618,7 +623,9 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{
free(prodesc->proname);
free(prodesc);
elog(ERROR, "plperl: return types of tuples not supported yet");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plperl functions cannot return tuples yet")));
}
perm_fmgr_info(typeStruct->typinput, &(prodesc->result_in_func));
......@@ -643,7 +650,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{
free(prodesc->proname);
free(prodesc);
elog(ERROR, "plperl: cache lookup for argument type %u failed",
elog(ERROR, "cache lookup failed for type %u",
procStruct->proargtypes[i]);
}
typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
......@@ -653,8 +660,10 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{
free(prodesc->proname);
free(prodesc);
elog(ERROR, "plperl functions cannot take type %s",
format_type_be(procStruct->proargtypes[i]));
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plperl functions cannot take type %s",
format_type_be(procStruct->proargtypes[i]))));
}
if (typeStruct->typrelid != InvalidOid)
......@@ -686,7 +695,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{
free(prodesc->proname);
free(prodesc);
elog(ERROR, "plperl: cannot create internal procedure %s",
elog(ERROR, "could not create internal procedure \"%s\"",
internal_proname);
}
......@@ -751,8 +760,8 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc)
ObjectIdGetDatum(tupdesc->attrs[i]->atttypid),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "plperl: Cache lookup for attribute '%s' type %u failed",
attname, tupdesc->attrs[i]->atttypid);
elog(ERROR, "cache lookup failed for type %u",
tupdesc->attrs[i]->atttypid);
typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput;
typelem = ((Form_pg_type) GETSTRUCT(typeTup))->typelem;
......
......@@ -4,7 +4,7 @@
* procedural language
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.44 2003/05/27 17:49:47 momjian Exp $
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.45 2003/07/25 23:37:28 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
......@@ -340,11 +340,17 @@ decl_statement : decl_varname decl_const decl_datatype decl_notnull decl_defval
row->lineno = $1.lineno;
if ($2)
elog(ERROR, "Rowtype variable cannot be CONSTANT");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("rowtype variable cannot be CONSTANT")));
if ($4)
elog(ERROR, "Rowtype variable cannot be NOT NULL");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("rowtype variable cannot be NOT NULL")));
if ($5 != NULL)
elog(ERROR, "Default value for rowtype variable is not supported");
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("default value for rowtype variable is not supported")));
plpgsql_adddatum((PLpgSQL_datum *)row);
plpgsql_ns_additem(PLPGSQL_NSTYPE_ROW,
......@@ -554,7 +560,10 @@ decl_aliasitem : T_WORD
if (nsi == NULL)
{
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "function has no parameter %s", name);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_PARAMETER),
errmsg("function has no parameter \"%s\"",
name)));
}
plpgsql_ns_setlocal(true);
......@@ -1087,7 +1096,8 @@ stmt_fors : opt_label K_FOR lno fors_target K_IN K_SELECT expr_until_loop loop_
new->row = (PLpgSQL_row *)$4;
break;
default:
elog(ERROR, "unknown dtype %d in stmt_fors", $4->dtype);
elog(ERROR, "unrecognized dtype: %d",
$4->dtype);
}
new->query = $7;
new->body = $8;
......@@ -1117,7 +1127,8 @@ stmt_dynfors : opt_label K_FOR lno fors_target K_IN K_EXECUTE expr_until_loop lo
new->row = (PLpgSQL_row *)$4;
break;
default:
elog(ERROR, "unknown dtype %d in stmt_dynfors", $4->dtype);
elog(ERROR, "unrecognized dtype: %d",
$4->dtype);
}
new->query = $7;
new->body = $8;
......@@ -1375,7 +1386,11 @@ stmt_open : K_OPEN lno cursor_varptr
if (tok != K_FOR)
{
plpgsql_error_lineno = $2;
elog(ERROR, "syntax error at \"%s\" - expected FOR to open a reference cursor", yytext);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("syntax error at \"%s\"",
yytext),
errdetail("Expected FOR to open a reference cursor.")));
}
tok = yylex();
......@@ -1391,7 +1406,10 @@ stmt_open : K_OPEN lno cursor_varptr
default:
plpgsql_error_lineno = $2;
elog(ERROR, "syntax error at \"%s\"", yytext);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("syntax error at \"%s\"",
yytext)));
}
}
......@@ -1406,8 +1424,10 @@ stmt_open : K_OPEN lno cursor_varptr
if (tok != '(')
{
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "cursor %s has arguments",
$3->refname);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cursor \"%s\" has arguments",
$3->refname)));
}
/*
......@@ -1428,7 +1448,8 @@ stmt_open : K_OPEN lno cursor_varptr
if (strncmp(cp, "SELECT", 6) != 0)
{
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "expected 'SELECT (', got '%s' (internal error)",
/* internal error */
elog(ERROR, "expected \"SELECT (\", got \"%s\"",
new->argquery->query);
}
cp += 6;
......@@ -1437,7 +1458,8 @@ stmt_open : K_OPEN lno cursor_varptr
if (*cp != '(')
{
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "expected 'SELECT (', got '%s' (internal error)",
/* internal error */
elog(ERROR, "expected \"SELECT (\", got \"%s\"",
new->argquery->query);
}
*cp = ' ';
......@@ -1455,13 +1477,19 @@ stmt_open : K_OPEN lno cursor_varptr
if (tok == '(')
{
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "cursor %s has no arguments", $3->refname);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cursor \"%s\" has no arguments",
$3->refname)));
}
if (tok != ';')
{
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "syntax error at \"%s\"", yytext);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("syntax error at \"%s\"",
yytext)));
}
}
}
......@@ -1503,8 +1531,10 @@ cursor_varptr : T_VARIABLE
if (((PLpgSQL_var *) yylval.variable)->datatype->typoid != REFCURSOROID)
{
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "%s must be of type cursor or refcursor",
((PLpgSQL_var *) yylval.variable)->refname);
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("\"%s\" must be of type cursor or refcursor",
((PLpgSQL_var *) yylval.variable)->refname)));
}
$$ = (PLpgSQL_var *) yylval.variable;
}
......@@ -1518,8 +1548,10 @@ cursor_variable : T_VARIABLE
if (((PLpgSQL_var *) yylval.variable)->datatype->typoid != REFCURSOROID)
{
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "%s must be of type refcursor",
((PLpgSQL_var *) yylval.variable)->refname);
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("\"%s\" must be of type refcursor",
((PLpgSQL_var *) yylval.variable)->refname)));
}
$$ = yylval.variable->dno;
}
......@@ -1632,7 +1664,9 @@ read_sql_construct(int until,
{
parenlevel--;
if (parenlevel < 0)
elog(ERROR, "mismatched parentheses");
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("mismatched parentheses")));
}
/*
* End of function definition is an error, and we don't expect to
......@@ -1643,13 +1677,19 @@ read_sql_construct(int until,
{
plpgsql_error_lineno = lno;
if (parenlevel != 0)
elog(ERROR, "mismatched parentheses");
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("mismatched parentheses")));
if (isexpression)
elog(ERROR, "missing %s at end of SQL expression",
expected);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("missing \"%s\" at end of SQL expression",
expected)));
else
elog(ERROR, "missing %s at end of SQL statement",
expected);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("missing \"%s\" at end of SQL statement",
expected)));
break;
}
if (plpgsql_SpaceScanned)
......@@ -1709,8 +1749,12 @@ read_datatype(int tok)
{
plpgsql_error_lineno = lno;
if (parenlevel != 0)
elog(ERROR, "mismatched parentheses");
elog(ERROR, "incomplete datatype declaration");
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("mismatched parentheses")));
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("incomplete datatype declaration")));
}
/* Possible followers for datatype in a declaration */
if (tok == K_NOT || tok == K_ASSIGN || tok == K_DEFAULT)
......@@ -1769,14 +1813,18 @@ make_select_stmt(void)
if (tok == 0)
{
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "unexpected end of file");
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("unexpected end of function definition")));
}
if (tok == K_INTO)
{
if (have_into)
{
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "INTO specified more than once");
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("INTO specified more than once")));
}
tok = yylex();
switch (tok)
......@@ -1814,8 +1862,10 @@ make_select_stmt(void)
default:
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "plpgsql: %s is not a variable",
yytext);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("\"%s\" is not a variable",
yytext)));
}
}
have_nexttok = 1;
......@@ -1945,8 +1995,10 @@ make_fetch_stmt(void)
default:
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "plpgsql: %s is not a variable",
yytext);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("\"%s\" is not a variable",
yytext)));
}
}
have_nexttok = 1;
......@@ -2028,8 +2080,10 @@ check_assignable(PLpgSQL_datum *datum)
if (((PLpgSQL_var *) datum)->isconst)
{
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "%s is declared CONSTANT",
((PLpgSQL_var *) datum)->refname);
ereport(ERROR,
(errcode(ERRCODE_ERROR_IN_ASSIGNMENT),
errmsg("\"%s\" is declared CONSTANT",
((PLpgSQL_var *) datum)->refname)));
}
break;
case PLPGSQL_DTYPE_RECFIELD:
......
......@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.59 2003/07/01 21:47:09 tgl Exp $
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.60 2003/07/25 23:37:28 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
......@@ -154,7 +154,7 @@ plpgsql_compile(FunctionCallInfo fcinfo)
ObjectIdGetDatum(funcOid),
0, 0, 0);
if (!HeapTupleIsValid(procTup))
elog(ERROR, "plpgsql: cache lookup for proc %u failed", funcOid);
elog(ERROR, "cache lookup failed for function %u", funcOid);
procStruct = (Form_pg_proc) GETSTRUCT(procTup);
/*
......@@ -301,15 +301,21 @@ do_compile(FunctionCallInfo fcinfo,
* Check for a polymorphic returntype. If found, use the actual
* returntype type from the caller's FuncExpr node, if we
* have one.
*
* Note: errcode is FEATURE_NOT_SUPPORTED because it should always
* work; if it doesn't we're in some context that fails to make
* the info available.
*/
rettypeid = procStruct->prorettype;
if (rettypeid == ANYARRAYOID || rettypeid == ANYELEMENTOID)
{
rettypeid = get_fn_expr_rettype(fcinfo->flinfo);
if (!OidIsValid(rettypeid))
elog(ERROR, "could not determine actual return type "
"for polymorphic function %s",
plpgsql_error_funcname);
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("could not determine actual return type "
"for polymorphic function \"%s\"",
plpgsql_error_funcname)));
}
/*
......@@ -325,8 +331,7 @@ do_compile(FunctionCallInfo fcinfo,
ObjectIdGetDatum(rettypeid),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup for return type %u failed",
rettypeid);
elog(ERROR, "cache lookup failed for type %u", rettypeid);
typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
/* Disallow pseudotype result, except VOID or RECORD */
......@@ -337,12 +342,14 @@ do_compile(FunctionCallInfo fcinfo,
rettypeid == RECORDOID)
/* okay */ ;
else if (rettypeid == TRIGGEROID)
elog(ERROR, "plpgsql functions cannot return type %s"
"\n\texcept when used as triggers",
format_type_be(rettypeid));
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("trigger functions may only be called as triggers")));
else
elog(ERROR, "plpgsql functions cannot return type %s",
format_type_be(rettypeid));
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plpgsql functions cannot return type %s",
format_type_be(rettypeid))));
}
if (typeStruct->typrelid != InvalidOid ||
......@@ -382,15 +389,16 @@ do_compile(FunctionCallInfo fcinfo,
ObjectIdGetDatum(argtypeid),
0, 0, 0);
if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup for argument type %u failed",
argtypeid);
elog(ERROR, "cache lookup failed for type %u", argtypeid);
typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
/* Disallow pseudotype argument */
/* (note we already replaced ANYARRAY/ANYELEMENT) */
if (typeStruct->typtype == 'p')
elog(ERROR, "plpgsql functions cannot take type %s",
format_type_be(argtypeid));
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plpgsql functions cannot take type %s",
format_type_be(argtypeid))));
if (typeStruct->typrelid != InvalidOid)
{
......@@ -601,8 +609,7 @@ do_compile(FunctionCallInfo fcinfo,
break;
default:
elog(ERROR, "unknown function type %u in plpgsql_compile()",
functype);
elog(ERROR, "unrecognized function typecode: %u", functype);
break;
}
......@@ -634,7 +641,7 @@ do_compile(FunctionCallInfo fcinfo,
*/
parse_rc = plpgsql_yyparse();
if (parse_rc != 0)
elog(ERROR, "plpgsql: parser returned %d ???", parse_rc);
elog(ERROR, "plpgsql parser returned %d", parse_rc);
plpgsql_scanner_finish();
......@@ -864,8 +871,10 @@ plpgsql_parse_dblword(char *word)
return T_VARIABLE;
}
}
elog(ERROR, "row %s doesn't have a field %s",
cp[0], cp[1]);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("row \"%s\" has no field \"%s\"",
cp[0], cp[1])));
}
default:
......@@ -969,8 +978,10 @@ plpgsql_parse_tripword(char *word)
return T_VARIABLE;
}
}
elog(ERROR, "row %s.%s doesn't have a field %s",
cp[0], cp[1], cp[2]);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("row \"%s.%s\" has no field \"%s\"",
cp[0], cp[1], cp[2])));
}
default:
......@@ -1188,8 +1199,7 @@ plpgsql_parse_dblwordtype(char *word)
ObjectIdGetDatum(attrStruct->atttypid),
0, 0, 0);
if (!HeapTupleIsValid(typetup))
elog(ERROR, "cache lookup for type %u of %s.%s failed",
attrStruct->atttypid, cp[0], cp[1]);
elog(ERROR, "cache lookup failed for type %u", attrStruct->atttypid);
/*
* Found that - build a compiler type struct and return it
......@@ -1300,8 +1310,7 @@ plpgsql_parse_tripwordtype(char *word)
ObjectIdGetDatum(attrStruct->atttypid),
0, 0, 0);
if (!HeapTupleIsValid(typetup))
elog(ERROR, "cache lookup for type %u of %s.%s failed",
attrStruct->atttypid, cp[0], cp[1]);
elog(ERROR, "cache lookup failed for type %u", attrStruct->atttypid);
/*
* Found that - build a compiler type struct and return it
......@@ -1339,7 +1348,9 @@ plpgsql_parse_wordrowtype(char *word)
/* Lookup the relation */
classOid = RelnameGetRelid(cp[0]);
if (!OidIsValid(classOid))
elog(ERROR, "%s: no such class", cp[0]);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_TABLE),
errmsg("relation \"%s\" does not exist", cp[0])));
/*
* Build and return the complete row definition
......@@ -1380,7 +1391,9 @@ plpgsql_parse_dblwordrowtype(char *word)
relvar = makeRangeVarFromNameList(stringToQualifiedNameList(cp, "plpgsql_parse_dblwordrowtype"));
classOid = RangeVarGetRelid(relvar, true);
if (!OidIsValid(classOid))
elog(ERROR, "%s: no such class", cp);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_TABLE),
errmsg("relation \"%s\" does not exist", cp)));
/*
* Build and return the complete row definition
......@@ -1420,7 +1433,9 @@ plpgsql_build_rowtype(Oid classOid)
classStruct->relkind != RELKIND_SEQUENCE &&
classStruct->relkind != RELKIND_VIEW &&
classStruct->relkind != RELKIND_COMPOSITE_TYPE)
elog(ERROR, "%s isn't a table", relname);
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("relation \"%s\" is not a table", relname)));
/*
* Create a row datum entry and all the required variables that it
......@@ -1451,8 +1466,8 @@ plpgsql_build_rowtype(Oid classOid)
Int16GetDatum(i + 1),
0, 0);
if (!HeapTupleIsValid(attrtup))
elog(ERROR, "cache lookup for attribute %d of class %s failed",
i + 1, relname);
elog(ERROR, "cache lookup failed for attribute %d of relation %u",
i + 1, classOid);
attrStruct = (Form_pg_attribute) GETSTRUCT(attrtup);
attname = NameStr(attrStruct->attname);
......@@ -1461,8 +1476,8 @@ plpgsql_build_rowtype(Oid classOid)
ObjectIdGetDatum(attrStruct->atttypid),
0, 0, 0);
if (!HeapTupleIsValid(typetup))
elog(ERROR, "cache lookup for type %u of %s.%s failed",
attrStruct->atttypid, relname, attname);
elog(ERROR, "cache lookup failed for type %u",
attrStruct->atttypid);
/*
* Create the internal variable
......@@ -1639,7 +1654,10 @@ void
plpgsql_yyerror(const char *s)
{
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "%s at or near \"%s\"", s, plpgsql_yytext);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
/* translator: first %s is a phrase like "syntax error" */
errmsg("%s at or near \"%s\"", s, plpgsql_yytext)));
}
......@@ -1678,9 +1696,11 @@ compute_function_hashkey(FmgrInfo *flinfo,
{
argtypeid = get_fn_expr_argtype(flinfo, i);
if (!OidIsValid(argtypeid))
elog(ERROR, "could not determine actual argument "
"type for polymorphic function %s",
NameStr(procStruct->proname));
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("could not determine actual argument "
"type for polymorphic function \"%s\"",
NameStr(procStruct->proname))));
}
hashkey->argtypes[i] = argtypeid;
......@@ -1729,9 +1749,11 @@ plpgsql_HashTableInsert(PLpgSQL_function *function,
HASH_ENTER,
&found);
if (hentry == NULL)
elog(ERROR, "out of memory in plpgsql_HashTable");
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
if (found)
elog(WARNING, "trying to insert a function that exists");
elog(WARNING, "trying to insert a function that already exists");
hentry->function = function;
/* prepare back link from function to hashtable key */
......
This diff is collapsed.
......@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.26 2003/05/23 04:08:34 tgl Exp $
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.27 2003/07/25 23:37:29 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
......@@ -313,7 +313,10 @@ plpgsql_ns_rename(char *oldname, char *newname)
}
}
elog(ERROR, "there is no variable '%s' in the current block", oldname);
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("there is no variable \"%s\" in the current block",
oldname)));
}
......@@ -366,7 +369,9 @@ plpgsql_convert_ident(const char *s, char **output, int numidents)
*cp++ = *s++;
}
if (*s != '"') /* should not happen if lexer checked */
elog(ERROR, "unterminated \" in name: %s", sstart);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("unterminated \" in name: %s", sstart)));
s++;
}
else
......@@ -403,8 +408,10 @@ plpgsql_convert_ident(const char *s, char **output, int numidents)
if (identctr < numidents)
output[identctr++] = curident;
else
elog(ERROR, "Qualified identifier cannot be used here: %s",
sstart);
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("qualified identifier cannot be used here: %s",
sstart)));
/* If not done, skip whitespace, dot, whitespace */
if (*s)
......@@ -412,16 +419,16 @@ plpgsql_convert_ident(const char *s, char **output, int numidents)
while (*s && isspace((unsigned char) *s))
s++;
if (*s++ != '.')
elog(ERROR, "Expected dot between identifiers: %s", sstart);
elog(ERROR, "expected dot between identifiers: %s", sstart);
while (*s && isspace((unsigned char) *s))
s++;
if (*s == '\0')
elog(ERROR, "Expected another identifier: %s", sstart);
elog(ERROR, "expected another identifier: %s", sstart);
}
}
if (identctr != numidents)
elog(ERROR, "Improperly qualified identifier: %s",
elog(ERROR, "improperly qualified identifier: %s",
sstart);
}
......@@ -586,7 +593,7 @@ dump_stmt(PLpgSQL_stmt * stmt)
dump_perform((PLpgSQL_stmt_perform *) stmt);
break;
default:
elog(ERROR, "plpgsql_dump: unknown cmd_type %d\n", stmt->cmd_type);
elog(ERROR, "unknown cmd_type: %d", stmt->cmd_type);
break;
}
}
......
......@@ -3,7 +3,7 @@
* procedural language
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.13 2003/07/01 21:47:09 tgl Exp $
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.14 2003/07/25 23:37:29 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
......@@ -65,7 +65,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS)
* Connect to SPI manager
*/
if (SPI_connect() != SPI_OK_CONNECT)
elog(ERROR, "plpgsql: cannot connect to SPI manager");
elog(ERROR, "could not connect to SPI manager");
/* Find or compile the function */
func = plpgsql_compile(fcinfo);
......@@ -84,7 +84,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS)
* Disconnect from SPI manager
*/
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "plpgsql: SPI_finish() failed");
elog(ERROR, "SPI_finish() failed");
return retval;
}
......@@ -4,7 +4,7 @@
* procedural language
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.28 2003/06/19 23:22:40 tgl Exp $
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Attic/scan.l,v 1.29 2003/07/25 23:37:29 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
......@@ -228,7 +228,9 @@ dump { return O_DUMP; }
\". {
plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "unterminated quoted identifier");
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("unterminated quoted identifier")));
}
/* ----------
......@@ -251,7 +253,9 @@ dump { return O_DUMP; }
<IN_COMMENT>. ;
<IN_COMMENT><<EOF>> {
plpgsql_error_lineno = start_lineno;
elog(ERROR, "unterminated comment");
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("unterminated comment")));
}
/* ----------
......@@ -277,7 +281,9 @@ dump { return O_DUMP; }
}
<IN_STRING><<EOF>> {
plpgsql_error_lineno = start_lineno;
elog(ERROR, "unterminated string");
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("unterminated string")));
}
<IN_STRING>[^'\\]* { }
......@@ -344,7 +350,7 @@ void
plpgsql_push_back_token(int token)
{
if (have_pushback_token)
elog(ERROR, "plpgsql_push_back_token: can't push back multiple tokens");
elog(ERROR, "cannot push back multiple tokens");
pushback_token = token;
have_pushback_token = true;
}
......
This diff is collapsed.
/* $Header: /cvsroot/pgsql/src/pl/plpython/Attic/plpython.h,v 1.7 2003/05/27 17:49:47 momjian Exp $ */
/* $Header: /cvsroot/pgsql/src/pl/plpython/Attic/plpython.h,v 1.8 2003/07/25 23:37:30 tgl Exp $ */
#ifndef PLPYTHON_H
#define PLPYTHON_H
......@@ -43,8 +43,8 @@
#if DEBUG_LEVEL
#define CALL_LEVEL_INC() do { PLy_call_level += 1; \
elog(DEBUG4, "Level: %d", PLy_call_level); } while (0)
#define CALL_LEVEL_DEC() do { elog(DEBUG4, "Level: %d", PLy_call_level); \
elog(DEBUG4, "level: %d", PLy_call_level); } while (0)
#define CALL_LEVEL_DEC() do { elog(DEBUG4, "level: %d", PLy_call_level); \
PLy_call_level -= 1; } while (0)
#else
#define CALL_LEVEL_INC() do { PLy_call_level += 1; } while (0)
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment