From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Damien Clochard <damien(at)dalibo(dot)info> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: [PATCH] Generate random dates/times in a specified range |
Date: | 2025-07-09 22:14:42 |
Message-ID: | 1409971.1752099282@sss.pgh.pa.us |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Damien Clochard <damien(at)dalibo(dot)info> writes:
> So this adds 5 new variants of the random() function:
> random(min date, max date) returns date
> random(min time, max time) returns time
> random(min time, max time, zone text) returns timetz
> random(min timestamp, max timestamp) returns timestamp
> random(min timestamptz, max timestamptz) returns timestamptz
I'm a little uncomfortable with this proposal, mainly because it
overloads the random() function name to the point where I'm afraid
of "ambiguous function" failures in SQL code that used to be fine.
The traditional way of achieving these results would be something like
select now() + random() * interval '10 days';
and I'm not convinced that the use-case is so large as to justify
adding built-in forms of that.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Davis | 2025-07-09 22:52:34 | Re: Remaining dependency on setlocale() |
Previous Message | Melanie Plageman | 2025-07-09 21:59:26 | Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access) |