Re: BUG #14446: make_date with negative year

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: BUG #14446: make_date with negative year
Дата
Msg-id 20161204134050.vsfjbwub6u6jljax@alvherre.pgsql
обсуждение исходный текст
Ответ на BUG #14446: make_date with negative year  (abelisto@gmail.com)
Ответы Re: BUG #14446: make_date with negative year  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-bugs
abelisto@gmail.com wrote:

> Bug reference:      14446
> Logged by:          Andy Abelisto
> Email address:      abelisto@gmail.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)

--
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Вложения

В списке pgsql-bugs по дате отправления:

Предыдущее
От: abelisto@gmail.com
Дата:
Сообщение: BUG #14446: make_date with negative year
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: BUG #14446: make_date with negative year