Re: [GENERAL] CURRENT_TIMESTAMP

Manfred Koizar <mkoi-pg@aon.at>

From: Manfred Koizar <mkoi-pg@aon.at>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Bruce Momjian <pgman@candle.pha.pa.us>, josh@agliodbs.com, Aaron Held <aaron@MetroNY.com>, Roberto Mello <rmello@cc.usu.edu>, Neil Conway <neilc@samurai.com>, pgsql-sql@postgresql.org
Date: 2002-09-24T09:37:30Z
Lists: pgsql-hackers, pgsql-general, pgsql-sql
On Mon, 23 Sep 2002 16:55:48 -0400, Tom Lane <tgl@sss.pgh.pa.us>
wrote:
>Bruce Momjian <pgman@candle.pha.pa.us> writes:
>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).

I agree.  SQL99 mentions this requirement for triggers and I think we
can apply it to rules as well.

Here is another example:

BEGIN;
INSERT INTO foo VALUES (..., CURRENT_TIMESTAMP, ...);
-- wait a few seconds
INSERT INTO foo VALUES (..., CURRENT_TIMESTAMP, ...);
COMMIT;

Please don't ask me, why I would want that, but the standard demands
the timestamps to be different.

>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.

No, it's fundamentally different whether you do something in one
SQL-statment or per a sequence of statements.

Servus
 Manfred