Skip site navigation (1) Skip section navigation (2)

Re: creating a table with a serial column sets currval

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: creating a table with a serial column sets currval
Date: 2007-10-19 13:24:24
Message-ID: 10000.1192800264@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Kris Jurka <books(at)ejurka(dot)com> writes:
> On Thu, 18 Oct 2007, Tom Lane wrote:
>> It's not that it gets put in the cache, it's that read_info gets called
>> (setting elm->increment).  I think we probably should clean this up by
>> creating a separate flag in that struct that explicitly says "currval is
>> valid", which would be set by nextval(), setval() (because historically
>> it's acted that way), and I guess ALTER SEQUENCE RESTART WITH (for
>> consistency with setval()).

> Personally I think setval should only set validCurrval and the last_value 
> if iscalled = true.  If is_called = false I think it should retain the 
> previous last_value if any until the next nextval call.

Hmm.  If we did that, then ALTER RESTART WITH (which always sets
iscalled false) shouldn't affect the flag either, which would likely
simplify matters a bit.  However, it would be a change in behavior,
so I'm not convinced we should back-patch 8.2 like that.

Any other opinions out there?

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: Dawid KuroczkoDate: 2007-10-19 13:32:03
Subject: PostgreSQL 8.2 Bug in casting varchar to int in SELECT ... WHERE IN ( ... )
Previous:From: Ciprian Dorin CraciunDate: 2007-10-19 11:45:00
Subject: Re: Stalled post to pgsql-bugs

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group