Search Postgresql Archives

Re: Freezing localtimestamp and other time function on some value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry.
I have re-read my previous message.
It looks unclean.

For sequential calls in same transaction `now()` and `current_timestamp` will produce the same output.

```
begin; -- start a transaction

select
  now() immutable_now,
  current_timestamp immutable_current_ts,
  clock_timestamp() mutable_clock_ts;

select pg_sleep(1); -- wait a couple of time

select
  now() immutable_now, -- same as above
  current_timestamp immutable_current_ts, -- same as above
  clock_timestamp() mutable_clock_ts; -- value changed

select pg_sleep(1); -- wait a couple of time again

select
  now() immutable_now, -- same as above
  current_timestamp immutable_current_ts, -- same as above
  clock_timestamp() mutable_clock_ts; -- value changed

commit; -- commit or rollback
```


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux