Fwd: Difference in postgres9.0.4 and postgres9.1beta1 when displaying error lines in functions with comments - Mailing list pgsql-bugs

From Abel Abraham Camarillo Ojeda
Subject Fwd: Difference in postgres9.0.4 and postgres9.1beta1 when displaying error lines in functions with comments
Date
Msg-id BANLkTinL3UF-h7-vPk9GuPMWf7VFnmogCA@mail.gmail.com
Whole thread Raw
List pgsql-bugs
I should have posted this here before sending it to pgsql-hackers... ups.

---------- Forwarded message ----------
From: Abel Abraham Camarillo Ojeda <acamari@verlet.org>
Date: Thu, Jun 9, 2011 at 8:58 PM
Subject: Difference in postgres9.0.4 and postgres9.1beta1 when
displaying error lines in functions with comments
To: pgsql-hackers@postgresql.org


Postgres 9.0.4 and postgres9.1beta1 give different line of error numbers on
functions that raise runtime errors (it seems).

How to reproduce, given the next SQL file:

$ cat /tmp/sql
begin;
CREATE FUNCTION pg_temp.commchecksql() returns boolean strict language
plpgsql as
$$
begin

-- SQL comment
perform 'aoeuaoeuaeou'::regclass;
return true;
end;
$$;

select pg_temp.commchecksql();
rollback;

begin;
CREATE FUNCTION pg_temp.commcheckC() returns boolean strict language plpgsq=
l as
$$
begin

/* C-like comment */
perform 'aoeuaoeuaeou'::regclass;
return true;
end;
$$;

select pg_temp.commcheckC();

rollback;

------------------

If I run it on postgres9.0.4:

$ psql -U postgres template1 -f/tmp/sql
SET
BEGIN
CREATE FUNCTION
psql:/tmp/sql:12: ERROR: =C2=A0relation "aoeuaoeuaeou" does not exist
LINE 1: SELECT 'aoeuaoeuaeou'::regclass
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^
QUERY: =C2=A0SELECT 'aoeuaoeuaeou'::regclass
CONTEXT: =C2=A0PL/pgSQL function "commchecksql" line 4 at PERFORM
ROLLBACK
BEGIN
CREATE FUNCTION
psql:/tmp/sql:26: ERROR: =C2=A0relation "aoeuaoeuaeou" does not exist
LINE 1: SELECT 'aoeuaoeuaeou'::regclass
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^
QUERY: =C2=A0SELECT 'aoeuaoeuaeou'::regclass
CONTEXT: =C2=A0PL/pgSQL function "commcheckc" line 4 at PERFORM
ROLLBACK

--------------------

On postgres9.1beta1:

$ psql -U postgres template1 -f/tmp/sql

SET
BEGIN
CREATE FUNCTION
psql:/tmp/sql:12: ERROR: =C2=A0relation "aoeuaoeuaeou" does not exist
LINE 1: SELECT 'aoeuaoeuaeou'::regclass
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^
QUERY: =C2=A0SELECT 'aoeuaoeuaeou'::regclass
CONTEXT: =C2=A0PL/pgSQL function "commchecksql" line 5 at PERFORM
ROLLBACK
BEGIN
CREATE FUNCTION
psql:/tmp/sql:26: ERROR: =C2=A0relation "aoeuaoeuaeou" does not exist
LINE 1: SELECT 'aoeuaoeuaeou'::regclass
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^
QUERY: =C2=A0SELECT 'aoeuaoeuaeou'::regclass
CONTEXT: =C2=A0PL/pgSQL function "commcheckc" line 5 at PERFORM
ROLLBACK

--------------------

The line numbers of where the error is have changed:

--- /tmp/out9.0.4 =C2=A0 =C2=A0 =C2=A0 Thu Jun =C2=A09 20:47:45 2011
+++ /tmp/out9.1beta1 =C2=A0 =C2=A0Thu Jun =C2=A09 20:49:02 2011
@@ -5,7 +5,7 @@
=C2=A0LINE 1: SELECT 'aoeuaoeuaeou'::regclass
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^
=C2=A0QUERY: =C2=A0SELECT 'aoeuaoeuaeou'::regclass
-CONTEXT: =C2=A0PL/pgSQL function "commchecksql" line 4 at PERFORM
+CONTEXT: =C2=A0PL/pgSQL function "commchecksql" line 5 at PERFORM
=C2=A0ROLLBACK
=C2=A0BEGIN
=C2=A0CREATE FUNCTION
@@ -13,5 +13,5 @@
=C2=A0LINE 1: SELECT 'aoeuaoeuaeou'::regclass
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0^
=C2=A0QUERY: =C2=A0SELECT 'aoeuaoeuaeou'::regclass
-CONTEXT: =C2=A0PL/pgSQL function "commcheckc" line 4 at PERFORM
+CONTEXT: =C2=A0PL/pgSQL function "commcheckc" line 5 at PERFORM
=C2=A0ROLLBACK

---------------------

I care about this because I have some custom regression tests that check the
failing of functions coded like this... and they suddenly failed with that
difference when I checked them against postgres9.0.4.

Is this an intended behaviour?

Thank you.

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: BUG #6050: Dump and restore of view after a schema change: can't restore the view
Next
From: Bruce Momjian
Date:
Subject: Re: collation problem on 9.1-beta1