public inbox for [email protected]
help / color / mirror / Atom feedFrom: Chapman Flack <[email protected]>
Subject: Re: [Pljava-dev] odd error with 1.5.0-snapshot
Date: Wed, 3 Feb 2016 15:16:16 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
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
[email protected]
http://lists.pgfoundry.org/mailman/listinfo/pljava-dev
view thread (7+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [Pljava-dev] odd error with 1.5.0-snapshot
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox