From: | Sean Chittenden <sean(at)chittenden(dot)org> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Shridhar Daithankar <shridhar_daithankar(at)persistent(dot)co(dot)in>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Resetting a sequence's last value... |
Date: | 2003-04-27 19:39:37 |
Message-ID: | 20030427193937.GN35599@perrin.int.nxad.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> > I'm looking to have things return an error if someone calls
> > currval() on the sequence. -sc
>
> There isn't any mechanism for that, although I imagine it wouldn't
> be hard to add such a function to commands/sequence.c. But the
> requirement seems a bit bizarre. Maybe there's a better way to do
> whatever you're after?
Controlling/policing the source tree is the other option. Here's a
quick description:
I have a transaction table that I use to record meta data about the
connection (current user, ip that they're connecting from, time,
etc.). The transaction ID (txn_id) returned from the start_txn()
function calls nextval() on the txn_id_seq. Every subsequent table
calls currval() on that particular sequence, however after certain
policy based places in the transaction, I need the caller to start a
new transaction. If a programmer lapses to call start_txn() again,
then the audit trail gets really fuzzy and it becomes impossible to
differentiate a 1st transaction from a 2nd transaction. As opposed to
policing the source tree for possible errors, I'd like a technological
solution that will allow me to call, "invalidate_currval('txn_id')" or
some such that way the next time someone tries to call
currval('txn_id'), they'll get a nice big fat juicy error that'll
abort the remainder of their transaction.
Thoughts? I got a post offlist suggesting writing a C function, but
that's pretty dependent on the backend and would have to be recompiled
from version to version, something I'm not too wild about. -sc
--
Sean Chittenden
From | Date | Subject | |
---|---|---|---|
Next Message | Bruno Wolff III | 2003-04-27 20:52:16 | Re: Resetting a sequence's last value... |
Previous Message | Tom Lane | 2003-04-27 15:36:02 | Re: Cannot use the queries buffer of psql... :-( |