Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id BCFA7476585; Mon, 30 Sep 2002 13:59:25 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 0C9B647659E; Mon, 30 Sep 2002 13:59:25 -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 g8UHx0hR023266; Mon, 30 Sep 2002 13:59:00 -0400 (EDT) To: Bruce Momjian Cc: josh@agliodbs.com, Martijn van Oosterhout , Manfred Koizar , Roland Roberts , pgsql-sql@postgresql.org, pgsql-general@postgresql.org Subject: Re: [SQL] CURRENT_TIMESTAMP In-reply-to: <200209301620.g8UGKsq24305@candle.pha.pa.us> References: <200209301620.g8UGKsq24305@candle.pha.pa.us> Comments: In-reply-to Bruce Momjian message dated "Mon, 30 Sep 2002 12:20:54 -0400" Date: Mon, 30 Sep 2002 13:59:00 -0400 Message-ID: <23265.1033408740@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/1402 X-Sequence-Number: 30983 Bruce Momjian writes: > Notice the part I highlighted. The time returned is > implementation-dependent "during the execution of S". Now, if we do: > BEGIN; > SELECT CURRENT_TIMESTAMP; > SELECT CURRENT_TIMESTAMP; > the time currently returned for the second query is _not_ during the > duration of S (S being an SQL procedure statement) Not so fast. What is an "SQL procedure statement"? Our interactive commands do not map real well to the spec's definitions. Consider for example SQL92 section 4.17: 4.17 Procedures A consists of a , a sequence of s, and a single . ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A in a is invoked by a compilation unit as- sociated with the by means of a host language "call" statement that specifies the of the and supplies a sequence of parameter values corresponding in number and in to the s of the . A call of a causes the that it contains to be executed. The only thing you can easily map this onto in Postgres is stored functions; your reading would then say that each Postgres function call requires its own evaluation of current_timestamp, which I think we are all agreed would be a disastrous interpretation. It would be pretty easy to make the case that an ECPG module represents a "procedure" in the spec's meaning, in which case it is *necessary* for spec compliance that the ECPG module be able to execute all its commands with the same value of current_timestamp. This would look like a series of interactive commands to the backend. So I do not think that the spec provides clear support for your position. The only thing that is really clear is that there is a minimum unit of execution in which current_timestamp is not supposed to change. It does not clearly define any maximum unit; and it is even less clear that our interactive commands should be equated to "SQL procedure statement". regards, tom lane