Re: proposal: catch warnings

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: proposal: catch warnings
Дата
Msg-id BAY114-F357FA9EB1FD1905464B20FF9BC0@phx.gbl
обсуждение исходный текст
Ответ на Re: proposal: catch warnings  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
>
>"Pavel Stehule" <pavel.stehule@hotmail.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/



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [PATCHES] SGML index build fix
Следующее
От: "Pavel Stehule"
Дата:
Сообщение: is "add MOVE point" in ToDo valid still?