Re: BUG #14446: make_date with negative year

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: abelisto(at)gmail(dot)com, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14446: make_date with negative year
Date: 2016-12-04 18:19:39
Message-ID: CAFj8pRBCZBKWME6iYnswg0OjCCeOkMXU8yreFS5wYQkmD3D+Pg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

2016-12-04 14:40 GMT+01:00 Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>:

> abelisto(at)gmail(dot)com wrote:
>
> > Bug reference: 14446
> > Logged by: Andy Abelisto
> > Email address: abelisto(at)gmail(dot)com
> > PostgreSQL version: 9.5.5
> > Operating system: Linux Mint
> > Description:
> >
> > with t(x) as (values('1111-11-11 BC'::date)) select
> make_date(extract(year
> > from x)::int, extract(month from x)::int, extract(day from x)::int) from
> > t;
> > ERROR: date field value out of range: -1111-11-11
>
> make_date() has:
>
> /*
> * Note: we'll reject zero or negative year values. Perhaps
> negatives
> * should be allowed to represent BC years?
> */
> dterr = ValidateDate(DTK_DATE_M, false, false, false, &tm);
>
> With the attached patch it becomes (needs docs, tests):
>
> with t(x) as (values('1111-11-11 BC'::date),
> ('00001-11-11 bc'),
> ('00001-11-11'),
> ('1111-11-11')
> )
> select make_date(extract(year
> from x)::int, extract(month from x)::int, extract(day from x)::int) from
> t;
> make_date
> ───────────────
> 1111-11-11 BC
> 0001-11-11 BC
> 0001-11-11
> 1111-11-11
> (4 filas)
>
>
+1

Regards

Pavel

> --
> Álvaro Herrera https://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message hmahmood89 2016-12-05 14:30:37 BUG #14448: create table as values - type check skipped
Previous Message Alvaro Herrera 2016-12-04 13:40:50 Re: BUG #14446: make_date with negative year