Re: replace oidrand() with random_sample()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: replace oidrand() with random_sample()
Date: 2003-01-16 01:21:50
Message-ID: 10373.1042680110@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Neil Conway <neilc(at)samurai(dot)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

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Conway 2003-01-16 02:08:39 Re: replace oidrand() with random_sample()
Previous Message Christopher Kings-Lynne 2003-01-16 01:14:07 Re: fix broken regression tests