From: | Chapman Flack <chap(at)anastigmatix(dot)net> |
---|---|
To: | |
Subject: | Re: [Pljava-dev] odd error with 1.5.0-snapshot |
Date: | 2016-02-03 20:16:16 |
Message-ID: | 56B26010.2010207@anastigmatix.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pljava-dev |
On 02/03/2016 02:24 PM, John R Pierce wrote:
> curious if you have any hints about what that SQLException means.
> java.sql.SQLException: An attempt was made to call a PostgreSQL
> backend function after an elog(ERROR) had been issued
Ok, what it ostensibly means is: the code had, in the past, made
some call into PostgreSQL that ereport()ed an ERROR. That turns
into an SQLException in PL/Java (not the one we're looking at
here, this had to have happened earlier). Perhaps the code had
a try/catch block and caught that exception, and now it wants to
proceed and do more stuff.
Trouble is, whenever an ERROR has been thrown from a call into
PostgreSQL, we don't know what possibly gronkled state the
transaction has been left in, and for the remainder of this PL/Java
function call, no more access to PostgreSQL is going to be allowed.
That's what produced *this* SQLException, at the point where the
code seems to be going ahead and setting a parameter in a prepared
statement.
If you are writing PL/Java code that does want to catch an exception
thrown from PostgreSQL, recover and proceed to do more stuff, there
is one way to do that. You have to use sp = conn.setSavepoint()
in advance of where the exception might be thrown, and
conn.releaseSavepoint(sp) in the normal case where your call
is successful. In the catch block if an exception has been thrown,
use conn.rollback(sp) to put the transaction back into a known
non-gronkled state and now you can proceed to make more calls.
That was the official answer. A different interesting question
might be, what was the earlier exception that had been thrown and
caught, and why was it thrown in this case if the same code had
been in use before? They might want to redo the test with
client_min_messages or log_min_messages (or both) set to DEBUG2
or higher.
-Chap
_______________________________________________
Pljava-dev mailing list
Pljava-dev(at)lists(dot)pgfoundry(dot)org
http://lists.pgfoundry.org/mailman/listinfo/pljava-dev
From | Date | Subject | |
---|---|---|---|
Next Message | Frédéric OLIVIE | 2016-02-03 21:38:03 | RE: [Pljava-dev] odd error with 1.5.0-snapshot |
Previous Message | John R Pierce | 2016-02-03 19:24:10 | [Pljava-dev] odd error with 1.5.0-snapshot |