calling currval() before nextval() patch adding currval_isset() - Mailing list pgsql-patches

From John Hansen
Subject calling currval() before nextval() patch adding currval_isset()
Date
Msg-id 1099866110.16869.14.camel@localhost.localdomain
Whole thread Raw
Responses Re: calling currval() before nextval() patch adding  (Rod Taylor <pg@rbt.ca>)
Re: calling currval() before nextval() patch adding currval_isset()  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: calling currval() before nextval() patch adding currval_isset()  (John Hansen <john@oztralis.com.au>)
List pgsql-patches
Hi list,

attached, cvs context diff that adds currval_isset('sequence_name');

This avoids the warning messages you get when calling currval before
nextval in situations where the program flow does not allow you to
predetermine if the current session has called nexval yet.

I have for example, a general db_insert function, that needs to return
the currval value, or 0 if the table that was inserted on doesn't have a
sequence (sortof emulating mysql's last_insert_id function).

With this patch, I can now call currval_isset to determine if I need to
call currval. Previously, I just called currval, but with the result of
filling up the server log with warnings.

Kind Regards,

John Hansen

PS I picked OID 1295 for this function, as it's currently available
according to unused_oids.


Attachment

pgsql-patches by date:

Previous
From: Alin Vaida
Date:
Subject: Romanian translation for 8.0: new file (psql)
Next
From: Andrew Dunstan
Date:
Subject: win32 cleanup