New setval() call

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: New setval() call
Date: 2001-02-10 17:23:52
Message-ID: 200102101723.MAA04962@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I am inclinded to remove this open item:

New SQL function setval(seq,val,bool) for use in pg_dump (Philip)

The use of the 3rd parameter, 'iscalled', while used by pg_dump, is not
of general use, so we probably don't need to document it. Is this valid?

Info on the new param is:

---------------------------------------------------------------------------

IRC the point of the nextval() is to ensure that the internal state of
the sequence is correct. There's a bool "is_called" in the sequence
that means something like "I've been nextval()'d at least once", and the
only clean way to make that become set is to issue a nextval. You can
watch the behavior by doing "select * from sequenceobject" between
sequence commands --- it looks like the first nextval() simply sets
is_called without changing last_value, and then subsequent nextval()s
increment last_value. (This peculiar arrangement makes it possible
to have a starting value equal to MININT, should you want to do so.)
So pg_dump needs to make sure it restores the correct setting of both
fields.

This is pretty grotty because it looks like there's no way to clear
is_called again, short of dropping and recreating the sequence.
So unless you want to do that always, a data-only restore couldn't
guarantee to restore the state of a virgin sequence.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2001-02-10 18:09:23 Re: Re: [PATCHES] Fix for ODBC close
Previous Message Bruce Momjian 2001-02-10 17:17:13 Re: Re: [PATCHES] Fix for ODBC close