calling currval() before nextval() patch adding currval_isset()

From: John Hansen <john(at)geeknet(dot)com(dot)au>
To: pgsql-hackers(at)postgresql(dot)org
Subject: calling currval() before nextval() patch adding currval_isset()
Date: 2004-11-07 22:18:29
Message-ID: 1099865909.16869.11.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
currval_isset.diff text/x-patch 3.2 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2004-11-07 22:45:26 Re: Bittorrent
Previous Message Gaetano Mendola 2004-11-07 21:53:22 Bittorrent