Re: replace oidrand() with random_sample() - Mailing list pgsql-patches

From Tom Lane
Subject Re: replace oidrand() with random_sample()
Date
Msg-id 10373.1042680110@sss.pgh.pa.us
Whole thread Raw
In response to replace oidrand() with random_sample()  (Neil Conway <neilc@samurai.com>)
Responses Re: replace oidrand() with random_sample()  (Neil Conway <neilc@samurai.com>)
List pgsql-patches
Neil Conway <neilc@samurai.com> writes:
> The "random" regression test uses a function called oidrand(), which
> takes two parameters, an OID x and an integer y, and returns "true" with
> probability 1/y (the OID argument is ignored). This can be useful -- for
> example, it can be used to select a random sampling of the rows in a
> table (which is what the "random" regression test uses it for).

Do we actually need a separate function at all?  Seems like
    random() < 1.0/y
would accomplish the same result.

I agree that oidrand() is crufty and no longer useful, but I had
hesitated to rip it out, for fear that somebody somewhere might still
be using it.  It's not like it's costing us any maintenance effort
to leave it there.

            regards, tom lane

pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: replace oidrand() with random_sample()
Next
From: "Christopher Kings-Lynne"
Date:
Subject: Re: fix broken regression tests