Skip site navigation (1) Skip section navigation (2)

Re: BUG #2198: Now returns always same date and time during a session

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Jacques Gollion <jgollion(at)sambatechnologies(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2198: Now returns always same date and time during a session
Date: 2006-01-23 17:37:45
Message-ID: 20060123173745.GA1659@winnie.fuhr.org (view raw or flat)
Thread:
Lists: pgsql-bugs
On Mon, Jan 23, 2006 at 11:40:43AM +0000, Jacques Gollion wrote:
> The following functions returns the first time the right date and time but
> when called at several date and time returns the date that was returned at
> the first call.

See "Current Date/Time" in the documentation:

http://www.postgresql.org/docs/8.1/interactive/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT

"It is important to know that CURRENT_TIMESTAMP and related functions
return the start time of the current transaction; their values do
not change during the transaction.  This is considered a feature:
the intent is to allow a single transaction to have a consistent
notion of the 'current' time, so that multiple modifications within
the same transaction bear the same time stamp."

"There is also the function timeofday() which returns the wall-clock
time and advances during transactions."

> To get again the right date, it is necessary do disconnect and reconnect.

Do you have autocommit disabled?  I'd guess all of your function
calls are happening in the same transaction.  You shouldn't have
to reconnect; starting a new transaction should work.

-- 
Michael Fuhr

In response to

pgsql-bugs by date

Next:From: Peter EisentrautDate: 2006-01-23 19:20:03
Subject: Re: BUG #2203: Group by, suggested "feature"
Previous:From: Brandon BlackDate: 2006-01-23 17:34:27
Subject: BUG #2204: Feature Req: Unique output column names

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group