It appears that sequence.last_value and nextval('sequence') are out of sync
when first created. My comments below are in [brackets]. Is this by design
or is this a bug? Does this conform to SQL92? TIA.
--rob
partner=> create SEQUENCE junk;
CREATE
partner=> select junk.last_value;
last_value
------------
1 [ last value is one . . . Thought it would be 0, but
that's no big deal]
(1 row)
partner=> select nextval('junk');
nextval
---------
1 [If last value was one then why is nextval() not 2 ?!?!?]
(1 row)
partner=> select junk.last_value;
last_value
------------
1 [Consistent, but I expected 2 as described above]
(1 row)
partner=> select nextval('junk');
nextval
---------
2 [Ahhh now that's better]
(1 row)
partner=> select junk.last_value;
last_value
------------
2 [Just what I expected . . . ]
(1 row)