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 "postgres.h"
#include "utils/elog.h"
/* /*
* This kludge is necessary because of the conflicting * This kludge is necessary because of the conflicting
* definitions of 'DEBUG' between postgres and perl. * definitions of 'DEBUG' between postgres and perl.
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
* ENHANCEMENTS, OR MODIFICATIONS. * ENHANCEMENTS, OR MODIFICATIONS.
* *
* IDENTIFICATION * 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 @@ ...@@ -47,7 +47,6 @@
/* postgreSQL stuff */ /* postgreSQL stuff */
#include "executor/spi.h" #include "executor/spi.h"
#include "commands/trigger.h" #include "commands/trigger.h"
#include "utils/elog.h"
#include "fmgr.h" #include "fmgr.h"
#include "access/heapam.h" #include "access/heapam.h"
#include "tcop/tcopprot.h" #include "tcop/tcopprot.h"
...@@ -193,7 +192,7 @@ plperl_init_interp(void) ...@@ -193,7 +192,7 @@ plperl_init_interp(void)
plperl_interp = perl_alloc(); plperl_interp = perl_alloc();
if (!plperl_interp) 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_construct(plperl_interp);
perl_parse(plperl_interp, plperl_init_shared_libs, 3, embedding, NULL); perl_parse(plperl_interp, plperl_init_shared_libs, 3, embedding, NULL);
...@@ -232,7 +231,7 @@ plperl_call_handler(PG_FUNCTION_ARGS) ...@@ -232,7 +231,7 @@ plperl_call_handler(PG_FUNCTION_ARGS)
* Connect to SPI manager * Connect to SPI manager
************************************************************/ ************************************************************/
if (SPI_connect() != SPI_OK_CONNECT) 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 * Determine if called as function or trigger and
...@@ -240,7 +239,9 @@ plperl_call_handler(PG_FUNCTION_ARGS) ...@@ -240,7 +239,9 @@ plperl_call_handler(PG_FUNCTION_ARGS)
************************************************************/ ************************************************************/
if (CALLED_AS_TRIGGER(fcinfo)) 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)); * retval = PointerGetDatum(plperl_trigger_handler(fcinfo));
...@@ -286,7 +287,7 @@ plperl_create_sub(char *s, bool trusted) ...@@ -286,7 +287,7 @@ plperl_create_sub(char *s, bool trusted)
PUTBACK; PUTBACK;
FREETMPS; FREETMPS;
LEAVE; 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)) if (SvTRUE(ERRSV))
...@@ -314,7 +315,7 @@ plperl_create_sub(char *s, bool trusted) ...@@ -314,7 +315,7 @@ plperl_create_sub(char *s, bool trusted)
* subref is our responsibility because it is not mortal * subref is our responsibility because it is not mortal
*/ */
SvREFCNT_dec(subref); SvREFCNT_dec(subref);
elog(ERROR, "plperl_create_sub: didn't get a code ref"); elog(ERROR, "didn't get a code ref");
} }
PUTBACK; PUTBACK;
...@@ -406,7 +407,7 @@ plperl_call_perl_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo) ...@@ -406,7 +407,7 @@ plperl_call_perl_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo)
PUTBACK; PUTBACK;
FREETMPS; FREETMPS;
LEAVE; 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)) if (SvTRUE(ERRSV))
...@@ -415,7 +416,7 @@ plperl_call_perl_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo) ...@@ -415,7 +416,7 @@ plperl_call_perl_func(plperl_proc_desc * desc, FunctionCallInfo fcinfo)
PUTBACK; PUTBACK;
FREETMPS; FREETMPS;
LEAVE; 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); retval = newSVsv(POPs);
...@@ -453,7 +454,7 @@ plperl_func_handler(PG_FUNCTION_ARGS) ...@@ -453,7 +454,7 @@ plperl_func_handler(PG_FUNCTION_ARGS)
* because SPI_finish would free it). * because SPI_finish would free it).
************************************************************/ ************************************************************/
if (SPI_finish() != SPI_OK_FINISH) if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "plperl: SPI_finish() failed"); elog(ERROR, "SPI_finish() failed");
if (!(perlret && SvOK(perlret))) if (!(perlret && SvOK(perlret)))
{ {
...@@ -493,7 +494,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) ...@@ -493,7 +494,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
ObjectIdGetDatum(fn_oid), ObjectIdGetDatum(fn_oid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(procTup)) 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); procStruct = (Form_pg_proc) GETSTRUCT(procTup);
/************************************************************ /************************************************************
...@@ -551,7 +552,9 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) ...@@ -551,7 +552,9 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
************************************************************/ ************************************************************/
prodesc = (plperl_proc_desc *) malloc(sizeof(plperl_proc_desc)); prodesc = (plperl_proc_desc *) malloc(sizeof(plperl_proc_desc));
if (prodesc == NULL) 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)); MemSet(prodesc, 0, sizeof(plperl_proc_desc));
prodesc->proname = strdup(internal_proname); prodesc->proname = strdup(internal_proname);
prodesc->fn_xmin = HeapTupleHeaderGetXmin(procTup->t_data); prodesc->fn_xmin = HeapTupleHeaderGetXmin(procTup->t_data);
...@@ -567,7 +570,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) ...@@ -567,7 +570,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{ {
free(prodesc->proname); free(prodesc->proname);
free(prodesc); free(prodesc);
elog(ERROR, "plperl: cache lookup for language %u failed", elog(ERROR, "cache lookup failed for language %u",
procStruct->prolang); procStruct->prolang);
} }
langStruct = (Form_pg_language) GETSTRUCT(langTup); langStruct = (Form_pg_language) GETSTRUCT(langTup);
...@@ -587,7 +590,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) ...@@ -587,7 +590,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{ {
free(prodesc->proname); free(prodesc->proname);
free(prodesc); free(prodesc);
elog(ERROR, "plperl: cache lookup for return type %u failed", elog(ERROR, "cache lookup failed for type %u",
procStruct->prorettype); procStruct->prorettype);
} }
typeStruct = (Form_pg_type) GETSTRUCT(typeTup); typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
...@@ -601,16 +604,18 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) ...@@ -601,16 +604,18 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{ {
free(prodesc->proname); free(prodesc->proname);
free(prodesc); free(prodesc);
elog(ERROR, "plperl functions cannot return type %s" ereport(ERROR,
"\n\texcept when used as triggers", (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
format_type_be(procStruct->prorettype)); errmsg("trigger functions may only be called as triggers")));
} }
else else
{ {
free(prodesc->proname); free(prodesc->proname);
free(prodesc); free(prodesc);
elog(ERROR, "plperl functions cannot return type %s", ereport(ERROR,
format_type_be(procStruct->prorettype)); (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) ...@@ -618,7 +623,9 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{ {
free(prodesc->proname); free(prodesc->proname);
free(prodesc); 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)); perm_fmgr_info(typeStruct->typinput, &(prodesc->result_in_func));
...@@ -643,7 +650,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) ...@@ -643,7 +650,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{ {
free(prodesc->proname); free(prodesc->proname);
free(prodesc); free(prodesc);
elog(ERROR, "plperl: cache lookup for argument type %u failed", elog(ERROR, "cache lookup failed for type %u",
procStruct->proargtypes[i]); procStruct->proargtypes[i]);
} }
typeStruct = (Form_pg_type) GETSTRUCT(typeTup); typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
...@@ -653,8 +660,10 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) ...@@ -653,8 +660,10 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{ {
free(prodesc->proname); free(prodesc->proname);
free(prodesc); free(prodesc);
elog(ERROR, "plperl functions cannot take type %s", ereport(ERROR,
format_type_be(procStruct->proargtypes[i])); (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plperl functions cannot take type %s",
format_type_be(procStruct->proargtypes[i]))));
} }
if (typeStruct->typrelid != InvalidOid) if (typeStruct->typrelid != InvalidOid)
...@@ -686,7 +695,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) ...@@ -686,7 +695,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger)
{ {
free(prodesc->proname); free(prodesc->proname);
free(prodesc); free(prodesc);
elog(ERROR, "plperl: cannot create internal procedure %s", elog(ERROR, "could not create internal procedure \"%s\"",
internal_proname); internal_proname);
} }
...@@ -751,8 +760,8 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc) ...@@ -751,8 +760,8 @@ plperl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc)
ObjectIdGetDatum(tupdesc->attrs[i]->atttypid), ObjectIdGetDatum(tupdesc->attrs[i]->atttypid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(typeTup)) if (!HeapTupleIsValid(typeTup))
elog(ERROR, "plperl: Cache lookup for attribute '%s' type %u failed", elog(ERROR, "cache lookup failed for type %u",
attname, tupdesc->attrs[i]->atttypid); tupdesc->attrs[i]->atttypid);
typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput; typoutput = ((Form_pg_type) GETSTRUCT(typeTup))->typoutput;
typelem = ((Form_pg_type) GETSTRUCT(typeTup))->typelem; typelem = ((Form_pg_type) GETSTRUCT(typeTup))->typelem;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * 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. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -340,11 +340,17 @@ decl_statement : decl_varname decl_const decl_datatype decl_notnull decl_defval ...@@ -340,11 +340,17 @@ decl_statement : decl_varname decl_const decl_datatype decl_notnull decl_defval
row->lineno = $1.lineno; row->lineno = $1.lineno;
if ($2) if ($2)
elog(ERROR, "Rowtype variable cannot be CONSTANT"); ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("rowtype variable cannot be CONSTANT")));
if ($4) 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) 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_adddatum((PLpgSQL_datum *)row);
plpgsql_ns_additem(PLPGSQL_NSTYPE_ROW, plpgsql_ns_additem(PLPGSQL_NSTYPE_ROW,
...@@ -554,7 +560,10 @@ decl_aliasitem : T_WORD ...@@ -554,7 +560,10 @@ decl_aliasitem : T_WORD
if (nsi == NULL) if (nsi == NULL)
{ {
plpgsql_error_lineno = plpgsql_scanner_lineno(); 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); 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_ ...@@ -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; new->row = (PLpgSQL_row *)$4;
break; break;
default: default:
elog(ERROR, "unknown dtype %d in stmt_fors", $4->dtype); elog(ERROR, "unrecognized dtype: %d",
$4->dtype);
} }
new->query = $7; new->query = $7;
new->body = $8; new->body = $8;
...@@ -1117,7 +1127,8 @@ stmt_dynfors : opt_label K_FOR lno fors_target K_IN K_EXECUTE expr_until_loop lo ...@@ -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; new->row = (PLpgSQL_row *)$4;
break; break;
default: default:
elog(ERROR, "unknown dtype %d in stmt_dynfors", $4->dtype); elog(ERROR, "unrecognized dtype: %d",
$4->dtype);
} }
new->query = $7; new->query = $7;
new->body = $8; new->body = $8;
...@@ -1375,7 +1386,11 @@ stmt_open : K_OPEN lno cursor_varptr ...@@ -1375,7 +1386,11 @@ stmt_open : K_OPEN lno cursor_varptr
if (tok != K_FOR) if (tok != K_FOR)
{ {
plpgsql_error_lineno = $2; 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(); tok = yylex();
...@@ -1391,7 +1406,10 @@ stmt_open : K_OPEN lno cursor_varptr ...@@ -1391,7 +1406,10 @@ stmt_open : K_OPEN lno cursor_varptr
default: default:
plpgsql_error_lineno = $2; 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 ...@@ -1406,8 +1424,10 @@ stmt_open : K_OPEN lno cursor_varptr
if (tok != '(') if (tok != '(')
{ {
plpgsql_error_lineno = plpgsql_scanner_lineno(); plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "cursor %s has arguments", ereport(ERROR,
$3->refname); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cursor \"%s\" has arguments",
$3->refname)));
} }
/* /*
...@@ -1428,7 +1448,8 @@ stmt_open : K_OPEN lno cursor_varptr ...@@ -1428,7 +1448,8 @@ stmt_open : K_OPEN lno cursor_varptr
if (strncmp(cp, "SELECT", 6) != 0) if (strncmp(cp, "SELECT", 6) != 0)
{ {
plpgsql_error_lineno = plpgsql_scanner_lineno(); 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); new->argquery->query);
} }
cp += 6; cp += 6;
...@@ -1437,7 +1458,8 @@ stmt_open : K_OPEN lno cursor_varptr ...@@ -1437,7 +1458,8 @@ stmt_open : K_OPEN lno cursor_varptr
if (*cp != '(') if (*cp != '(')
{ {
plpgsql_error_lineno = plpgsql_scanner_lineno(); 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); new->argquery->query);
} }
*cp = ' '; *cp = ' ';
...@@ -1455,13 +1477,19 @@ stmt_open : K_OPEN lno cursor_varptr ...@@ -1455,13 +1477,19 @@ stmt_open : K_OPEN lno cursor_varptr
if (tok == '(') if (tok == '(')
{ {
plpgsql_error_lineno = plpgsql_scanner_lineno(); 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 != ';') if (tok != ';')
{ {
plpgsql_error_lineno = plpgsql_scanner_lineno(); 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 ...@@ -1503,8 +1531,10 @@ cursor_varptr : T_VARIABLE
if (((PLpgSQL_var *) yylval.variable)->datatype->typoid != REFCURSOROID) if (((PLpgSQL_var *) yylval.variable)->datatype->typoid != REFCURSOROID)
{ {
plpgsql_error_lineno = plpgsql_scanner_lineno(); plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "%s must be of type cursor or refcursor", ereport(ERROR,
((PLpgSQL_var *) yylval.variable)->refname); (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("\"%s\" must be of type cursor or refcursor",
((PLpgSQL_var *) yylval.variable)->refname)));
} }
$$ = (PLpgSQL_var *) yylval.variable; $$ = (PLpgSQL_var *) yylval.variable;
} }
...@@ -1518,8 +1548,10 @@ cursor_variable : T_VARIABLE ...@@ -1518,8 +1548,10 @@ cursor_variable : T_VARIABLE
if (((PLpgSQL_var *) yylval.variable)->datatype->typoid != REFCURSOROID) if (((PLpgSQL_var *) yylval.variable)->datatype->typoid != REFCURSOROID)
{ {
plpgsql_error_lineno = plpgsql_scanner_lineno(); plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "%s must be of type refcursor", ereport(ERROR,
((PLpgSQL_var *) yylval.variable)->refname); (errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("\"%s\" must be of type refcursor",
((PLpgSQL_var *) yylval.variable)->refname)));
} }
$$ = yylval.variable->dno; $$ = yylval.variable->dno;
} }
...@@ -1632,7 +1664,9 @@ read_sql_construct(int until, ...@@ -1632,7 +1664,9 @@ read_sql_construct(int until,
{ {
parenlevel--; parenlevel--;
if (parenlevel < 0) 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 * End of function definition is an error, and we don't expect to
...@@ -1643,13 +1677,19 @@ read_sql_construct(int until, ...@@ -1643,13 +1677,19 @@ read_sql_construct(int until,
{ {
plpgsql_error_lineno = lno; plpgsql_error_lineno = lno;
if (parenlevel != 0) if (parenlevel != 0)
elog(ERROR, "mismatched parentheses"); ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("mismatched parentheses")));
if (isexpression) if (isexpression)
elog(ERROR, "missing %s at end of SQL expression", ereport(ERROR,
expected); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("missing \"%s\" at end of SQL expression",
expected)));
else else
elog(ERROR, "missing %s at end of SQL statement", ereport(ERROR,
expected); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("missing \"%s\" at end of SQL statement",
expected)));
break; break;
} }
if (plpgsql_SpaceScanned) if (plpgsql_SpaceScanned)
...@@ -1709,8 +1749,12 @@ read_datatype(int tok) ...@@ -1709,8 +1749,12 @@ read_datatype(int tok)
{ {
plpgsql_error_lineno = lno; plpgsql_error_lineno = lno;
if (parenlevel != 0) if (parenlevel != 0)
elog(ERROR, "mismatched parentheses"); ereport(ERROR,
elog(ERROR, "incomplete datatype declaration"); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("mismatched parentheses")));
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("incomplete datatype declaration")));
} }
/* Possible followers for datatype in a declaration */ /* Possible followers for datatype in a declaration */
if (tok == K_NOT || tok == K_ASSIGN || tok == K_DEFAULT) if (tok == K_NOT || tok == K_ASSIGN || tok == K_DEFAULT)
...@@ -1769,14 +1813,18 @@ make_select_stmt(void) ...@@ -1769,14 +1813,18 @@ make_select_stmt(void)
if (tok == 0) if (tok == 0)
{ {
plpgsql_error_lineno = plpgsql_scanner_lineno(); 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 (tok == K_INTO)
{ {
if (have_into) if (have_into)
{ {
plpgsql_error_lineno = plpgsql_scanner_lineno(); 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(); tok = yylex();
switch (tok) switch (tok)
...@@ -1814,8 +1862,10 @@ make_select_stmt(void) ...@@ -1814,8 +1862,10 @@ make_select_stmt(void)
default: default:
plpgsql_error_lineno = plpgsql_scanner_lineno(); plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "plpgsql: %s is not a variable", ereport(ERROR,
yytext); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("\"%s\" is not a variable",
yytext)));
} }
} }
have_nexttok = 1; have_nexttok = 1;
...@@ -1945,8 +1995,10 @@ make_fetch_stmt(void) ...@@ -1945,8 +1995,10 @@ make_fetch_stmt(void)
default: default:
plpgsql_error_lineno = plpgsql_scanner_lineno(); plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "plpgsql: %s is not a variable", ereport(ERROR,
yytext); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("\"%s\" is not a variable",
yytext)));
} }
} }
have_nexttok = 1; have_nexttok = 1;
...@@ -2028,8 +2080,10 @@ check_assignable(PLpgSQL_datum *datum) ...@@ -2028,8 +2080,10 @@ check_assignable(PLpgSQL_datum *datum)
if (((PLpgSQL_var *) datum)->isconst) if (((PLpgSQL_var *) datum)->isconst)
{ {
plpgsql_error_lineno = plpgsql_scanner_lineno(); plpgsql_error_lineno = plpgsql_scanner_lineno();
elog(ERROR, "%s is declared CONSTANT", ereport(ERROR,
((PLpgSQL_var *) datum)->refname); (errcode(ERRCODE_ERROR_IN_ASSIGNMENT),
errmsg("\"%s\" is declared CONSTANT",
((PLpgSQL_var *) datum)->refname)));
} }
break; break;
case PLPGSQL_DTYPE_RECFIELD: case PLPGSQL_DTYPE_RECFIELD:
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * 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. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -154,7 +154,7 @@ plpgsql_compile(FunctionCallInfo fcinfo) ...@@ -154,7 +154,7 @@ plpgsql_compile(FunctionCallInfo fcinfo)
ObjectIdGetDatum(funcOid), ObjectIdGetDatum(funcOid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(procTup)) 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); procStruct = (Form_pg_proc) GETSTRUCT(procTup);
/* /*
...@@ -301,15 +301,21 @@ do_compile(FunctionCallInfo fcinfo, ...@@ -301,15 +301,21 @@ do_compile(FunctionCallInfo fcinfo,
* Check for a polymorphic returntype. If found, use the actual * Check for a polymorphic returntype. If found, use the actual
* returntype type from the caller's FuncExpr node, if we * returntype type from the caller's FuncExpr node, if we
* have one. * 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; rettypeid = procStruct->prorettype;
if (rettypeid == ANYARRAYOID || rettypeid == ANYELEMENTOID) if (rettypeid == ANYARRAYOID || rettypeid == ANYELEMENTOID)
{ {
rettypeid = get_fn_expr_rettype(fcinfo->flinfo); rettypeid = get_fn_expr_rettype(fcinfo->flinfo);
if (!OidIsValid(rettypeid)) if (!OidIsValid(rettypeid))
elog(ERROR, "could not determine actual return type " ereport(ERROR,
"for polymorphic function %s", (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
plpgsql_error_funcname); errmsg("could not determine actual return type "
"for polymorphic function \"%s\"",
plpgsql_error_funcname)));
} }
/* /*
...@@ -325,8 +331,7 @@ do_compile(FunctionCallInfo fcinfo, ...@@ -325,8 +331,7 @@ do_compile(FunctionCallInfo fcinfo,
ObjectIdGetDatum(rettypeid), ObjectIdGetDatum(rettypeid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(typeTup)) if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup for return type %u failed", elog(ERROR, "cache lookup failed for type %u", rettypeid);
rettypeid);
typeStruct = (Form_pg_type) GETSTRUCT(typeTup); typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
/* Disallow pseudotype result, except VOID or RECORD */ /* Disallow pseudotype result, except VOID or RECORD */
...@@ -337,12 +342,14 @@ do_compile(FunctionCallInfo fcinfo, ...@@ -337,12 +342,14 @@ do_compile(FunctionCallInfo fcinfo,
rettypeid == RECORDOID) rettypeid == RECORDOID)
/* okay */ ; /* okay */ ;
else if (rettypeid == TRIGGEROID) else if (rettypeid == TRIGGEROID)
elog(ERROR, "plpgsql functions cannot return type %s" ereport(ERROR,
"\n\texcept when used as triggers", (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
format_type_be(rettypeid)); errmsg("trigger functions may only be called as triggers")));
else else
elog(ERROR, "plpgsql functions cannot return type %s", ereport(ERROR,
format_type_be(rettypeid)); (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plpgsql functions cannot return type %s",
format_type_be(rettypeid))));
} }
if (typeStruct->typrelid != InvalidOid || if (typeStruct->typrelid != InvalidOid ||
...@@ -382,15 +389,16 @@ do_compile(FunctionCallInfo fcinfo, ...@@ -382,15 +389,16 @@ do_compile(FunctionCallInfo fcinfo,
ObjectIdGetDatum(argtypeid), ObjectIdGetDatum(argtypeid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(typeTup)) if (!HeapTupleIsValid(typeTup))
elog(ERROR, "cache lookup for argument type %u failed", elog(ERROR, "cache lookup failed for type %u", argtypeid);
argtypeid);
typeStruct = (Form_pg_type) GETSTRUCT(typeTup); typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
/* Disallow pseudotype argument */ /* Disallow pseudotype argument */
/* (note we already replaced ANYARRAY/ANYELEMENT) */ /* (note we already replaced ANYARRAY/ANYELEMENT) */
if (typeStruct->typtype == 'p') if (typeStruct->typtype == 'p')
elog(ERROR, "plpgsql functions cannot take type %s", ereport(ERROR,
format_type_be(argtypeid)); (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plpgsql functions cannot take type %s",
format_type_be(argtypeid))));
if (typeStruct->typrelid != InvalidOid) if (typeStruct->typrelid != InvalidOid)
{ {
...@@ -601,8 +609,7 @@ do_compile(FunctionCallInfo fcinfo, ...@@ -601,8 +609,7 @@ do_compile(FunctionCallInfo fcinfo,
break; break;
default: default:
elog(ERROR, "unknown function type %u in plpgsql_compile()", elog(ERROR, "unrecognized function typecode: %u", functype);
functype);
break; break;
} }
...@@ -634,7 +641,7 @@ do_compile(FunctionCallInfo fcinfo, ...@@ -634,7 +641,7 @@ do_compile(FunctionCallInfo fcinfo,
*/ */
parse_rc = plpgsql_yyparse(); parse_rc = plpgsql_yyparse();
if (parse_rc != 0) if (parse_rc != 0)
elog(ERROR, "plpgsql: parser returned %d ???", parse_rc); elog(ERROR, "plpgsql parser returned %d", parse_rc);
plpgsql_scanner_finish(); plpgsql_scanner_finish();
...@@ -864,8 +871,10 @@ plpgsql_parse_dblword(char *word) ...@@ -864,8 +871,10 @@ plpgsql_parse_dblword(char *word)
return T_VARIABLE; return T_VARIABLE;
} }
} }
elog(ERROR, "row %s doesn't have a field %s", ereport(ERROR,
cp[0], cp[1]); (errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("row \"%s\" has no field \"%s\"",
cp[0], cp[1])));
} }
default: default:
...@@ -969,8 +978,10 @@ plpgsql_parse_tripword(char *word) ...@@ -969,8 +978,10 @@ plpgsql_parse_tripword(char *word)
return T_VARIABLE; return T_VARIABLE;
} }
} }
elog(ERROR, "row %s.%s doesn't have a field %s", ereport(ERROR,
cp[0], cp[1], cp[2]); (errcode(ERRCODE_UNDEFINED_COLUMN),
errmsg("row \"%s.%s\" has no field \"%s\"",
cp[0], cp[1], cp[2])));
} }
default: default:
...@@ -1188,8 +1199,7 @@ plpgsql_parse_dblwordtype(char *word) ...@@ -1188,8 +1199,7 @@ plpgsql_parse_dblwordtype(char *word)
ObjectIdGetDatum(attrStruct->atttypid), ObjectIdGetDatum(attrStruct->atttypid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(typetup)) if (!HeapTupleIsValid(typetup))
elog(ERROR, "cache lookup for type %u of %s.%s failed", elog(ERROR, "cache lookup failed for type %u", attrStruct->atttypid);
attrStruct->atttypid, cp[0], cp[1]);
/* /*
* Found that - build a compiler type struct and return it * Found that - build a compiler type struct and return it
...@@ -1300,8 +1310,7 @@ plpgsql_parse_tripwordtype(char *word) ...@@ -1300,8 +1310,7 @@ plpgsql_parse_tripwordtype(char *word)
ObjectIdGetDatum(attrStruct->atttypid), ObjectIdGetDatum(attrStruct->atttypid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(typetup)) if (!HeapTupleIsValid(typetup))
elog(ERROR, "cache lookup for type %u of %s.%s failed", elog(ERROR, "cache lookup failed for type %u", attrStruct->atttypid);
attrStruct->atttypid, cp[0], cp[1]);
/* /*
* Found that - build a compiler type struct and return it * Found that - build a compiler type struct and return it
...@@ -1339,7 +1348,9 @@ plpgsql_parse_wordrowtype(char *word) ...@@ -1339,7 +1348,9 @@ plpgsql_parse_wordrowtype(char *word)
/* Lookup the relation */ /* Lookup the relation */
classOid = RelnameGetRelid(cp[0]); classOid = RelnameGetRelid(cp[0]);
if (!OidIsValid(classOid)) 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 * Build and return the complete row definition
...@@ -1380,7 +1391,9 @@ plpgsql_parse_dblwordrowtype(char *word) ...@@ -1380,7 +1391,9 @@ plpgsql_parse_dblwordrowtype(char *word)
relvar = makeRangeVarFromNameList(stringToQualifiedNameList(cp, "plpgsql_parse_dblwordrowtype")); relvar = makeRangeVarFromNameList(stringToQualifiedNameList(cp, "plpgsql_parse_dblwordrowtype"));
classOid = RangeVarGetRelid(relvar, true); classOid = RangeVarGetRelid(relvar, true);
if (!OidIsValid(classOid)) 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 * Build and return the complete row definition
...@@ -1420,7 +1433,9 @@ plpgsql_build_rowtype(Oid classOid) ...@@ -1420,7 +1433,9 @@ plpgsql_build_rowtype(Oid classOid)
classStruct->relkind != RELKIND_SEQUENCE && classStruct->relkind != RELKIND_SEQUENCE &&
classStruct->relkind != RELKIND_VIEW && classStruct->relkind != RELKIND_VIEW &&
classStruct->relkind != RELKIND_COMPOSITE_TYPE) 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 * Create a row datum entry and all the required variables that it
...@@ -1451,8 +1466,8 @@ plpgsql_build_rowtype(Oid classOid) ...@@ -1451,8 +1466,8 @@ plpgsql_build_rowtype(Oid classOid)
Int16GetDatum(i + 1), Int16GetDatum(i + 1),
0, 0); 0, 0);
if (!HeapTupleIsValid(attrtup)) if (!HeapTupleIsValid(attrtup))
elog(ERROR, "cache lookup for attribute %d of class %s failed", elog(ERROR, "cache lookup failed for attribute %d of relation %u",
i + 1, relname); i + 1, classOid);
attrStruct = (Form_pg_attribute) GETSTRUCT(attrtup); attrStruct = (Form_pg_attribute) GETSTRUCT(attrtup);
attname = NameStr(attrStruct->attname); attname = NameStr(attrStruct->attname);
...@@ -1461,8 +1476,8 @@ plpgsql_build_rowtype(Oid classOid) ...@@ -1461,8 +1476,8 @@ plpgsql_build_rowtype(Oid classOid)
ObjectIdGetDatum(attrStruct->atttypid), ObjectIdGetDatum(attrStruct->atttypid),
0, 0, 0); 0, 0, 0);
if (!HeapTupleIsValid(typetup)) if (!HeapTupleIsValid(typetup))
elog(ERROR, "cache lookup for type %u of %s.%s failed", elog(ERROR, "cache lookup failed for type %u",
attrStruct->atttypid, relname, attname); attrStruct->atttypid);
/* /*
* Create the internal variable * Create the internal variable
...@@ -1639,7 +1654,10 @@ void ...@@ -1639,7 +1654,10 @@ void
plpgsql_yyerror(const char *s) plpgsql_yyerror(const char *s)
{ {
plpgsql_error_lineno = plpgsql_scanner_lineno(); 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, ...@@ -1678,9 +1696,11 @@ compute_function_hashkey(FmgrInfo *flinfo,
{ {
argtypeid = get_fn_expr_argtype(flinfo, i); argtypeid = get_fn_expr_argtype(flinfo, i);
if (!OidIsValid(argtypeid)) if (!OidIsValid(argtypeid))
elog(ERROR, "could not determine actual argument " ereport(ERROR,
"type for polymorphic function %s", (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
NameStr(procStruct->proname)); errmsg("could not determine actual argument "
"type for polymorphic function \"%s\"",
NameStr(procStruct->proname))));
} }
hashkey->argtypes[i] = argtypeid; hashkey->argtypes[i] = argtypeid;
...@@ -1729,9 +1749,11 @@ plpgsql_HashTableInsert(PLpgSQL_function *function, ...@@ -1729,9 +1749,11 @@ plpgsql_HashTableInsert(PLpgSQL_function *function,
HASH_ENTER, HASH_ENTER,
&found); &found);
if (hentry == NULL) if (hentry == NULL)
elog(ERROR, "out of memory in plpgsql_HashTable"); ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory")));
if (found) if (found)
elog(WARNING, "trying to insert a function that exists"); elog(WARNING, "trying to insert a function that already exists");
hentry->function = function; hentry->function = function;
/* prepare back link from function to hashtable key */ /* prepare back link from function to hashtable key */
......
This diff is collapsed.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * 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. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -313,7 +313,10 @@ plpgsql_ns_rename(char *oldname, char *newname) ...@@ -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) ...@@ -366,7 +369,9 @@ plpgsql_convert_ident(const char *s, char **output, int numidents)
*cp++ = *s++; *cp++ = *s++;
} }
if (*s != '"') /* should not happen if lexer checked */ 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++; s++;
} }
else else
...@@ -403,8 +408,10 @@ plpgsql_convert_ident(const char *s, char **output, int numidents) ...@@ -403,8 +408,10 @@ plpgsql_convert_ident(const char *s, char **output, int numidents)
if (identctr < numidents) if (identctr < numidents)
output[identctr++] = curident; output[identctr++] = curident;
else else
elog(ERROR, "Qualified identifier cannot be used here: %s", ereport(ERROR,
sstart); (errcode(ERRCODE_SYNTAX_ERROR),
errmsg("qualified identifier cannot be used here: %s",
sstart)));
/* If not done, skip whitespace, dot, whitespace */ /* If not done, skip whitespace, dot, whitespace */
if (*s) if (*s)
...@@ -412,16 +419,16 @@ plpgsql_convert_ident(const char *s, char **output, int numidents) ...@@ -412,16 +419,16 @@ plpgsql_convert_ident(const char *s, char **output, int numidents)
while (*s && isspace((unsigned char) *s)) while (*s && isspace((unsigned char) *s))
s++; s++;
if (*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)) while (*s && isspace((unsigned char) *s))
s++; s++;
if (*s == '\0') if (*s == '\0')
elog(ERROR, "Expected another identifier: %s", sstart); elog(ERROR, "expected another identifier: %s", sstart);
} }
} }
if (identctr != numidents) if (identctr != numidents)
elog(ERROR, "Improperly qualified identifier: %s", elog(ERROR, "improperly qualified identifier: %s",
sstart); sstart);
} }
...@@ -586,7 +593,7 @@ dump_stmt(PLpgSQL_stmt * stmt) ...@@ -586,7 +593,7 @@ dump_stmt(PLpgSQL_stmt * stmt)
dump_perform((PLpgSQL_stmt_perform *) stmt); dump_perform((PLpgSQL_stmt_perform *) stmt);
break; break;
default: default:
elog(ERROR, "plpgsql_dump: unknown cmd_type %d\n", stmt->cmd_type); elog(ERROR, "unknown cmd_type: %d", stmt->cmd_type);
break; break;
} }
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * 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. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -65,7 +65,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS) ...@@ -65,7 +65,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS)
* Connect to SPI manager * Connect to SPI manager
*/ */
if (SPI_connect() != SPI_OK_CONNECT) 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 */ /* Find or compile the function */
func = plpgsql_compile(fcinfo); func = plpgsql_compile(fcinfo);
...@@ -84,7 +84,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS) ...@@ -84,7 +84,7 @@ plpgsql_call_handler(PG_FUNCTION_ARGS)
* Disconnect from SPI manager * Disconnect from SPI manager
*/ */
if (SPI_finish() != SPI_OK_FINISH) if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "plpgsql: SPI_finish() failed"); elog(ERROR, "SPI_finish() failed");
return retval; return retval;
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * 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. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -228,7 +228,9 @@ dump { return O_DUMP; } ...@@ -228,7 +228,9 @@ dump { return O_DUMP; }
\". { \". {
plpgsql_error_lineno = plpgsql_scanner_lineno(); 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; } ...@@ -251,7 +253,9 @@ dump { return O_DUMP; }
<IN_COMMENT>. ; <IN_COMMENT>. ;
<IN_COMMENT><<EOF>> { <IN_COMMENT><<EOF>> {
plpgsql_error_lineno = start_lineno; 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; } ...@@ -277,7 +281,9 @@ dump { return O_DUMP; }
} }
<IN_STRING><<EOF>> { <IN_STRING><<EOF>> {
plpgsql_error_lineno = start_lineno; plpgsql_error_lineno = start_lineno;
elog(ERROR, "unterminated string"); ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("unterminated string")));
} }
<IN_STRING>[^'\\]* { } <IN_STRING>[^'\\]* { }
...@@ -344,7 +350,7 @@ void ...@@ -344,7 +350,7 @@ void
plpgsql_push_back_token(int token) plpgsql_push_back_token(int token)
{ {
if (have_pushback_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; pushback_token = token;
have_pushback_token = true; 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 #ifndef PLPYTHON_H
#define PLPYTHON_H #define PLPYTHON_H
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
#if DEBUG_LEVEL #if DEBUG_LEVEL
#define CALL_LEVEL_INC() do { PLy_call_level += 1; \ #define CALL_LEVEL_INC() do { PLy_call_level += 1; \
elog(DEBUG4, "Level: %d", PLy_call_level); } while (0) elog(DEBUG4, "level: %d", PLy_call_level); } while (0)
#define CALL_LEVEL_DEC() do { elog(DEBUG4, "Level: %d", PLy_call_level); \ #define CALL_LEVEL_DEC() do { elog(DEBUG4, "level: %d", PLy_call_level); \
PLy_call_level -= 1; } while (0) PLy_call_level -= 1; } while (0)
#else #else
#define CALL_LEVEL_INC() do { PLy_call_level += 1; } while (0) #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