db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Eade <se...@backstagetech.com.au>
Subject Re: Problem w/PostgreSQL Insert
Date Tue, 17 Feb 2004 13:05:09 GMT
Sean Laurent wrote:

>I already posted about this, but no one responded, so I'll try again.
>
>There  is a bug in the PostgreSQL adapter code that Tim Regovich pointed out 
>in December of 2002:
>http://nagoya.apache.org/eyebrowse/ReadMsg?listName=torque-dev@db.apache.org&msgId=590783
>
>The basic idea is that getIDMethodSQL() uses the 'currval' function, which 
>causes problems on inserts with an error messages like 'xxx.currval is not 
>yet defined in this session.'
>
>According to the PostgreSQL documentation, currval() returns "the value most 
>recently obtained by nextval for this sequence in the current session. (An 
>error is reported if nextval has never been called for this sequence in this 
>session.)"  Notice the part in parenthesis.  For new sessions, nextval() will 
>never have been called and thus currval() won't work.
>
>The proper solution is simply to use nextval() instead of currval().  I was 
>easily able to change this in my copy of the Torque code and my testing 
>indicates that it's now working properly.
>
>What can I do to help make certain this gets fixed in the main Torque 
>development line?
>
>-Sean
>  
>
You will find if you trace the code that Torque retrieves the id value 
after the insert takes place and hence currval() is correct.

Using currval() has fewer concurrency issues than using nextval(), I 
believe this may be why it is used.

Scott

-- 
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message