From: | "Pavel Stehule" <pavel(dot)stehule(at)hotmail(dot)com> |
---|---|
To: | tgl(at)sss(dot)pgh(dot)pa(dot)us |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: proposal: catch warnings |
Date: | 2007-01-07 17:40:57 |
Message-ID: | BAY20-F181A3FE2E1B42E84F0C927F9BD0@phx.gbl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
What is problem? ANSI SQL has different model of handling exception than
postgresql. It doesn't distinguishes between warnings and exception. Simply
some sqlstate clases are reservated for warnings and other's for exception.
But all sqlstate's (without '00000') can be handled via any CONTINUE, EXIT
or UNDO handler. Exceptions are not problem. But I cannot map sqlstates
'01xxx' and '02xxx' to exception because they internally do rollback. I have
to use different elevel. I cannot trap warnings on plpgpsm level, because in
this moment I will lost an possibility of traping warnings from others PL. I
can use warning for signaling any safe event (don't need rollaback) from
this PL. Currently I save only last warning, but it is possible safe
warnings info to any queue.
>
>What in the world does it mean to "catch" a warning? If your intention
>is to process arbitrary user-defined code while inside the error
>subsystem, I can tell you right now that it's unlikely to work.
>
No, it means, it process user-defined code related to some compound
statement immediate after some statement which signals sqlstate '01xxx' or
'02xxx'. Exceptions are diffrent, they do rollback before call exception's
handle. I use callback function only for decision if there is any possible
warning handler and for saving struct edata. After excecuton any statement I
check this struct and call handler statement.
> > Simply solution's is adding one callback to
> > error's processing of errors on level WARNING.
>
>I can't get excited about hooks that are defined in such a way that
>there can be only one user of the hook ... if it's useful to you,
>it's probably useful to someone else too.
>
Propably we can use it for faster catch no_data in plpgsql or for enhancing
of statement RAISE in future. Any SQL/PSM implementation have to solve this
task.
Regards
Pavel Stehule
_________________________________________________________________
Emotikony a pozadi programu MSN Messenger ozivi vasi konverzaci.
http://messenger.msn.cz/
From | Date | Subject | |
---|---|---|---|
Next Message | Seneca Cunningham | 2007-01-07 17:47:25 | --with-libxml build failures on OS X |
Previous Message | Tom Lane | 2007-01-07 17:14:06 | Re: [HACKERS] COPY with no WAL, in certain circumstances |