Re: [PATCH] Generate random dates/times in a specified range - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [PATCH] Generate random dates/times in a specified range
Date
Msg-id 1409971.1752099282@sss.pgh.pa.us
Whole thread Raw
In response to [PATCH] Generate random dates/times in a specified range  (Damien Clochard <damien@dalibo.info>)
List pgsql-hackers
Damien Clochard <damien@dalibo.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



pgsql-hackers by date:

Previous
From: Melanie Plageman
Date:
Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)
Next
From: Jeff Davis
Date:
Subject: Re: Remaining dependency on setlocale()