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

From John Hansen
Subject calling currval() before nextval() patch adding currval_isset()
Date
Msg-id 1099865909.16869.11.camel@localhost.localdomain
Whole thread Raw
List pgsql-hackers
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-hackers by date:

Previous
From: Gaetano Mendola
Date:
Subject: Bittorrent
Next
From: David Fetter
Date:
Subject: Re: Bittorrent