Throw error and ErrorContext question. - Mailing list pgsql-hackers

From Gevik Babakhani
Subject Throw error and ErrorContext question.
Date
Msg-id 001101c82191$1a916590$0a01a8c0@gevmus
Whole thread Raw
Responses Re: Throw error and ErrorContext question.
List 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
------------------------------------------------



pgsql-hackers by date:

Previous
From: Devrim GÜNDÜZ
Date:
Subject: New tzdata available
Next
From: Tom Lane
Date:
Subject: Re: fulltext parser strange behave