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 1lRMx1-0005oU-O2 for pgsql-bugs@arkaria.postgresql.org; Tue, 30 Mar 2021 22:35:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lRMx0-0004tZ-Lj for pgsql-bugs@arkaria.postgresql.org; Tue, 30 Mar 2021 22:35:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lRMx0-0004tS-Fu for pgsql-bugs@lists.postgresql.org; Tue, 30 Mar 2021 22:35:06 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lRMwy-0000Ci-EF for pgsql-bugs@lists.postgresql.org; Tue, 30 Mar 2021 22:35:05 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1lRMwx-0004VV-Jl; Tue, 30 Mar 2021 18:35:03 -0400 Date: Tue, 30 Mar 2021 18:35:03 -0400 From: Bruce Momjian To: neverov.max@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16939: Plural interval for negative singular Message-ID: <20210330223503.GA30391@momjian.us> References: <16939-cceeb03fb72736ee@postgresql.org> <20210323160336.GE579@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210323160336.GE579@momjian.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Mar 23, 2021 at 12:03:36PM -0400, Bruce Momjian wrote: > On Tue, Mar 23, 2021 at 05:21:30AM +0000, PG Bug reporting form wrote: > > The following bug has been logged on the website: > > > > Bug reference: 16939 > > Logged by: Max Neverov > > Email address: neverov.max@gmail.com > > PostgreSQL version: 13.2 > > Operating system: alpine > > Description: > > > > Execute the query: > > postgres=# set intervalstyle='postgres'; > > SET > > postgres=# select interval '-1 year -1 day'; > > interval > > ------------------ > > -1 years -1 days > > (1 row) > > > > Expected output: > > -1 year -1 day > > > > The code > > (https://github.com/postgres/postgres/blob/master/src/backend/utils/adt/datetime.c#L4193) > > pluralizes a time unit if the value is not 1, should check both -1 and 1. > > > > Wow, interesting. Seems there were a few places in the code that > handled this properly, and several that didn't. The attached patch > fixes these and updates the regression tests. I will apply this for PG > 14 in the next few days. This is too likely to break something to > backpatch. Thanks for the report. Patch applied and will appear in PG 14. Thanks for the report. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion.