Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 4CA5A63568A for ; Mon, 8 Jun 2009 21:25:52 -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 38060-01-5 for ; Mon, 8 Jun 2009 21:25:50 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp110.biz.mail.mud.yahoo.com (smtp110.biz.mail.mud.yahoo.com [68.142.201.179]) by mail.postgresql.org (Postfix) with SMTP id D319A63868A for ; Mon, 8 Jun 2009 21:25:28 -0300 (ADT) Received: (qmail 51043 invoked from network); 9 Jun 2009 00:25:26 -0000 Received: from unknown (HELO ?192.168.5.110?) (rm_pg@76.201.140.35 with plain) by smtp110.biz.mail.mud.yahoo.com with SMTP; 9 Jun 2009 00:25:26 -0000 X-Yahoo-SMTP: acjdBE2swBAAX9ja0RY4hQi0ggqg.Ml3.omUEQJ1xZsuGIb6CRE- X-YMail-OSG: KY8BPecVM1nuYH8qZEQjSRQ3PO0_lDBYGGI.C8.nx_3KR6y6ZefVnXFOe114IFmwIVJnAISsmFSyMluXnpC2SL1ZpTs51AxIucFNDl8s3CdSnUBZI8h7QaaHWc4dzjKStxSNVgQvaX4.ToDfDCPQAUMuZK1tWeNE3lBixiGVcOlNuD3kh24QnjhD4PR2EsKp1ryoBBr3TCeHjGXGtyuCIm3btUzUG4Rs2yNCSgo9wgBD.npSOzeWbr2MSt4eN85eXMJxIfKg2yn5vPmEuqZFfGkt4O5O8pOms2T746b5dCvWwDt6PJDh.1Nh7yTQOaYh44E5KLAUcY_0g8oNVBs9dhuXZo38mlzJfu2hhKloICC3Bmwk X-Yahoo-Newman-Property: ymail-3 Message-ID: <4A2DABF5.3070906@cheapcomplexdevices.com> Date: Mon, 08 Jun 2009 17:25:25 -0700 From: Ron Mayer User-Agent: Thunderbird 2.0.0.21 (X11/20090318) MIME-Version: 1.0 To: Tom Lane CC: Ron Mayer , Sebastien FLAESCH , pgsql-general@postgresql.org, mmoncure@gmail.com Subject: Re: INTERVAL SECOND limited to 59 seconds? References: <4A127038.3010103@4js.com> <4A2C0E02.9070908@cheapcomplexdevices.com> <17203.1244402910@sss.pgh.pa.us> In-Reply-To: <17203.1244402910@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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/437 X-Sequence-Number: 148781 Tom Lane wrote: > Ron Mayer writes: >> Looks like the original questions from the thread >> got resolved, but I found this behaviour surprising: > >> regression=# select interval '1' day to second; >> interval >> ---------- >> @ 1 hour >> (1 row) > >> Should this be 1 second? > > That is a bit odd, especially seeing that eg. '1' hour to second > comes out as 1 second. What's making it do that? What from a design point of view? Seems like it's a side effect of the logic that makes: select interval '1 2'; know that the 2 means hours rather than seconds. Code-wise, it seems because around line 2906 in DecodeInterval: switch (range) ... case INTERVAL_MASK(DAY) | INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND): type=DTK_HOUR; But if I naively change that by making it DTK_SECOND, I'd break "select interval '1 2' day to second;". I guess I'd need to tweak it to say: if it follows a days filed it means hours; but by itself it means seconds? There's a bit of other odd stuff around there. It seems CVS head accepts "select interval '1 2' hour;" but not "select interval '1 2' hour to minute;" regression=# select interval '1 2' hour; interval ---------------- 1 day 02:00:00 (1 row) and I would have guessed that either both should succeed or both should fail. And if both succeed I wouldn't have expected 1 day 2 hours...... I'd still be happy to send a patch, but am still trying to figure out what the desired behavior is. My current impression: What's the desired behavior for each of these: select interval '1' day to second; --- should it be 1 second to be consistent with "select interval 1;"? --- or an error as Sebastien argued in a different part of the thread? select interval '1 2' hour; --- should be an error as "select interval '1 2' hour to minute" is? --- should be "1 day 2 hours" as cvs head treats "select interval '1 day 2 hours' hour to minute;"? --- should be 2 hours? select interval '1 2' hour to minute; --- should be an error as "select interval '1 2' hour to minute" is? --- should be "1 day 2 hours" as cvs head treats "select interval '1 day 2 hours' hour to minute;"? --- should be 2 hours?