Transactions and timestamps
Transactions and timestamps
От:
Daniel Åkerud <zilch@home.se>
Дата:
If I do
BEGIN
UPDATE some_session set time_stop = CURRENT_TIMESTAMP
UPDATE another_session set time_start = CURRENT_TIMESTAMP
END
Is there any chance the current_timestamp will be different?
Do I have to first select current_timestamp and then update with a variable? (function?)
---
Daniel Åkerud
Daniel Åkerud
[ Don't underestimate the power of stupid people in large groups]
Re: Transactions and timestamps
От:
"Richard Huxton" <dev@archonet.com>
Дата:
Please don't post HTML to the mailing list - it makes quoting difficult... From: "Daniel Åkerud" If I do BEGIN UPDATE some_session set time_stop = CURRENT_TIMESTAMP UPDATE another_session set time_start = CURRENT_TIMESTAMP END Is there any chance the current_timestamp will be different? =reply= If you try your example by hand (with a suitable pause) you'll see CURRENT_TIMESTAMP and the now() function return the time at the start of the transaction. You use timeofday() IIRC to get the "real" current time. HTH - Richard Huxton
Re: Transactions and timestamps
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
=?iso-8859-1?Q?Daniel_=C5kerud?= writes: > If I do > BEGIN > UPDATE some_session set time_stop =3D CURRENT_TIMESTAMP > UPDATE another_session set time_start =3D CURRENT_TIMESTAMP > END > Is there any chance the current_timestamp will be different? No. CURRENT_TIMESTAMP is actually the time of the start of the transaction. regards, tom lane