Memory context in exception handler

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Memory context in exception handler
Дата
Msg-id 200701132319.00246.peter_e@gmx.net
обсуждение исходный текст
Ответы Re: Memory context in exception handler  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
I'm trying to use the PG_TRY/PG_CATCH exception handling:

bool
xml_is_document(xmltype *arg)
{bool        result;xmlDocPtr    doc;
PG_TRY();{    doc = xml_parse((text *) arg, true, true);    result = true;}PG_CATCH();{    ErrorData *errdata =
CopyErrorData();   if (errdata->sqlerrcode == ERRCODE_INVALID_XML_DOCUMENT)    {        FlushErrorState();
result= false;    }    else        PG_RE_THROW();}PG_END_TRY();
 
if (doc)    xmlFreeDoc(doc);
return result;
}

But this fails because CopyErrorData() complains by way of assertion 
that we're still in ErrorContext.  A nearby comment suggests to switch 
away to another context to preserve the data across FlushErrorState(), 
but that doesn't seem necessary in this situation.  Are there other 
reasons why this rule is so rigorously enforced?

-- 
Peter Eisentraut
http://developer.postgresql.org/~petere/


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

Предыдущее
От: Christopher Browne
Дата:
Сообщение: Re: [GENERAL] Autovacuum Improvements
Следующее
От: Jignesh Shah
Дата:
Сообщение: Performance of Parser?