Skip to content

Commit c472b83

Browse files
committed
With Joe Conway's concurrence, remove srandom() call from normal_rand().
This was the last piece of code that took it upon itself to reset the random number sequence --- now we only have srandom() in postmaster start, backend start, and explicit setseed() operations.
1 parent 94a13b8 commit c472b83

File tree

5 files changed

+9
-18
lines changed

5 files changed

+9
-18
lines changed

contrib/tablefunc/README.tablefunc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Installation:
4848

4949
installs following functions into database template1:
5050

51-
normal_rand(int numvals, float8 mean, float8 stddev, int seed)
51+
normal_rand(int numvals, float8 mean, float8 stddev)
5252
- returns a set of normally distributed float8 values
5353

5454
crosstabN(text sql)
@@ -74,12 +74,12 @@ Documentation
7474
==================================================================
7575
Name
7676

77-
normal_rand(int, float8, float8, int) - returns a set of normally
77+
normal_rand(int, float8, float8) - returns a set of normally
7878
distributed float8 values
7979

8080
Synopsis
8181

82-
normal_rand(int numvals, float8 mean, float8 stddev, int seed)
82+
normal_rand(int numvals, float8 mean, float8 stddev)
8383

8484
Inputs
8585

@@ -92,9 +92,6 @@ Inputs
9292
stddev
9393
the standard deviation of the normal distribution of values
9494

95-
seed
96-
a seed value for the pseudo-random number generator
97-
9895
Outputs
9996

10097
Returns setof float8, where the returned set of random values are normally
@@ -103,7 +100,7 @@ Outputs
103100
Example usage
104101

105102
test=# SELECT * FROM
106-
test=# normal_rand(1000, 5, 3, EXTRACT(SECONDS FROM CURRENT_TIME(0))::int);
103+
test=# normal_rand(1000, 5, 3);
107104
normal_rand
108105
----------------------
109106
1.56556322244898

contrib/tablefunc/expected/tablefunc.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
-- normal_rand()
88
-- no easy way to do this for regression testing
99
--
10-
SELECT avg(normal_rand)::int FROM normal_rand(100, 250, 0.2, EXTRACT(SECONDS FROM CURRENT_TIME(0))::int);
10+
SELECT avg(normal_rand)::int FROM normal_rand(100, 250, 0.2);
1111
avg
1212
-----
1313
250

contrib/tablefunc/sql/tablefunc.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
-- normal_rand()
1111
-- no easy way to do this for regression testing
1212
--
13-
SELECT avg(normal_rand)::int FROM normal_rand(100, 250, 0.2, EXTRACT(SECONDS FROM CURRENT_TIME(0))::int);
13+
SELECT avg(normal_rand)::int FROM normal_rand(100, 250, 0.2);
1414

1515
--
1616
-- crosstab()

contrib/tablefunc/tablefunc.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ typedef struct crosstab_hashent
165165
* normal_rand - return requested number of random values
166166
* with a Gaussian (Normal) distribution.
167167
*
168-
* inputs are int numvals, float8 lower_bound, and float8 upper_bound
169-
* returns float8
168+
* inputs are int numvals, float8 mean, and float8 stddev
169+
* returns setof float8
170170
*/
171171
PG_FUNCTION_INFO_V1(normal_rand);
172172
Datum
@@ -213,12 +213,6 @@ normal_rand(PG_FUNCTION_ARGS)
213213

214214
funcctx->user_fctx = fctx;
215215

216-
/*
217-
* we might actually get passed a negative number, but for this
218-
* purpose it doesn't matter, just cast it as an unsigned value
219-
*/
220-
srandom(PG_GETARG_UINT32(3));
221-
222216
MemoryContextSwitchTo(oldcontext);
223217
}
224218

contrib/tablefunc/tablefunc.sql.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Adjust this setting to control where the objects get created.
22
SET search_path = public;
33

4-
CREATE OR REPLACE FUNCTION normal_rand(int4, float8, float8, int4)
4+
CREATE OR REPLACE FUNCTION normal_rand(int4, float8, float8)
55
RETURNS setof float8
66
AS 'MODULE_PATHNAME','normal_rand'
77
LANGUAGE 'C' VOLATILE STRICT;

0 commit comments

Comments
 (0)