pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
now() does not change within a transaction
3+ messages / 3 participants
[nested] [flat]

* now() does not change within a transaction
@ 1970-01-01 00:00 Christoph Haller <ch@rodos.fzk.de>
  2002-04-18 12:41 ` Re: now() does not change within a transaction Karel Zak <zakkr@zf.jcu.cz>
  2002-04-18 15:50 ` Re: now() does not change within a transaction Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 2 replies; 3+ messages in thread

From: Christoph Haller @ 1970-01-01 00:00 UTC (permalink / raw)
  To: pgsql-sql

Hi pgsql-sql list, 
I did some testing around tables using a column 
timestamp with time zone not null default now(). 
I have noticed a valuable feature: 
As long as being inside a transaction initiated by 
begin; 
the return value of the now() function does not change. 
Is this intended - as written in the documentation? 
Can I rely on it, so future releases of PostgreSQL 
will act the same. 
Regards, Christoph 



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: now() does not change within a transaction
  1970-01-01 00:00 now() does not change within a transaction Christoph Haller <ch@rodos.fzk.de>
@ 2002-04-18 12:41 ` Karel Zak <zakkr@zf.jcu.cz>
  1 sibling, 0 replies; 3+ messages in thread

From: Karel Zak @ 2002-04-18 12:41 UTC (permalink / raw)
  To: Christoph Haller <ch@rodos.fzk.de>; +Cc: pgsql-sql

On Thu, Apr 18, 2002 at 02:04:35PM +0000, Christoph Haller wrote:
> Hi pgsql-sql list, 
> I did some testing around tables using a column 
> timestamp with time zone not null default now(). 
> I have noticed a valuable feature: 
> As long as being inside a transaction initiated by 
> begin; 
> the return value of the now() function does not change. 
> Is this intended - as written in the documentation? 

 Sure. See (for example):

http://docs.linux.cz/PostgreSQL/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT 

   It is quite important to realize that CURRENT_TIMESTAMP and related
   functions all return the time as of the start of the current transaction;
   their values do not increment while a transaction is running. But
   timeofday() returns the actual current time.
 
test=# select timeofday()::timestamp;
           timeofday
-------------------------------
 2002-04-18 14:39:36.459162+02

        Karel

-- 
 Karel Zak  <zakkr@zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/
 
 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: now() does not change within a transaction
  1970-01-01 00:00 now() does not change within a transaction Christoph Haller <ch@rodos.fzk.de>
@ 2002-04-18 15:50 ` Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Bruce Momjian @ 2002-04-18 15:50 UTC (permalink / raw)
  To: Christoph Haller <ch@rodos.fzk.de>; +Cc: pgsql-sql

Christoph Haller wrote:
> Hi pgsql-sql list, 
> I did some testing around tables using a column 
> timestamp with time zone not null default now(). 
> I have noticed a valuable feature: 
> As long as being inside a transaction initiated by 
> begin; 
> the return value of the now() function does not change. 
> Is this intended - as written in the documentation? 
> Can I rely on it, so future releases of PostgreSQL 
> will act the same. 

Yes, this is intended and will not change.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2002-04-18 15:50 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1970-01-01 00:00 now() does not change within a transaction Christoph Haller <ch@rodos.fzk.de>
2002-04-18 12:41 ` Karel Zak <zakkr@zf.jcu.cz>
2002-04-18 15:50 ` Bruce Momjian <pgman@candle.pha.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox