Re: Bad canonicalization for dateranges with 'infinity' bounds

Поиск
Список
Период
Сортировка
От Thomas Munro
Тема Re: Bad canonicalization for dateranges with 'infinity' bounds
Дата
Msg-id CA+hUKGJ0gUs-BMRwCgQF-dtURq_7aT1Ecum22u2jH2CcdEQAYw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Bad canonicalization for dateranges with 'infinity' bounds  (Laurenz Albe <laurenz.albe@cybertec.at>)
Ответы Re: Bad canonicalization for dateranges with 'infinity' bounds  (Thomas Munro <thomas.munro@gmail.com>)
Список pgsql-hackers
On Fri, May 3, 2019 at 12:49 AM Laurenz Albe <laurenz.albe@cybertec.at> wrote:
> > I propose the attached patch which fixes the problem.

Hi Laurenz,

I agree that the patch makes the code match the documentation.  The
documented behaviour seems to make more sense than the code, since
unpatched master gives this nonsense result when it flips the
inclusive flag but doesn't adjust the value (because it can't):

postgres=# select '(-infinity,infinity]'::daterange @> 'infinity'::date;
 ?column?
----------
 f
(1 row)

-    if (!upper.infinite && upper.inclusive)
+    if (!(upper.infinite || DATE_NOT_FINITE(upper.val)) && upper.inclusive)

Even though !(X || Y) is equivalent to !X && !Y, by my reading of
range_in(), lower.value can be uninitialised when lower.infinite is
true, and it's also a bit hard to read IMHO, so I'd probably write
that as !upper.infinite && !DATE_NOT_FINITE(upper.val) &&
upper.inclusive.  I don't think it can affect the result but it might
upset Valgrind or similar.

-- 
Thomas Munro
https://enterprisedb.com



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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: initdb recommendations
Следующее
От: Joe Conway
Дата:
Сообщение: Re: [Proposal] Table-level Transparent Data Encryption (TDE) and KeyManagement Service (KMS)