Re: currval question

From: Garo Hussenjian <garo(at)xapnet(dot)com>
To: Andy Kriger <akriger(at)greaterthanone(dot)com>, Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: currval question
Date: 2002-09-16 22:34:05
Message-ID: B9ABAA6D.35CE%garo@xapnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Andy,

I don't know exactly what's under the hood, but I know that currval() won't
even return a result unless you've used nextval() in your session. If
currval() did not operate solely within the scope of the session, it stands
to reason that it would return a result... It's behavior (from the driver's
seat) is consistent with a well conceived concurrency model. This should be
easy enough to test with a couple of terminals. My money is on Postgres! :)

Regards,
Garo.

on 9/16/02 3:14 PM, Andy Kriger at akriger(at)greaterthanone(dot)com wrote:

> I am trying to get the last value updated by an column auto-incrementing
> with nextval(). In MySQL, you'd use LAST_INSERT_ID() - in Postgre, currval()
> appears to do the trick.
>
> Is this maintained on a per-connection basis? For example, user A inserts
> and the nextval() updates to 5, user B does 2 inserts, updating nextval() to
> 7. When user A calls currval() they should get 5 if the updates are per-cnx.
> What does psql do under the hood here?
>
> thx
> a
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>

=-=-==-=-=-==

Xapnet Internet Solutions
1501 Powell St., Suite N
Emeryville, CA 94608

Tel - (510) 655-9771
Fax - (510) 655-9775
Web - http://www.xapnet.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Cindy 2002-09-16 22:42:57 plperl.so
Previous Message Tino Wildenhain 2002-09-16 22:23:30 Re: currval question