Igor Stassiy <istassiy(at)gmail(dot)com> writes:
> This question refers to version 9.4 of Postgres. I have have a function
> Datum do_something(PG_FUNCTION_ARGS)
> {
>     ...
>     if(error_occured) {
>         ereport(ERROR, (errmsg("some error occured")));
>     }
>     ...
> }
> When I call do_something in a way to deliberately cause the error
> condition, the client connection (psql) is terminated,
[ shrug... ]  You did not show us whatever is causing that problem.
Given a self-contained example, it would be possible to offer some
useful advice.  On the basis of what you've said here, though, I can
only suggest that you're looking for the problem in the wrong place.
			regards, tom lane