From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Memory context in exception handler |
Date: | 2007-01-13 22:18:59 |
Message-ID: | 200701132319.00246.peter_e@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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/
From | Date | Subject | |
---|---|---|---|
Next Message | Jignesh Shah | 2007-01-13 23:38:24 | Performance of Parser? |
Previous Message | Jeff Amiel | 2007-01-13 17:40:41 | Re: Corrupt database? 8.1/FreeBSD6.0 |