values from now() in the same transaction - Mailing list pgsql-general

From Vladimir Zelinski
Subject values from now() in the same transaction
Date
Msg-id 194565.67156.qm@web52708.mail.yahoo.com
Whole thread Raw
Responses Re: values from now() in the same transaction  (Alvaro Herrera <alvherre@commandprompt.com>)
List 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


pgsql-general by date:

Previous
From: "Ian Harding"
Date:
Subject: Re: requests / suggestions to help with backups
Next
From: Alvaro Herrera
Date:
Subject: Re: values from now() in the same transaction