Re: PL/pgSQL, RAISE and error context

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Joel Jacobson <joel(at)trustly(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Marko Tiikkaja <marko(at)joh(dot)to>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Merlin Moncure <mmoncure(at)gmail(dot)com>
Subject: Re: PL/pgSQL, RAISE and error context
Date: 2015-04-27 14:21:37
Message-ID: CAFj8pRD91Fp7BK-gzwBZbfmGrQz5fdL1NBgD3Ayq5NtKcsMe4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2015-04-27 16:05 GMT+02:00 Joel Jacobson <joel(at)trustly(dot)com>:

> Looks good Pavel!
>
> May I just suggest you add the default case
> to src/test/regress/sql/plpgsql.sql
> and src/test/regress/expected/plpgsql.out, to make it easier for the
> reviewer to compare the difference between what happens in the default
> case, when not using the raise-syntax and not using the GUCs?
>
> Suggested addition to the beginning of src/test/regress/sql/plpgsql.sql:
> +do $$
> +begin
> + raise notice 'hello';
> +end;
> +$$;
> +
> +do $$
> +begin
> + raise exception 'hello';
> +end;
> +$$;
>

done

>
> Many thanks for this patch! I will pray to the PL/pgSQL God it will be
> accepted. :)
>

:) -- please, do review, or fix documentation in this patch.

I hope, so it will be merged early in 9.6 cycle. It is relatively simple.

Pavel

>
> Best regards,
>
> Joel
>
>
> On Sun, Apr 26, 2015 at 9:19 AM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
> wrote:
>
>> Hi
>>
>> I reduced this patch, little bit cleaned - now it is based on plpgsql GUC
>> display_context_min_messages - like client_min_messages, log_min_messages.
>>
>> Documentation added.
>>
>> Regards
>>
>> Pavel
>>
>> 2015-04-25 22:23 GMT+02:00 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>:
>>
>>> Hi
>>>
>>> 2015-04-24 19:16 GMT+02:00 Joel Jacobson <joel(at)trustly(dot)com>:
>>>
>>>> On Fri, Apr 24, 2015 at 6:07 PM, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
>>>> wrote:
>>>> >> Example:
>>>> >>
>>>> >> context_messages = -warning, -error, +notice
>>>> >
>>>> >
>>>> > I prefer your first proposal - and there is a precedent for plpgsql -
>>>> > plpgsql_extra_checks
>>>> >
>>>> > It is clean for anybody. +-identifiers looks like horrible httpd
>>>> config. :)
>>>>
>>>> I have to agree on that :) Just thought this is the best we can do if
>>>> we want to reduce the number of GUCs to a minimum.
>>>>
>>>
>>> I played with some prototype and I am thinking so we need only one GUC
>>>
>>> plpgsql.display_context_messages = 'none'; -- compatible with current
>>> plpgsql.display_context_messages = 'all';
>>> plpgsql.display_context_messages = 'exception, log'; -- what I prefer
>>>
>>> I implemented [ (WITH|WITHOUT) CONTEXT ] clause for RAISE statement
>>>
>>> RAISE NOTICE WITH CONTEXT 'some message';
>>> RAISE NOTICE WITH CONTEXT USING message = 'some message';
>>> RAISE EXCEPTION WITHOUT CONTEXT 'other message';
>>>
>>> The patch is very small with full functionality (without documentation)
>>> - I am thinking so it can work. This patch is back compatible - and allow
>>> to change default behave simply.
>>>
>>> plpgsql.display_context_messages can be simplified to some like
>>> plpgsql.display_context_min_messages
>>>
>>> What do you think about it?
>>>
>>> Regards
>>>
>>> Pavel
>>>
>>>
>>
>

Attachment Content-Type Size
plpgsql-raise-context-02.patch text/x-patch 13.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2015-04-27 14:28:49 Re: INSERT ... ON CONFLICT UPDATE/IGNORE 4.0, parser/executor stuff
Previous Message Joel Jacobson 2015-04-27 14:05:32 Re: PL/pgSQL, RAISE and error context