values from now() in the same transaction

From: Vladimir Zelinski <zelvlad(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: values from now() in the same transaction
Date: 2007-02-16 20:32:28
Message-ID: 194565.67156.qm@web52708.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I created a function with VOLATILE directive. it's
body looks like shown bellow

------------------------ cut start
begin
insert into monitor(ts, c1) values(LOCALTIMESTAMP,
'Step 1000'); -- start time

-- query below runs for 20min
insert ito t1 select * from big_table

-- this timestamp should be bigger by 20min than start
time
insert into monitor(ts, c1) values(LOCALTIMESTAMP,
'Step 1001'); end
----------------------- cut end

The value returned by LOCALTIMESTAMP function is the
same in both places despite that actual interval of 20
min between these calls.
I tried function now(),current_timestamp() but all of
them behave similar.

I don't believe that it's bug, probably it's a feature
of the postgreSql database.

Is any way to insert a timestamp within the same
transaction that would have current system time (not
time of the beginning of the transaction)?

With other words, I would like to see different
timestamps on first and last timestamp.

Thank you,
Vladimir

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2007-02-16 21:02:36 Re: values from now() in the same transaction
Previous Message Ian Harding 2007-02-16 20:07:42 Re: requests / suggestions to help with backups