Re: BUG #16939: Plural interval for negative singular - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: BUG #16939: Plural interval for negative singular
Date
Msg-id 20210323160336.GE579@momjian.us
Whole thread Raw
In response to BUG #16939: Plural interval for negative singular  (PG Bug reporting form <noreply@postgresql.org>)
Responses Re: BUG #16939: Plural interval for negative singular  (Bruce Momjian <bruce@momjian.us>)
Re: BUG #16939: Plural interval for negative singular  (Noah Misch <noah@leadboat.com>)
List pgsql-bugs
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.

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  If only the physical world exists, free will is an illusion.


Attachment

pgsql-bugs by date:

Previous
From: Guillaume Lelarge
Date:
Subject: Re: BUG #16940: ERROR: unrecognized parameter
Next
From: PG Bug reporting form
Date:
Subject: BUG #16941: ECPG add support for const void*