Richard Huxton <[EMAIL PROTECTED]> writes:
> Bruno Boettcher wrote:
>> and i get an error:
>> ERROR:  parser: parse error at or near "$1"
>> (BTW would be helpful if the thing could spit out also the line
>> number....)

> You can get syntax error line-numbers by editing the function in a
> text-file and \i file to import it. Otherwise, plpgsql's error reporting
> is a bit weak.

Actually, plpgsql DOES report the line number.  Into the postmaster log.
For example:

regression=# create function zz() returns int as '
regression'# begin
regression'#   x := x + 1;
regression'#   return x;
regression'# end;' language 'plpgsql';
CREATE
regression=# select zz();
ERROR:  parser: parse error at or near "x"
regression=#

tail postmaster.log shows

ERROR:  parser: parse error at or near "x"
DEBUG:  Last error occured while executing PL/pgSQL function zz
DEBUG:  line 2 at SQL statement

I am not sure why this precious info is so deeply buried.  I know why
it's not part of the ERROR itself: our elog mechanism doesn't support
that.  But seems like it could at least be made a NOTICE rather than a
DEBUG message.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to