Re: Resetting a sequence's last value...
От | Sean Chittenden |
---|---|
Тема | Re: Resetting a sequence's last value... |
Дата | |
Msg-id | 20030427193937.GN35599@perrin.int.nxad.com обсуждение исходный текст |
Ответ на | Re: Resetting a sequence's last value... (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Resetting a sequence's last value...
|
Список | 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
В списке pgsql-general по дате отправления: