From: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
---|---|
To: | Damien Clochard <damien(at)dalibo(dot)info> |
Cc: | Greg Sabino Mullane <htamfids(at)gmail(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: [PATCH] Generate random dates/times in a specified range |
Date: | 2025-09-08 12:40:57 |
Message-ID: | CAEZATCX_VQX9asjrwTXg0wTd6126Reo3yFxKno0QGJfviTwL4Q@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, 26 Aug 2025 at 15:17, Damien Clochard <damien(at)dalibo(dot)info> wrote:
>
> Le 25.08.2025 15:33, Greg Sabino Mullane a écrit :
> > Your v3 did not get attached to the previous email.
>
> My bad, here it is
It seems like we have reached a consensus on adding just the random
date and timestamp[tz] functions, so I took a more detailed look with
an aim to committing this.
I'm attaching v4 with a few minor updates:
1). Updated the paragraph of text below "Table 9.6. Random Functions"
to also refer to "Table 9.33. Date/Time Functions", so that it's clear
that all the comments that follow apply to the date/time random()
functions too -- in particular, the part about setseed(). Having
reflected on it, I think that's a slightly better option than putting
the new functions in Table 9.6, because that's part of a whole section
about mathematical functions and everything there refers to number
types, not dates/timestamps, so putting the new functions there feels
a little out-of-place.
2). Changed check_range_boundaries() to a macro CHECK_RANGE_BOUNDS().
This feels a little neater, since it's such a trivial check, and the
datatype is not always int64.
3). Changed the C function names, adding an underscore for better
readability and consistency with other date/timestamp functions.
4). Used the DATE/TIMESTAMP_IS_NOBEGIN/NOEND() macros for neatness.
5). I didn't like this error message:
ERROR: lower and upper bound cannot be infinite
because it's not grammatically correct, so I changed it to this:
ERROR: lower and upper bounds must be finite
which is an error already used elsewhere for similar checks. This is
not quite the same as the errors thrown by random_numeric() -- perhaps
that should be changed to match (making its errors the same as the
errors thrown by width_bucket_numeric()).
6). It's not necessary to include utils/builtins.h or utils/datetime.h.
I think this is now committable, so if there are no objections, I'll
push this shortly.
Regards,
Dean
Attachment | Content-Type | Size |
---|---|---|
v4-0001-Add-date-and-timestamp-variants-of-random-min-max.patch | text/x-patch | 14.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Aleksander Alekseev | 2025-09-08 12:50:07 | Re: [BUG] PostgreSQL crashes with ThreadSanitizer during early initialization |
Previous Message | Shayon Mukherjee | 2025-09-08 12:15:05 | Re: [PATCH] Proposal to Enable/Disable Index using ALTER INDEX |