X-Original-To: pgsql-patches-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 4B8329DCF92 for ; Mon, 20 Mar 2006 19:17:22 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 10992-07 for ; Mon, 20 Mar 2006 19:17:24 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) by postgresql.org (Postfix) with ESMTP id AB2359DCE4C for ; Mon, 20 Mar 2006 19:17:19 -0400 (AST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.11.6) id k2KNHM110309; Mon, 20 Mar 2006 18:17:22 -0500 (EST) From: Bruce Momjian Message-Id: <200603202317.k2KNHM110309@candle.pha.pa.us> Subject: Re: Additional current timestamp values In-Reply-To: <441F351E.8030203@samurai.com> To: Neil Conway Date: Mon, 20 Mar 2006 18:17:22 -0500 (EST) CC: Brendan Jurd , pgsql-patches@postgresql.org X-Mailer: ELM [version 2.4ME+ PL121 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.462 required=5 tests=[AWL=-0.038, RAZOR2_CHECK=0.5] X-Spam-Score: 0.462 X-Spam-Level: X-Archive-Number: 200603/218 X-Sequence-Number: 19222 Neil Conway wrote: > Bruce Momjian wrote: > > CURRENT_TIMESTAMP might not be the > > transaction start time on other database systems. > > For this reason, and for completeness, > > transaction_timestamp is provided. > > Well, transaction_timestamp() is even more unlikely to be the > transaction start time on other database systems :) If the user wants > non-standard syntax for getting the timestamp at which the current > transaction began, we already have now(). True, which is why I brought it up. I think a good argument can be made that we don't need two non-standard ways of specifying the transaction timestamp, but we need to decide that as a group. > > One trick is that these should be the same: > > > > test=> SELECT statement_timestamp(), transaction_timestamp(); > > Should they be? It seems quite reasonable to me that the DBMS begins a > transaction internally (setting transaction_timestamp()), and then a > short while later begins executing the statement submitted by the user, > at which point statement_timestamp() is set. > > Perhaps ensuring they are identical for single-statement transactions is > the best behavior, I just don't think this is required behavior. Yea, perhaps it isn't required, but it seems like a good idea. It will avoid confusion and seems logical. :-) > > And these should be the same: > > > > $ psql -c ' > > INSERT INTO t VALUES (statement_timestamp()); > > INSERT INTO t VALUES (statement_timestamp());' test > > INSERT 0 1 > > Uh, why should these be the same? This gets into cases where a single statement generates more than one parsenode, e.g. rules. We want all the parse nodes to have the same timestamp. We had a long discussion that the statement time isn't really meaningful/logical, so I went with code that said the statement arrival time is the proper time to return, and be consistent. -- Bruce Momjian http://candle.pha.pa.us SRA OSS, Inc. http://www.sraoss.com + If your life is a hard drive, Christ can be your backup. +