From: Dave Cramer <pg@fastcrypt.com>
To: Albe Laurenz <all@adv.magwien.gv.at>
Cc: roehm@it.usyd.edu.au
Cc: pgsql-jdbc@postgresql.org
Subject: Re: autocommit and stored procedures
Date: Thu, 16 Aug 2007 06:19:56 -0400
Message-ID: <77ED2597-BCE7-4BD1-9BD2-14EC2E178099@fastcrypt.com> (raw)
In-Reply-To: <D960CB61B694CF459DCFB4B0128514C2116E9A@exadv11.host.magwien.gv.at>
References: <D3A9FBB1-6304-4B25-878D-E0F1C06280BA@it.usyd.edu.au>
<D960CB61B694CF459DCFB4B0128514C2116E9A@exadv11.host.magwien.gv.at>
On 16-Aug-07, at 5:46 AM, Albe Laurenz wrote:
> roehm@it.usyd.edu.au wrote:
>> In particular, does an JDBC autocommit around the call to a stored
>> procedure commit each statement within that stored procedure, or does
>> it commit the procedure as a whole?
>
> A function in PostgreSQL is always executed within one single
> transaction, so you cannot commit only part of the SQL-statements
> within a function.
>
> The JDBC 4.0 specification says:
>
> The Connection attribute auto-commit specifies when to end
> transactions. Enabling
> auto-commit causes a transaction commit after each individual SQL
> statement as
> soon as that statement is complete. The point at which a statement
> is considered to
> be "complete" depends on the type of SQL statement as well as what
> the application
> does after executing it:
>
> ■ For Data Manipulation Language (DML) statements such as Insert,
> Update,
> Delete, and DDL statements, the statement is complete as soon as
> it has finished
> executing.
> ■ For Select statements, the statement is complete when the
> associated result set
> is closed.
> ■ For CallableStatement objects or for statements that return
> multiple results,
> the statement is complete when all of the associated result sets
> have been closed,
> and all update counts and output parameters have been retrieved.
Isn't that interesting I wonder who's database has the above select
and CallableStatement semantics.
Dave
>
> To me that seems to mean that if I do
>
> executeUpdate("SELECT myfunction()")
>
> the autocommit should occur after the select statement is finished,
> i.e.
> after the complete function has been executed.
>
> But I'll admit that this is disputable...
>
> Yours,
> Laurenz Albe
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
> choose an index scan if your joining column's datatypes do not
> match
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: pg@fastcrypt.com, all@adv.magwien.gv.at, roehm@it.usyd.edu.au
Subject: Re: autocommit and stored procedures
In-Reply-To: <77ED2597-BCE7-4BD1-9BD2-14EC2E178099@fastcrypt.com>
References: <D3A9FBB1-6304-4B25-878D-E0F1C06280BA@it.usyd.edu.au> <D960CB61B694CF459DCFB4B0128514C2116E9A@exadv11.host.magwien.gv.at> <77ED2597-BCE7-4BD1-9BD2-14EC2E178099@fastcrypt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox