Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 32A24633E74; Sun, 31 May 2009 18:35:40 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 10254-03; Sun, 31 May 2009 18:35:38 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 6DC35633C8D; Sun, 31 May 2009 18:35:38 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n4VLZX28015586; Sun, 31 May 2009 17:35:33 -0400 (EDT) To: Sebastien FLAESCH cc: pgsql-general@postgresql.org, mmoncure@gmail.com, pgsql-hackers@postgresql.org Subject: Re: INTERVAL SECOND limited to 59 seconds? In-reply-to: <4A127038.3010103@4js.com> References: <4A127038.3010103@4js.com> Comments: In-reply-to Sebastien FLAESCH message dated "Tue, 19 May 2009 10:39:20 +0200" Date: Sun, 31 May 2009 17:35:33 -0400 Message-ID: <15585.1243805733@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200905/1207 X-Sequence-Number: 148344 Sebastien FLAESCH writes: > I would expect that an INTERVAL SECOND can store more that 59 seconds. I took a look into the SQL spec and I think that we do indeed have a spec compliance issue here. SQL99 section 4.7 saith Within a value of type interval, the first field is constrained only by the of the associated . Table 8, "Valid values for fields in INTERVAL values", specifies the constraints on subsequent field values. [ Table 8 says about what you'd expect, eg 0..23 for HOUR ] Values in interval fields other than SECOND are integers and have precision 2 when not the first field. SECOND, however, can be defined to have an that indicates the number of decimal digits maintained following the decimal point in the seconds value. When not the first field, SECOND has a precision of 2 places before the decimal point. So in other words, "999 seconds" is a valid value for a field of type INTERVAL SECOND, *and should come out the same way*, not as "00:16:39", and certainly not as "00:00:39". It might be a relatively easy fix to not truncate the input value incorrectly. I haven't looked, but I think we should look now, because 8.4 has already changed the behavior in this area and it would be good not to change it twice. The focus of the 8.4 work was to make sure that we would correctly interpret the values of spec-compliant interval literals, but this example shows we are not there yet. We are fairly far away from being able to make it print out as the spec would suggest, because interval_out simply doesn't have access to the information that the field is constrained to be INTERVAL SECOND rather than some other kind of interval. We also have got no concept at all of , only of , so constraining the leading field to only a certain number of integral digits isn't possible either. I don't foresee anything getting done about either of those points for 8.4. regards, tom lane