Re: plperl error format vs plpgsql error format vs pgTAP

Lists: pgsql-hackers
From: Kevin Field <kevinjamesfield(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-28 19:03:10
Message-ID: 1c26d3f4-a49a-4916-91d3-b3ca7e9d3cc2@m17g2000vbi.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I use pgTAP to make sure my functions produce the correct errors using
throws_ok(). So when I get an error from a plpgsql function, it looks
like this:

ERROR: upper bound of FOR loop cannot be null
CONTEXT: PL/pgSQL function "foo" line 35 at FOR with integer loop
variable

...which I can then test using throws_ok by giving it the string
'upper bound of FOR loop cannot be null'. However, in a plperl
function, errors come out in this format:

error from Perl function "check_no_loop": Loops not allowed! Node 1
cannot be part of node 3 at line 13.

Unfortunately, I can't test for this without including the line
number, which means that changing any plperl function that I have such
a test for pretty much guarantees that I'll need to change the test to
reflect the new line numbers the errors would be thrown from in the
function.

Is it possible to unify the error reporting format, so pgTAP can test
them without needing line numbers from plperl functions?


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kevin Field <kevinjamesfield(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-28 19:22:29
Message-ID: 27547.1243538549@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Kevin Field <kevinjamesfield(at)gmail(dot)com> writes:
> I use pgTAP to make sure my functions produce the correct errors using
> throws_ok(). So when I get an error from a plpgsql function, it looks
> like this:

> ERROR: upper bound of FOR loop cannot be null
> CONTEXT: PL/pgSQL function "foo" line 35 at FOR with integer loop
> variable

> ...which I can then test using throws_ok by giving it the string
> 'upper bound of FOR loop cannot be null'.

Surely, this is a completely brain-dead approach to testing errors
in the first place ... what will happen in a localized installation?

What you need is a test that looks at the SQLSTATE code, and little
if anything else.

regards, tom lane


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Kevin Field <kevinjamesfield(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-28 19:28:40
Message-ID: 4A1EE5E8.2010402@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Kevin Field wrote:
> I use pgTAP to make sure my functions produce the correct errors using
> throws_ok(). So when I get an error from a plpgsql function, it looks
> like this:
>
> ERROR: upper bound of FOR loop cannot be null
> CONTEXT: PL/pgSQL function "foo" line 35 at FOR with integer loop
> variable
>
> ...which I can then test using throws_ok by giving it the string
> 'upper bound of FOR loop cannot be null'. However, in a plperl
> function, errors come out in this format:
>
> error from Perl function "check_no_loop": Loops not allowed! Node 1
> cannot be part of node 3 at line 13.
>
> Unfortunately, I can't test for this without including the line
> number, which means that changing any plperl function that I have such
> a test for pretty much guarantees that I'll need to change the test to
> reflect the new line numbers the errors would be thrown from in the
> function.
>
> Is it possible to unify the error reporting format, so pgTAP can test
> them without needing line numbers from plperl functions?
>
>

This is under perl's control, not ours. The perl docco says:

If the last element of LIST does not end in a newline, the current
script line number and input line number (if any) are also printed
and a newline is supplied.

Can pgTap check for a regex instead if just a string?

cheers

andrew


From: Kevin Field <kevinjamesfield(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-28 19:51:38
Message-ID: 48f6f438-874e-407d-9c40-fdf7de9db23d@h23g2000vbc.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On May 28, 3:22 pm, t(dot)(dot)(dot)(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane) wrote:
> Kevin Field <kevinjamesfi(dot)(dot)(dot)(at)gmail(dot)com> writes:
> > I use pgTAP to make sure my functions produce the correct errors using
> > throws_ok(). So when I get an error from a plpgsql function, it looks
> > like this:
> > ERROR: upper bound of FOR loop cannot be null
> > CONTEXT: PL/pgSQL function "foo" line 35 at FOR with integer loop
> > variable
> > ...which I can then test using throws_ok by giving it the string
> > 'upper bound of FOR loop cannot be null'.
>
> Surely, this is a completely brain-dead approach to testing errors
> in the first place ... what will happen in a localized installation?
>
> What you need is a test that looks at the SQLSTATE code, and little
> if anything else.

There won't be any localized installations.

I wanted to use the SQLSTATE code, but it's always XX000. If there
were some way to set it when calling elog() so I knew the right error
was being reached, that would be a great option. Is that something
under the control of PostgreSQL?


From: Kevin Field <kevinjamesfield(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-28 19:53:25
Message-ID: 63416f1b-dc02-4f19-971d-f3e7a92604af@s28g2000vbp.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On May 28, 3:28 pm, and(dot)(dot)(dot)(at)dunslane(dot)net (Andrew Dunstan) wrote:
> Kevin Field wrote:
> > I use pgTAP to make sure my functions produce the correct errors using
> > throws_ok(). So when I get an error from a plpgsql function, it looks
> > like this:
>
> > ERROR: upper bound of FOR loop cannot be null
> > CONTEXT: PL/pgSQL function "foo" line 35 at FOR with integer loop
> > variable
>
> > ...which I can then test using throws_ok by giving it the string
> > 'upper bound of FOR loop cannot be null'. However, in a plperl
> > function, errors come out in this format:
>
> > error from Perl function "check_no_loop": Loops not allowed! Node 1
> > cannot be part of node 3 at line 13.
>
> > Unfortunately, I can't test for this without including the line
> > number, which means that changing any plperl function that I have such
> > a test for pretty much guarantees that I'll need to change the test to
> > reflect the new line numbers the errors would be thrown from in the
> > function.
>
> > Is it possible to unify the error reporting format, so pgTAP can test
> > them without needing line numbers from plperl functions?
>
> This is under perl's control, not ours. The perl docco says:
>
> If the last element of LIST does not end in a newline, the current
> script line number and input line number (if any) are also printed
> and a newline is supplied.
>
> Can pgTap check for a regex instead if just a string?

That's the other option, if the pgTAP author is willing...if the
SQLSTATE thing doesn't work out I guess we'll have to go down that
road.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kevin Field <kevinjamesfield(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-28 21:15:44
Message-ID: 441.1243545344@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Kevin Field <kevinjamesfield(at)gmail(dot)com> writes:
> I wanted to use the SQLSTATE code, but it's always XX000. If there
> were some way to set it when calling elog()

ereport?

http://developer.postgresql.org/pgdocs/postgres/error-message-reporting.html

At the plpgsql level, since 8.4 you can specify a SQLSTATE in RAISE.
AFAIR nobody's gotten round to doing anything about it in plperl.

regards, tom lane


From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kevin Field <kevinjamesfield(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-28 21:18:12
Message-ID: 0739180E-7418-465F-9263-1F16C346B6F4@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On May 28, 2009, at 12:22 PM, Tom Lane wrote:

> What you need is a test that looks at the SQLSTATE code, and little
> if anything else.

Yes, and throws_ok() supports that:

SELECT throws_ok( 'SELECT 1 / 0', '22012' );

Best,

David


From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: Kevin Field <kevinjamesfield(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-28 21:19:10
Message-ID: 056FDF77-9C13-4333-ACBE-D82EF67BBBAD@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On May 28, 2009, at 12:53 PM, Kevin Field wrote:

>> Can pgTap check for a regex instead if just a string?
>
> That's the other option, if the pgTAP author is willing...if the
> SQLSTATE thing doesn't work out I guess we'll have to go down that
> road.

Patches welcome. ;-)

http://github.com/theory/pgtap/tree/master/

I'm getting a new version ready to release as I type.

Best,

David


From: Kevin Field <kevinjamesfield(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-29 11:59:21
Message-ID: 2fc8fb45-a27c-4497-b082-cb56b80c9d49@g20g2000vba.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On May 28, 5:19 pm, da(dot)(dot)(dot)(at)kineticode(dot)com ("David E. Wheeler") wrote:
> On May 28, 2009, at 12:53 PM, Kevin Field wrote:
>
> >> Can pgTap check for a regex instead if just a string?
>
> > That's the other option, if the pgTAP author is willing...if the
> > SQLSTATE thing doesn't work out I guess we'll have to go down that
> > road.
>
> Patches welcome. ;-)
>
> http://github.com/theory/pgtap/tree/master/
>
> I'm getting a new version ready to release as I type.

Thanks, great to know. :) Although, I do think changing plperl is
the more proper option, so I'm going to try there first...


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Kevin Field <kevinjamesfield(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-29 15:35:44
Message-ID: 603c8f070905290835w6a594609g33d06d635b8765d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, May 29, 2009 at 7:59 AM, Kevin Field <kevinjamesfield(at)gmail(dot)com> wrote:
> On May 28, 5:19 pm, da(dot)(dot)(dot)(at)kineticode(dot)com ("David E. Wheeler") wrote:
>> On May 28, 2009, at 12:53 PM, Kevin Field wrote:
>>
>> >> Can pgTap check for a regex instead if just a string?
>>
>> > That's the other option, if the pgTAP author is willing...if the
>> > SQLSTATE thing doesn't work out I guess we'll have to go down that
>> > road.
>>
>> Patches welcome. ;-)
>>
>>    http://github.com/theory/pgtap/tree/master/
>>
>> I'm getting a new version ready to release as I type.
>
> Thanks, great to know.  :)  Although, I do think changing plperl is
> the more proper option, so I'm going to try there first...

It seems to me that removing line numbers from PL/perl error messages
is not a good solution to anything. Line numbers are extremely useful
for debugging purposes, and getting rid of them because one particular
testing framework doesn't know how to use regular expressions is
solving the wrong problem.

I'm also a bit confused because your original post had a line number
in the PL/pgsql output, too, just formatted slightly differently. Why
doesn't that one cause a problem?

...Robert


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Kevin Field <kevinjamesfield(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-29 15:37:59
Message-ID: 4A200157.101@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Kevin Field wrote:
> On May 28, 5:19 pm, da(dot)(dot)(dot)(at)kineticode(dot)com ("David E. Wheeler") wrote:
>
>> On May 28, 2009, at 12:53 PM, Kevin Field wrote:
>>
>>
>>>> Can pgTap check for a regex instead if just a string?
>>>>
>>> That's the other option, if the pgTAP author is willing...if the
>>> SQLSTATE thing doesn't work out I guess we'll have to go down that
>>> road.
>>>
>> Patches welcome. ;-)
>>
>> http://github.com/theory/pgtap/tree/master/
>>
>> I'm getting a new version ready to release as I type.
>>
>
> Thanks, great to know. :) Although, I do think changing plperl is
> the more proper option, so I'm going to try there first...
>
>

As I pointed out before, these line numbers are put there by the perl
engine, not by the plperl glue code.

If you want to make plperl strip out the line number from every error
message the perl engine produces, I am going to object. It might make
things easier for pgTap but it will make life much harder in other ways.

cheers

andrew


From: Kevin Field <kevinjamesfield(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-29 15:48:19
Message-ID: 811ecb4b-a978-4cc0-b9f4-df0d2d22c59a@r34g2000vbi.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On May 29, 11:35 am, robertmh(dot)(dot)(dot)(at)gmail(dot)com (Robert Haas) wrote:
> On Fri, May 29, 2009 at 7:59 AM, Kevin Field <kevinjamesfi(dot)(dot)(dot)(at)gmail(dot)com> wrote:
> > On May 28, 5:19 pm, da(dot)(dot)(dot)(at)kineticode(dot)com ("David E. Wheeler") wrote:
> >> On May 28, 2009, at 12:53 PM, Kevin Field wrote:
>
> >> >> Can pgTap check for a regex instead if just a string?
>
> >> > That's the other option, if the pgTAP author is willing...if the
> >> > SQLSTATE thing doesn't work out I guess we'll have to go down that
> >> > road.
>
> >> Patches welcome. ;-)
>
> >> http://github.com/theory/pgtap/tree/master/
>
> >> I'm getting a new version ready to release as I type.
>
> > Thanks, great to know. :) Although, I do think changing plperl is
> > the more proper option, so I'm going to try there first...
>
> It seems to me that removing line numbers from PL/perl error messages
> is not a good solution to anything. Line numbers are extremely useful
> for debugging purposes, and getting rid of them because one particular
> testing framework doesn't know how to use regular expressions is
> solving the wrong problem.

You're right, but that's not what I'm proposing...

> I'm also a bit confused because your original post had a line number
> in the PL/pgsql output, too, just formatted slightly differently. Why
> doesn't that one cause a problem?

The difference is, in PL/pgsql they're in the CONTEXT: line, whereas
in plperl they're in the error line. This is inconsistent; if we fix
it, we don't need to add kludge to pgTAP.

But later in the thread the desired fix became not changing perl but
instead making a way to report error codes from plperl, which is what
I'm attempting to do with my rusty C skills soon. plperl should have
ereport() *anyway*, as I believe Tom had insinuated.


From: Kevin Field <kevinjamesfield(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-29 16:13:14
Message-ID: a717d99b-03e3-4828-90aa-b3974b59c413@j12g2000vbl.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On May 29, 11:48 am, Kevin Field <kevinjamesfi(dot)(dot)(dot)(at)gmail(dot)com> wrote:
> On May 29, 11:35 am, robertmh(dot)(dot)(dot)(at)gmail(dot)com (Robert Haas) wrote:
>
>
>
> > On Fri, May 29, 2009 at 7:59 AM, Kevin Field <kevinjamesfi(dot)(dot)(dot)(at)gmail(dot)com> wrote:
> > > On May 28, 5:19 pm, da(dot)(dot)(dot)(at)kineticode(dot)com ("David E. Wheeler") wrote:
> > >> On May 28, 2009, at 12:53 PM, Kevin Field wrote:
>
> > >> >> Can pgTap check for a regex instead if just a string?
>
> > >> > That's the other option, if the pgTAP author is willing...if the
> > >> > SQLSTATE thing doesn't work out I guess we'll have to go down that
> > >> > road.
>
> > >> Patches welcome. ;-)
>
> > >> http://github.com/theory/pgtap/tree/master/
>
> > >> I'm getting a new version ready to release as I type.
>
> > > Thanks, great to know. :) Although, I do think changing plperl is
> > > the more proper option, so I'm going to try there first...
>
> > It seems to me that removing line numbers from PL/perl error messages
> > is not a good solution to anything. Line numbers are extremely useful
> > for debugging purposes, and getting rid of them because one particular
> > testing framework doesn't know how to use regular expressions is
> > solving the wrong problem.
>
> You're right, but that's not what I'm proposing...
>
> > I'm also a bit confused because your original post had a line number
> > in the PL/pgsql output, too, just formatted slightly differently. Why
> > doesn't that one cause a problem?
>
> The difference is, in PL/pgsql they're in the CONTEXT: line, whereas
> in plperl they're in the error line. This is inconsistent; if we fix
> it, we don't need to add kludge to pgTAP.
>
> But later in the thread the desired fix became not changing perl but
> instead making a way to report error codes from plperl, which is what
> I'm attempting to do with my rusty C skills soon. plperl should have
> ereport() *anyway*, as I believe Tom had insinuated.

BTW, I noticed in exec_stmt_raise() in src/pl/plpgsql/src/pl_exec.c
that the comment still says "throw it with elog()" rather than "ereport
()" even though ereport() is used in all places but one in the
function:

default:
elog(ERROR, "unrecognized raise option: %d", opt->opt_type);

Should this be changed to:

default:
ereport(ERROR, (errmsg_internal("unrecognized raise option: %d",
opt->opt_type)));

...along with the comment?


From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: Kevin Field <kevinjamesfield(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-29 16:16:15
Message-ID: BA3C68E3-AC98-46A4-8591-95EF3B393455@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On May 29, 2009, at 4:59 AM, Kevin Field wrote:

>> http://github.com/theory/pgtap/tree/master/
>>
>> I'm getting a new version ready to release as I type.
>
> Thanks, great to know. :) Although, I do think changing plperl is
> the more proper option, so I'm going to try there first...

I added `throws_like()` to the To Do list, so if anyone wants to do
that…fork and clone!

Best,

David


From: Kevin Field <kevinjamesfield(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-29 16:43:48
Message-ID: 70174eb0-d00b-4a32-b590-faed988ff07d@v4g2000vba.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On May 29, 11:48 am, Kevin Field <kevinjamesfi(dot)(dot)(dot)(at)gmail(dot)com> wrote:
> On May 29, 11:35 am, robertmh(dot)(dot)(dot)(at)gmail(dot)com (Robert Haas) wrote:
>
>
>
> > On Fri, May 29, 2009 at 7:59 AM, Kevin Field <kevinjamesfi(dot)(dot)(dot)(at)gmail(dot)com> wrote:
> > > On May 28, 5:19 pm, da(dot)(dot)(dot)(at)kineticode(dot)com ("David E. Wheeler") wrote:
> > >> On May 28, 2009, at 12:53 PM, Kevin Field wrote:
>
> > >> >> Can pgTap check for a regex instead if just a string?
>
> > >> > That's the other option, if the pgTAP author is willing...if the
> > >> > SQLSTATE thing doesn't work out I guess we'll have to go down that
> > >> > road.
>
> > >> Patches welcome. ;-)
>
> > >> http://github.com/theory/pgtap/tree/master/
>
> > >> I'm getting a new version ready to release as I type.
>
> > > Thanks, great to know. :) Although, I do think changing plperl is
> > > the more proper option, so I'm going to try there first...
>
> > It seems to me that removing line numbers from PL/perl error messages
> > is not a good solution to anything. Line numbers are extremely useful
> > for debugging purposes, and getting rid of them because one particular
> > testing framework doesn't know how to use regular expressions is
> > solving the wrong problem.
>
> You're right, but that's not what I'm proposing...
>
> > I'm also a bit confused because your original post had a line number
> > in the PL/pgsql output, too, just formatted slightly differently. Why
> > doesn't that one cause a problem?
>
> The difference is, in PL/pgsql they're in the CONTEXT: line, whereas
> in plperl they're in the error line. This is inconsistent; if we fix
> it, we don't need to add kludge to pgTAP.
>
> But later in the thread the desired fix became not changing perl but
> instead making a way to report error codes from plperl, which is what
> I'm attempting to do with my rusty C skills soon. plperl should have
> ereport() *anyway*, as I believe Tom had insinuated.

Hmm, I'm rustier than I thought. I might need some help with this
later.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kevin Field <kevinjamesfield(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-05-29 17:04:04
Message-ID: 20611.1243616644@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Kevin Field <kevinjamesfield(at)gmail(dot)com> writes:
> default:
> elog(ERROR, "unrecognized raise option: %d", opt->opt_type);

> Should this be changed to:

> default:
> ereport(ERROR, (errmsg_internal("unrecognized raise option: %d",
> opt->opt_type)));

No, we generally don't bother with that. The above two are exactly
equivalent and the first is easier to write, so why complicate the code?
ereport is needed if you want to specify a SQLSTATE, provide a
translatable error message, etc, but for internal shouldn't-happen cases
we customarily just use elog.

regards, tom lane


From: Kevin Field <kevinjamesfield(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-06-01 16:01:06
Message-ID: a4d2c042-8492-4d9e-99d3-14443e4811e9@v4g2000vba.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On May 29, 1:04 pm, t(dot)(dot)(dot)(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane) wrote:
> Kevin Field <kevinjamesfi(dot)(dot)(dot)(at)gmail(dot)com> writes:
> > default:
> > elog(ERROR, "unrecognized raise option: %d", opt->opt_type);
> > Should this be changed to:
> > default:
> > ereport(ERROR, (errmsg_internal("unrecognized raise option: %d",
> > opt->opt_type)));
>
> No, we generally don't bother with that. The above two are exactly
> equivalent and the first is easier to write, so why complicate the code?
> ereport is needed if you want to specify a SQLSTATE, provide a
> translatable error message, etc, but for internal shouldn't-happen cases
> we customarily just use elog.

Ah, I had missed that. I understand. The function's comment's still
out of date though, I think, since it uses ereport at the end.


From: Kevin Field <kevinjamesfield(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: plperl error format vs plpgsql error format vs pgTAP
Date: 2009-06-01 17:18:25
Message-ID: c525aa3f-58ea-45d4-aa90-1c6a6258c696@q2g2000vbr.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On May 29, 12:43 pm, Kevin Field <kevinjamesfi(dot)(dot)(dot)(at)gmail(dot)com> wrote:
> On May 29, 11:48 am, Kevin Field <kevinjamesfi(dot)(dot)(dot)(at)gmail(dot)com> wrote:
>
>
>
> > On May 29, 11:35 am, robertmh(dot)(dot)(dot)(at)gmail(dot)com (Robert Haas) wrote:
>
> > > On Fri, May 29, 2009 at 7:59 AM, Kevin Field <kevinjamesfi(dot)(dot)(dot)(at)gmail(dot)com> wrote:
> > > > On May 28, 5:19 pm, da(dot)(dot)(dot)(at)kineticode(dot)com ("David E. Wheeler") wrote:
> > > >> On May 28, 2009, at 12:53 PM, Kevin Field wrote:
>
> > > >> >> Can pgTap check for a regex instead if just a string?
>
> > > >> > That's the other option, if the pgTAP author is willing...if the
> > > >> > SQLSTATE thing doesn't work out I guess we'll have to go down that
> > > >> > road.
>
> > > >> Patches welcome. ;-)
>
> > > >> http://github.com/theory/pgtap/tree/master/
>
> > > >> I'm getting a new version ready to release as I type.
>
> > > > Thanks, great to know. :) Although, I do think changing plperl is
> > > > the more proper option, so I'm going to try there first...
>
> > > It seems to me that removing line numbers from PL/perl error messages
> > > is not a good solution to anything. Line numbers are extremely useful
> > > for debugging purposes, and getting rid of them because one particular
> > > testing framework doesn't know how to use regular expressions is
> > > solving the wrong problem.
>
> > You're right, but that's not what I'm proposing...
>
> > > I'm also a bit confused because your original post had a line number
> > > in the PL/pgsql output, too, just formatted slightly differently. Why
> > > doesn't that one cause a problem?
>
> > The difference is, in PL/pgsql they're in the CONTEXT: line, whereas
> > in plperl they're in the error line. This is inconsistent; if we fix
> > it, we don't need to add kludge to pgTAP.
>
> > But later in the thread the desired fix became not changing perl but
> > instead making a way to report error codes from plperl, which is what
> > I'm attempting to do with my rusty C skills soon. plperl should have
> > ereport() *anyway*, as I believe Tom had insinuated.
>
> Hmm, I'm rustier than I thought. I might need some help with this
> later.

Actually, I'm not sure I'll be able to be of any use on this after
all. Would someone be able to add plperl ereport to the todo list for
me at least?