Re: date_trunc invalid units with infinite value
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Joseph Koshakow <koshy44@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-12-05T05:34:41Z
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
Commits
-
Improve tests of date_trunc() with infinity and unsupported units
- 67ffe1987d0a 18.0 landed
- 572c0f1b0e2a 19 (unreleased) landed
-
Fix incorrect Datum conversion in timestamptz_trunc_internal()
- 074db8604ad1 18.0 landed
- 2242b26ce472 19 (unreleased) landed
-
Improve handling of date_trunc() units for infinite input values
- d85ce012f99f 18.0 landed