From: | Dave Cramer <pg(at)fastcrypt(dot)com> |
---|---|
To: | Adriaan Joubert <a(dot)joubert(at)albourne(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: currval() race condition on server? |
Date: | 2006-10-23 14:34:36 |
Message-ID: | 7D3F1FCD-9258-4F8F-841B-219C62E248D5@fastcrypt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin pgsql-jdbc |
On 23-Oct-06, at 9:49 AM, Adriaan Joubert wrote:
> Hi,
>
> I've run into an intermittent problem with our code recently. We
> have the following set-up:
>
> table A : some data table
> table B : a history table for table A
>
> A trigger copies the old version of a row into table B whenever an
> update is done on table A. Both A and B contain an audit number,
> and the trigger obtains an audit number from a sequence and inserts
> it into the row inserted into table A.
>
> For some bookkeeping purposes I need the new audit number back from
> the update, so I submit a prepared statement through jdbc of the form
>
> UPDATE A SET ....; SELECT currval('ip_audit_seq');
>
> On the first call I get
>
> ERROR: currval of sequence "ip_audit_seq" is not yet defined in
> this session
currval is only defined after you call nextval in that connection.
>
> Note that this works without any trouble if I issue the commands in
> a transaction through psql, and this used to work in earlier
> versions of postgres.
>
> We have a lot of users on very high latency links, so it is
> important for the responsiveness of the application to try to do
> the update and select in a single database trip.
>
> So I'm wondering whether there is some type of race condition,
> where the selection of the new value from ip_audit_seq is not
> available to the currval function straight away? Anybody got any
> ideas on this?
There is no race condition
>
> Cheers,
>
> Adriaan
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>
From | Date | Subject | |
---|---|---|---|
Next Message | Adriaan Joubert | 2006-10-23 15:25:47 | Re: currval() race condition on server? |
Previous Message | Tom Lane | 2006-10-23 14:23:43 | Re: currval() race condition on server? |
From | Date | Subject | |
---|---|---|---|
Next Message | Adriaan Joubert | 2006-10-23 15:25:47 | Re: currval() race condition on server? |
Previous Message | Tom Lane | 2006-10-23 14:23:43 | Re: currval() race condition on server? |