Received: from ara.zf.jcu.cz (ara.zf.jcu.cz [160.217.161.4]) by postgresql.org (Postfix) with ESMTP id B673647658C for ; Thu, 18 Apr 2002 08:41:31 -0400 (EDT) Received: from ara.zf.jcu.cz (LOCALHOST [127.0.0.1]) by ara.zf.jcu.cz (8.12.1/8.12.1/Debian -5) with ESMTP id g3ICfYBK016644; Thu, 18 Apr 2002 14:41:34 +0200 Received: (from zakkr@localhost) by ara.zf.jcu.cz (8.12.1/8.12.1/Debian -5) id g3ICfY83016643; Thu, 18 Apr 2002 14:41:34 +0200 Date: Thu, 18 Apr 2002 14:41:34 +0200 From: Karel Zak To: Christoph Haller Cc: pgsql-sql@postgresql.org Subject: Re: now() does not change within a transaction Message-ID: <20020418144134.A16277@zf.jcu.cz> References: <200204181204.OAA11703@rodos> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200204181204.OAA11703@rodos>; from ch@rodos.fzk.de on Thu, Apr 18, 2002 at 02:04:35PM +0000 X-Archive-Number: 200204/223 X-Sequence-Number: 7487 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 http://home.zf.jcu.cz/~zakkr/ C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz