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

From Tom Lane
Subject Re: replace oidrand() with random_sample()
Date
Msg-id 26181.1042742609@sss.pgh.pa.us
Whole thread Raw
In response to Re: replace oidrand() with random_sample()  (Neil Conway <neilc@samurai.com>)
List pgsql-patches
Neil Conway <neilc@samurai.com> writes:
> You would have to try *pretty hard* just to know that it existed. And
> even if you decided to use it in an application, it won't take much more
> than grepping for 'oidrand' and replacing it with 'random() < 1.0/y' in
> order to upgrade to 7.4.

Or you could do

CREATE FUNCTION oidrand(oid, int) RETURNS bool AS
'SELECT random() < 1.0/$2' LANGUAGE sql;

            regards, tom lane

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: fix for PL/PgSQL segfault
Next
From: Neil Conway
Date:
Subject: Re: replace oidrand() with random_sample()