Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lTTl5-0005BP-MG for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Apr 2021 18:15:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lTTl4-0006vn-KH for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Apr 2021 18:15:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lTTl4-0006vg-9b for pgsql-hackers@lists.postgresql.org; Mon, 05 Apr 2021 18:15:30 +0000 Received: from mail-il1-x12f.google.com ([2607:f8b0:4864:20::12f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lTTl0-0005LH-Uq for pgsql-hackers@postgresql.org; Mon, 05 Apr 2021 18:15:29 +0000 Received: by mail-il1-x12f.google.com with SMTP id w2so7919055ilj.12 for ; Mon, 05 Apr 2021 11:15:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=llsJ9iOEZ67wxmpfihLE9gG2FGUkcAIQH9tLoInC58A=; b=1BeDdNPzFl6n8wnwEfOZGJXek1ujHm1t2TjLXVJFqG6UdRE9+fanlo9nwTTzZgtypV zVAVfk5C0JaAkMPjpi3K5k2NheChq6FRe9AgftiC/Vr6MEo2yme3KODfnJpPV8hGBcWb M/bDNYJUDWVioIqFJROjPvsKDN47e+5vfozvHL7CT5lHj9bDTK8OPKz20/z2dz+Ykyz1 kqtaIcGYuhZ4hMkwiQAbLtzy9+Zbvl/Wv9L7vNCLAgTCSPApXa6XVKOvpl9w3//mpJxY j6Fv+Cb5BtW3OnSjolz6Lp4i8zV3w7ArESIJzjy7+Rki5CcV0MG8dhoYNJIa2i9fq8iR uMnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=llsJ9iOEZ67wxmpfihLE9gG2FGUkcAIQH9tLoInC58A=; b=iJZLdsFAyevCJno5C0dV7dHKnj/ATuvMR8vu4yPjFfpzyoIQZeMROvoON/gh/v33XC w/GNrRLqdgbUtLWIbT8oI/mYnQ/2xNV9/ZfbAFgIPtBigfFQ/ymrWvda3rt7iuB5VH9w gQ4lYQn0mEfvGb6+bJTIJvedrehWLrn7iH8eP1YZ3hjlBTSIkrHxRw9M0Obje6/HZtav CzMuL2xwwnFGG5L5SG/UtglbRDaUi8esufBOsPNnKz/k/rm1CMHyhc7G0KBwiCOL/JoU zZhk2wIq0CWkiri+qImY+owaq0jfhcsL+3XIvLWrilF6hSLgI6AvBZ2sQx80OQKu3UZy jLnQ== X-Gm-Message-State: AOAM532gdlA3bGnhJ+0BYXku1fyJFc28OhxHZ7q8qcRX52ler2r+X7P1 tn69lM3T4QwfBdG7WOa3VWYRWw== X-Google-Smtp-Source: ABdhPJyWrtETcJ7frPE9ZDbOiTkxCF0TSQ3H4//2vi512bYioJLu+o7ei3XuYJ343Jb/e+ATqNipMg== X-Received: by 2002:a92:c5a3:: with SMTP id r3mr21297844ilt.155.1617646524425; Mon, 05 Apr 2021 11:15:24 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id z5sm10135069iod.37.2021.04.05.11.15.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Apr 2021 11:15:24 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id EF622800897; Mon, 5 Apr 2021 13:15:22 -0500 (CDT) Date: Mon, 5 Apr 2021 13:15:22 -0500 From: Justin Pryzby To: Bruce Momjian Cc: Bryn Llewellyn , Zhihong Yu , Isaac Morland , John W Higgins , pgsql-hackers@postgresql.org, Tom Lane Subject: Re: Have I found an interval arithmetic bug? Message-ID: <20210405181522.GS6592@telsasoft.com> References: <20210403022126.GG29126@momjian.us> <20210405163310.GP6592@telsasoft.com> <20210405180158.GB12179@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210405180158.GB12179@momjian.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Apr 05, 2021 at 02:01:58PM -0400, Bruce Momjian wrote: > On Mon, Apr 5, 2021 at 11:33:10AM -0500, Justin Pryzby wrote: > > > https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-INTERVAL-INPUT > > > « …field values can have fractional parts; for example '1.5 week' or '01:02:03.45'. Such input is converted to the appropriate number of months, days, and seconds for storage. When this would result in a fractional number of months or days, the fraction is added to the lower-order fields using the conversion factors 1 month = 30 days and 1 day = 24 hours. For example, '1.5 month' becomes 1 month and 15 days. Only seconds will ever be shown as fractional on output. » > > I see that. What is not clear here is how far we flow down. I was > looking at adding documentation or regression tests for that, but was > unsure. I adjusted the docs slightly in the attached patch. I should have adjusted the quote to include context: | In the verbose input format, and in SOME FIELDS of the more compact input formats, field values can have fractional parts[...] I don't know what "some fields" means - more clarity here would help indicate the intended behavior. > The interaction of months/days/seconds is so imprecise that passing it > futher down doesn't make much sense, and suggests a precision that > doesn't exist, but if people prefer that we can do it. I agree on its face that "months" is imprecise (30, 31, 27, 28 days), especially fractional months, and same for "years" (leap years), and hours per day (DST), but even minutes ("leap seconds"). But the documentation seems to be clear about the behavior: | .. using the conversion factors 1 month = 30 days and 1 day = 24 hours I think the most obvious/consistent change is for years and greater to "cascade down" to seconds, and not just months. -- Justin