Throw error and ErrorContext question.

From: "Gevik Babakhani" <pgdev(at)xs4all(dot)nl>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Throw error and ErrorContext question.
Date: 2007-11-07 22:54:07
Message-ID: 001101c82191$1a916590$0a01a8c0@gevmus
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Regarding the function parameter ref TODO:

I am trying to catch and copy an error to be re-thrown later.
I have the following questions:

1. Is the catch part in the following safe?
2. How do I re-throw the copied error when I am not in ErrorContext anymore?
I cannot use ReThrowError because of Assert.

3. If I have to use something like: ereport(ERROR,mysaved_error->message ...
mysaved_error->detail ...... );
then how do I FreeErrorData(mysaved_error) after calling the ereport
above?

First:
....
MemoryContext parseMemCtx = CurrentMemoryContext;
....

Then:

/* Try to identify as a once-qualified column */
PG_TRY();
{
node = qualifiedNameToVar(pstate, NULL, name1, name2, true,
cref->location);
/* status set to 0 or 1 */
qualified_status = (node != NULL);
}
PG_CATCH();
{
/* copy this error for later use */
errorMemCtx = CurrentMemoryContext;
MemoryContextSwitchTo(parseMemCtx);
qualifiedErrData = CopyErrorData();
FlushErrorState();
MemoryContextSwitchTo(errorMemCtx);

/* status is set to error */
qualified_status = 2;
}
PG_END_TRY();

------------------------------------------------
Gevik Babakhani

PostgreSQL NL http://www.postgresql.nl
TrueSoftware BV http://www.truesoftware.nl
------------------------------------------------

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-11-07 23:11:00 Re: fulltext parser strange behave
Previous Message Devrim GÜNDÜZ 2007-11-07 21:53:04 New tzdata available