I encountered a problem (bug? feature?) where "select currval('sequence')" 
will generate an error if "select nextval('sequence')" is not executed first.  
The attached patch will change this behaviour by reading the sequence tuple 
and returning the last_value attribute if nextval has not been called on the 
sequence yet.

The patched code appears to work as intended and did not have any effect on 
the output of the regression test.


____       | Billy G. Allie    | Domain....: Bill.Allie@mug.org
|  /|      | 7436 Hartwell     | Compuserve: 76337,2061
|-/-|----- | Dearborn, MI 48126| MSN.......: B_G_Allie@email.msn.com
|/  |LLIE  | (313) 582-1540    |
Mon, 02 Mar 1998 01:16:24 -0500
"Billy G. Allie" <Bill.Allie@mug.org>
Changes to sequence.c
Billy G. Allie wrote:
> 
> I encountered a problem (bug? feature?) where "select currval('sequence')"
> will generate an error if "select nextval('sequence')" is not executed first.
> The attached patch will change this behaviour by reading the sequence tuple
> and returning the last_value attribute if nextval has not been called on the
> sequence yet.

This is feature :)
1. This is what Oracle does.
2. currval () is described as returning value returned by
   last nextval() in _session_.

Vadim

Mon, 02 Mar 1998 14:55:47 +0700
"Vadim B. Mikheev" <vadim@sable.krasnoyarsk.su>
Re: [PATCHES] Changes to sequence.c
Vadim B. Mikheev wrote:
>Billy G. Allie wrote:
>> 
>> I encountered a problem (bug? feature?) where "select currval('sequence')"
>> will generate an error if "select nextval('sequence')" is not executed 
first.
> 
>This is feature :)
>1. This is what Oracle does.
>2. currval () is described as returning value returned by
>   last nextval() in _session_.
> 
>Vadim
> 
Does this mean we should not modify this behavior because "this is what Oracle 
does"?  I can envision where using currval() before nextval() can be useful.

-- 
____       | Billy G. Allie    | Domain....: Bill.Allie@mug.org
|  /|      | 7436 Hartwell     | Compuserve: 76337,2061
|-/-|----- | Dearborn, MI 48126| MSN.......: B_G_Allie@email.msn.com
|/  |LLIE  | (313) 582-1540    | 



Thu, 05 Mar 1998 22:44:31 -0500
"Billy G. Allie" <Bill.Allie@mug.org>
Re: [HACKERS] Re: [PATCHES] Changes to sequence.c 
Billy G. Allie wrote:
> 
> Vadim B. Mikheev wrote:
> >Billy G. Allie wrote:
> >>
> >> I encountered a problem (bug? feature?) where "select currval('sequence')"
> >> will generate an error if "select nextval('sequence')" is not executed
> first.
> >
> >This is feature :)
> >1. This is what Oracle does.
> >2. currval () is described as returning value returned by
> >   last nextval() in _session_.
> >
> >Vadim
> >
> Does this mean we should not modify this behavior because "this is what Oracle
> does"?  I can envision where using currval() before nextval() can be useful.

Actually, what you are proposing was initial behaviour of currval().
This was changed to be more consistent with 1. & 2. (note - not only 1.,
but 2. also).

But personally I haven't objection against changing this again.
Men, vote pls!

Vadim

Fri, 06 Mar 1998 19:39:58 +0700
"Vadim B. Mikheev" <vadim@sable.krasnoyarsk.su>
Re: [HACKERS] Re: [PATCHES] Changes to sequence.c