Re: date_trunc invalid units with infinite value

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Joseph Koshakow <koshy44(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: date_trunc invalid units with infinite value
Date: 2024-12-05 05:34:41
Message-ID: Z1E7cTyVbFZJwUWf@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Dec 01, 2024 at 03:09:17PM -0500, Joseph Koshakow wrote:
> When looking at the date_trunc function, I noticed that it wasn't
> rejecting invalid units if the value was infinite. It's slightly
> annoying to fix this, but we already do something very similar for
> date_part. I have attached a patch that would fix this issue, let me
> know if you think it's worth pursuing.

I agree that it is inconsistent that we allow infinite values to go
through this function call even for fields that are not listed as
supported by the documentation. So, yes, I think that what you are
doing the right thing by applying the check based on the units
supported, but I also doubt that it is something that we could
backpatch as it would cause queries to work now to suddenly break.

Thoughts and comments from others are welcome.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2024-12-05 05:43:43 Re: shared-memory based stats collector - v70
Previous Message jian he 2024-12-05 05:32:20 Re: NOT ENFORCED constraint feature