diff options
| author | Bruce Momjian | 2003-02-13 05:24:04 +0000 |
|---|---|---|
| committer | Bruce Momjian | 2003-02-13 05:24:04 +0000 |
| commit | 6cb1f4fe44a92aa97fbfd0c26ebbb8842349d90d (patch) | |
| tree | 228d6d973ec607fe0c171319b84b9d8cfd10fd58 /src/test | |
| parent | 8195f8f0427e0387f595ca951e4dcc257655e891 (diff) | |
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).
This patch removes that function, because it was old and messy. The old
function had the following problems:
- it was undocumented
- it was poorly named
- it was designed to workaround an optimizer bug that no longer exists
(the OID argument is to ensure that the optimizer won't optimize away
calls to the function; AFAIK marking the function as 'volatile' suffices
nowadays)
- it used a different random-number generation technique than the other
PSRNG-related functions in the backend do (it called random() like they
do, but it had its own logic for setting a set and deciding when to
reseed the RNG).
Ok, this patch removes oidrand(), oidsrand(), and userfntest(), and
improves the SGML docs a little bit (un-commenting the setseed()
documentation).
Neil Conway
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/random.out | 4 | ||||
| -rw-r--r-- | src/test/regress/sql/random.sql | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/test/regress/expected/random.out b/src/test/regress/expected/random.out index 0f4dce0bbe1..583be02be09 100644 --- a/src/test/regress/expected/random.out +++ b/src/test/regress/expected/random.out @@ -15,11 +15,11 @@ SELECT count(*) FROM onek; -- have a regression test which can pass/fail -- - thomas 1998-08-17 SELECT count(*) AS random INTO RANDOM_TBL - FROM onek WHERE oidrand(onek.oid, 10); + FROM onek WHERE random() < 1.0/10; -- select again, the count should be different INSERT INTO RANDOM_TBL (random) SELECT count(*) - FROM onek WHERE oidrand(onek.oid, 10); + FROM onek WHERE random() < 1.0/10; -- now test the results for randomness in the correct range SELECT random, count(random) FROM RANDOM_TBL GROUP BY random HAVING count(random) > 1; diff --git a/src/test/regress/sql/random.sql b/src/test/regress/sql/random.sql index 1279a8b0f48..e2333b985f8 100644 --- a/src/test/regress/sql/random.sql +++ b/src/test/regress/sql/random.sql @@ -12,12 +12,12 @@ SELECT count(*) FROM onek; -- have a regression test which can pass/fail -- - thomas 1998-08-17 SELECT count(*) AS random INTO RANDOM_TBL - FROM onek WHERE oidrand(onek.oid, 10); + FROM onek WHERE random() < 1.0/10; -- select again, the count should be different INSERT INTO RANDOM_TBL (random) SELECT count(*) - FROM onek WHERE oidrand(onek.oid, 10); + FROM onek WHERE random() < 1.0/10; -- now test the results for randomness in the correct range SELECT random, count(random) FROM RANDOM_TBL |
