From: Dave Cramer <pg@fastcrypt.com>
To: Paul Tomblin <ptomblin@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
Date: Wed, 20 Feb 2008 09:02:35 -0500
Message-ID: <46B69302-EBE4-4A20-B903-5DD76BD5F22C@fastcrypt.com> (raw)
In-Reply-To: <8efd35820802200541p14e99d8bx60ad628302b24f14@mail.gmail.com>
References: <38245.1203500677@motionsponsor.com>
<47BC0AF6.2060500@enterprisedb.com>
<87prurrh87.fsf@mnc.ch>
<55C92F71-0317-4E91-A092-C22A7A2F1FD8@fastcrypt.com>
<47BC1AC4.5010809@gmail.com>
<9096E930-A528-4AF7-92B9-6EB1A5A52F84@fastcrypt.com>
<47BC2798.9010300@enterprisedb.com>
<DB6FA671-F2D8-4F53-B621-43560A2DA0CF@fastcrypt.com>
<8efd35820802200541p14e99d8bx60ad628302b24f14@mail.gmail.com>
On 20-Feb-08, at 8:41 AM, Paul Tomblin wrote:
> On Feb 20, 2008 8:32 AM, Dave Cramer <pg@fastcrypt.com> wrote:
>> As far as I can tall Paul has inherited an application which uses a
>> single connection for all database operations, and is a swing app
>> which has callbacks which do the following
>>
>> Callback code
>>
>> grab the global connection object
>> create a statement
>> do something
>> close statement
>>
>> in this scenario, since currval has connection scope if two callbacks
>> are called at the same time, only one will have the right answer .
>>
>> Paul am I correct in my assumptions above ?
>
> Pretty much, except with the added complication that there are a dozen
> or so daemons that are also updating the same tables, and up until now
> they've all had autocommit on. I thought the currval had transaction
> scope not connection scope, at least that's what my testing in pgsql
> seemed to indicate, which is why I stated that autocommit was a
> problem.
>
> Are you saying that if in one connection I do a nextval and commit,
> and somebody else in a different connection does a hundred nextvals
> and commits, then 20 minutes later I do the currval I'll get the one
> from my old transaction?
Yes it has connection scope, not transaction scope. currval stores the
current value in connections memory.
>
>
>
>
> --
> For my assured failures and derelictions I ask pardon beforehand of my
> betters and my equals in my Calling here assembled, praying that in
> the hour of my temptations, weakness and weariness, the memory of this
> my Obligation and of the company before whom it was entered into, may
> return to me to aid, comfort and restrain.
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
>
> http://www.postgresql.org/about/donate
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, ptomblin@gmail.com
Subject: Re: Retrieving last InsertedID : INSERT... RETURNING safe ?
In-Reply-To: <46B69302-EBE4-4A20-B903-5DD76BD5F22C@fastcrypt.com>
References: <38245.1203500677@motionsponsor.com> <47BC0AF6.2060500@enterprisedb.com> <87prurrh87.fsf@mnc.ch> <55C92F71-0317-4E91-A092-C22A7A2F1FD8@fastcrypt.com> <47BC1AC4.5010809@gmail.com> <9096E930-A528-4AF7-92B9-6EB1A5A52F84@fastcrypt.com> <47BC2798.9010300@enterprisedb.com> <DB6FA671-F2D8-4F53-B621-43560A2DA0CF@fastcrypt.com> <8efd35820802200541p14e99d8bx60ad628302b24f14@mail.gmail.com> <46B69302-EBE4-4A20-B903-5DD76BD5F22C@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