Thread: Bug #801: now() in transaction
Bhuvan A (bhuvansql@myrealbox.com) reports a bug with a severity of 2 The lower the number the more severe it is. Short Description now() in transaction Long Description I am using 7.2.1. now() returns same value ever, within transaction. If we use now() say 10 times in the same transaction,all 10 times we are getting the same value, irrespect of the interval. 7.2 too behaves similar. AFAIK, we had similar problem in plpgsql in 7.1 and earlier. The constant values interpreted within begin block(in plpgsql)was used on all invocations of the function, during the lifetime of backend. This behaviour have been changed in7.2 and it behaves how the programmer expect it to! But why it should happen in normal transaction now? Kindly apologize, if my understanding is wrong. regards, bhuvaneswaran Sample Code bhuvan=> begin; BEGIN bhuvan=> select now(); now --------------------------------- 2002-10-18 16:36:41.071665+05:30 bhuvan=> -- wait for few seconds bhuvan=> select now(); now --------------------------------- 2002-10-18 16:36:41.071665+05:30 bhuvan=> -- wait for few seconds bhuvan=> select now(); now --------------------------------- 2002-10-18 16:36:41.071665+05:30 bhuvan=> -- wait for few seconds bhuvan=> select now(); now --------------------------------- 2002-10-18 16:36:41.071665+05:30 bhuvan=> rollback; ROLLBACK bhuvan=> No file was uploaded with this report
On Fri, Oct 18, 2002 at 07:23:29 -0400, pgsql-bugs@postgresql.org wrote: > Bhuvan A (bhuvansql@myrealbox.com) reports a bug with a severity of 2 > The lower the number the more severe it is. > > Short Description > now() in transaction > > Long Description > I am using 7.2.1. now() returns same value ever, within transaction. If we use now() say 10 times in the same transaction,all 10 times we are getting the same value, irrespect of the interval. 7.2 too behaves similar. This is how it is supposed to work. If you need the current time, rather than transaction start time, use timeofday(). This is covered in the documentation.