Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3009C475C85 for ; Mon, 23 Sep 2002 16:58:59 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 87F5D475C15 for ; Mon, 23 Sep 2002 16:58:58 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.5/8.12.5) with ESMTP id g8NKtm5D004620; Mon, 23 Sep 2002 16:55:48 -0400 (EDT) To: Bruce Momjian Cc: josh@agliodbs.com, Manfred Koizar , Aaron Held , Roberto Mello , Neil Conway , pgsql-sql@postgresql.org Subject: Re: [GENERAL] CURRENT_TIMESTAMP In-reply-to: <200209232041.g8NKfix19001@candle.pha.pa.us> References: <200209232041.g8NKfix19001@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Mon, 23 Sep 2002 16:41:44 -0400" Date: Mon, 23 Sep 2002 16:55:48 -0400 Message-ID: <4619.1032814548@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/278 X-Sequence-Number: 9555 Bruce Momjian writes: > I don't see how we can defend returning the start of the transaction as > the current_timestamp. Here's an example: CREATE RULE foo AS ON INSERT TO mytable DO ( INSERT INTO log1 VALUES (... , now(), ...); INSERT INTO log2 VALUES (... , now(), ...) ); I think it's important that these commands store the same timestamp in both log tables (not to mention that any now() being stored into mytable itself generate that same timestamp). If you scale that up just a little bit, you can devise scenarios where successive client-issued commands (within a single transaction) want to store the same timestamp. After all, it's only a minor implementation detail that you chose to fire these logging operations via a rule and not by client-side logic. In short, there are plenty of situations where it's critical for application correctness that a series of commands all be able to operate with the same value of now(). I don't think that it's wise for Postgres to try to decide where within a transaction it's safe to advance now(). That will inevitably break some applications, and it's not obvious what the benefit is. In short: if you want exact current time, there's timeofday(). If you want start of transaction time, we've got that. If you want start of current statement time, I have two questions: why, and exactly how do you want to define current statement, considering functions, rules, triggers, and all that other stuff that makes it interesting? ISTM that if a client or function wants to record intratransaction times, it can call timeofday() at the appropriate points for itself. regards, tom lane