Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id CCBCF632859; Mon, 1 Jun 2009 09:56:21 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 10027-08; Mon, 1 Jun 2009 09:56:03 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail2007.strasbourg.4js.com (mail2007.strasbourg.4js.com [84.14.60.197]) by mail.postgresql.org (Postfix) with ESMTP id 48CEF63515B; Mon, 1 Jun 2009 09:56:10 -0300 (ADT) Received: from fox.strasbourg.4js.com (AStrasbourg-151-1-3-80.w83-194.abo.wanadoo.fr [83.194.97.80]) (authenticated bits=0) by mail2007.strasbourg.4js.com (8.13.8/8.13.8/Debian-3) with ESMTP id n51Cu1Q1022694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 1 Jun 2009 14:56:06 +0200 Message-ID: <4A23CFFD.9050207@4js.com> Date: Mon, 01 Jun 2009 14:56:29 +0200 From: Sebastien FLAESCH Organization: Four J's Development Tools User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: Tom Lane CC: pgsql-general@postgresql.org, mmoncure@gmail.com, pgsql-hackers@postgresql.org Subject: Re: INTERVAL SECOND limited to 59 seconds? References: <4A127038.3010103@4js.com> <15585.1243805733@sss.pgh.pa.us> In-Reply-To: <15585.1243805733@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.94/9410/Mon Jun 1 13:15:49 2009 on mail2007.strasbourg.4js.com X-Virus-Status: Clean X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (mail2007.strasbourg.4js.com [10.10.0.1]); Mon, 01 Jun 2009 14:56:07 +0200 (CEST) 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: 200906/22 X-Sequence-Number: 148366 Thank you Tom for looking at this. I would be pleased to help on testing the fix when available. My plan is to store Informix INTERVALs (coming from the 4gl applications we support) into PostgreSQL INTERVALs, and I have a bunch of tests for that... I believe Informix INTERVALs (and related operators and functions) are not 100% SQL99, but they are close... Thanks a lot! Seb Tom Lane wrote: > 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 precision>, 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 >