Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 430C1B5DCFD for ; Wed, 13 Jul 2011 19:16:28 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 97168-01 for ; Wed, 13 Jul 2011 22:16:22 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gy0-f174.google.com (mail-gy0-f174.google.com [209.85.160.174]) by mail.postgresql.org (Postfix) with ESMTP id 3602AB5DCE3 for ; Wed, 13 Jul 2011 19:16:22 -0300 (ADT) Received: by gyh3 with SMTP id 3so2615601gyh.19 for ; Wed, 13 Jul 2011 15:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=references:in-reply-to:mime-version:content-transfer-encoding :content-type:message-id:cc:x-mailer:from:subject:date:to; bh=adm5DeNFHtLOCkSV8jWRkXBVdqJ3RyonRsoaPEPm8Pc=; b=OVCMEsuGhO9JDSdTaHOVhCeDMP9tNMW/xgB1H+wIx6Thndb3QQuxz6MJRxQyNidK4e FVG8yP8iimz6S7ZS0qL2Co9Qe6YjAIwTO+lPiIqfoNJESI010tC1nF/RCTeLZ/nqK8Po 7+9ZumFlqpcCN9kq+NeZqdl0f/wa6/+GWQQbk= Received: by 10.150.159.20 with SMTP id h20mr1856408ybe.418.1310595382203; Wed, 13 Jul 2011 15:16:22 -0700 (PDT) Received: from [10.13.216.130] (mobile-198-228-227-187.mycingular.net [198.228.227.187]) by mx.google.com with ESMTPS id c69sm253304yhm.1.2011.07.13.15.16.18 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 13 Jul 2011 15:16:20 -0700 (PDT) References: <201107131843.p6DIh8923252@momjian.us> <1310590466-sup-3055@alvh.no-ip.org> In-Reply-To: Mime-Version: 1.0 (iPhone Mail 8A293) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Message-Id: <73A5666E-2D40-457E-9DFF-248895DB7FAF@gmail.com> Cc: Alvaro Herrera , Bruce Momjian , Daniele Varrazzo , PostgreSQL-development X-Mailer: iPhone Mail (8A293) From: Robert Haas Subject: Re: [BUGS] extract(epoch from infinity) is not 0 Date: Wed, 13 Jul 2011 17:16:56 -0500 To: Brendan Jurd X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, MIME_QP_LONG_LINE=0.001 X-Spam-Level: X-Archive-Number: 201107/699 X-Sequence-Number: 191798 On Jul 13, 2011, at 4:21 PM, Brendan Jurd wrote: > On 14 July 2011 06:58, Alvaro Herrera wrote: >> I don't find the proposed behavior all that suprising, which the >> original behavior surely is. I guess the bigger question is whether the >> values that timestamptz_part() returns for other cases (than epoch) >> should also be different from 0 when an 'infinity' timestamp is passed. >> (In other words, why should 0 be the assumed return value here?) >>=20 >=20 > Well, for example, how do you go about answering the question "what is > the day-of-month of the infinite timestamp?" The question is > nonsense; it doesn't have a defined day of month, so I think we should > be returning NULL or throwing an error. Returning zero is definitely > wrong. I think throwing an error is the better way to go, as the user > probably didn't intend to ask an incoherent question. >=20 > It makes sense to special-case 'epoch' because it effectively converts > the operation into interval math; if we ask "how many seconds from > 1970-01-01 00:00 UTC until the infinite timestamp?" the answer is > genuinely "infinite seconds". So +1 for the proposed change for > epoch, and let's throw an error for the other date fields instead of > returning zero. I'd rather we avoid throwing an error, because that sometimes forces people w= ho want to handle that case to use a subtransaction to catch it, which is qu= ite slow. If we don't like 0, perhaps NULL or NaN would be better. ...Robert=