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-08 07:39:39 |
Message-ID: | BAY114-F357FA9EB1FD1905464B20FF9BC0@phx.gbl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
>
>"Pavel Stehule" <pavel(dot)stehule(at)hotmail(dot)com> writes:
> > 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.
>
>Really? If an EXIT handler fires on a warning, does that mean the
>statement giving the warning is aborted midstream, instead of being
>allowed to complete?
>
Propably I have too bad english. I wrote it. I am sorry. Any warning
handlers are executed after statements. With exit handler it executes
handler statement and leave block. That's all.
>I think that the model the SQL spec has in mind is that a warning
>condition is raised only after the statement has run to completion
>(which implies only one such condition per statement BTW). This is
>quite at variance with our notion of WARNING. AFAICS you are not going
>to be able to implement anything that works sanely if you try to take
>control away at the instant of elog(WARNING). You would need to create
>some infrastructure for making this happen after the statement giving
>the warning is otherwise done --- which will take *much* more extensive
>revisions than just hooking into elog.
>
I understand. Warning infrastructure is implemented in plpgpsm code now.
There is one interest of hook - compatibility. I can simply set if warning
is processed on server side or is sended to client. This decision depends on
application (not only application, it depend on used language).
Do you thing API like?
ErrorData *edata;
push_catch_warning_state(); // new handler and set catching to on
.... EXEC statement ....
if ((edata = catched_warning() != NULL)
{
if (I know warning)
process it;
clean_warning();
else
distribute_warning(); // doesn't mean directly sending to client, maybe
others handlers wait for it
}
pop_catch_warning_state(); // prev. handler and set catch to prev. value
Pavel
_________________________________________________________________
Najdete si svou lasku a nove pratele na Match.com. http://www.msn.cz/
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2007-01-08 08:02:14 | is "add MOVE point" in ToDo valid still? |
Previous Message | Jeremy Drake | 2007-01-08 05:04:09 | Re: pgsql: Widen the money type to 64 bits. |