]> granicus.if.org Git - postgresql/commitdiff
With Joe Conway's concurrence, remove srandom() call from normal_rand().
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 13 Sep 2003 21:44:50 +0000 (21:44 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 13 Sep 2003 21:44:50 +0000 (21:44 +0000)
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.

contrib/tablefunc/README.tablefunc
contrib/tablefunc/expected/tablefunc.out
contrib/tablefunc/sql/tablefunc.sql
contrib/tablefunc/tablefunc.c
contrib/tablefunc/tablefunc.sql.in

index b80899e957ec0cef83ff727843712e6925ca55d6..ddae93131940c4545b4abc6f3db410218e287d3c 100644 (file)
@@ -48,7 +48,7 @@ Installation:
 
   installs following functions into database template1:
 
-    normal_rand(int numvals, float8 mean, float8 stddev, int seed)
+    normal_rand(int numvals, float8 mean, float8 stddev)
       - returns a set of normally distributed float8 values
 
     crosstabN(text sql)
@@ -74,12 +74,12 @@ Documentation
 ==================================================================
 Name
 
-normal_rand(int, float8, float8, int) - returns a set of normally
+normal_rand(int, float8, float8) - returns a set of normally
        distributed float8 values
 
 Synopsis
 
-normal_rand(int numvals, float8 mean, float8 stddev, int seed)
+normal_rand(int numvals, float8 mean, float8 stddev)
 
 Inputs
 
@@ -92,9 +92,6 @@ Inputs
   stddev
     the standard deviation of the normal distribution of values
 
-  seed
-    a seed value for the pseudo-random number generator
-
 Outputs
 
   Returns setof float8, where the returned set of random values are normally
@@ -103,7 +100,7 @@ Outputs
 Example usage
 
   test=# SELECT * FROM
-  test=# normal_rand(1000, 5, 3, EXTRACT(SECONDS FROM CURRENT_TIME(0))::int);
+  test=# normal_rand(1000, 5, 3);
      normal_rand
 ----------------------
      1.56556322244898
index fa69cf3b4a6895ca0af5bbc0ff6530aa636dfc05..2e412e5cfa24f6bb3b005328332c02e5c1d802e4 100644 (file)
@@ -7,7 +7,7 @@
 -- normal_rand()
 -- no easy way to do this for regression testing
 --
-SELECT avg(normal_rand)::int FROM normal_rand(100, 250, 0.2, EXTRACT(SECONDS FROM CURRENT_TIME(0))::int);
+SELECT avg(normal_rand)::int FROM normal_rand(100, 250, 0.2);
  avg 
 -----
  250
index fe0e4d44bc8d46bec082e91d74f5ef4910c0b117..5292fc2bc785e591fac4cd5175cbe7eebebfeada 100644 (file)
@@ -10,7 +10,7 @@
 -- normal_rand()
 -- no easy way to do this for regression testing
 --
-SELECT avg(normal_rand)::int FROM normal_rand(100, 250, 0.2, EXTRACT(SECONDS FROM CURRENT_TIME(0))::int);
+SELECT avg(normal_rand)::int FROM normal_rand(100, 250, 0.2);
 
 --
 -- crosstab()
index 312c63a4c0c3b66c7ba8d5c620c914b0fb9c4610..031d7c8bc8a6f1d6deb78518503d8e51c9be7488 100644 (file)
@@ -165,8 +165,8 @@ typedef struct crosstab_hashent
  * normal_rand - return requested number of random values
  * with a Gaussian (Normal) distribution.
  *
- * inputs are int numvals, float8 lower_bound, and float8 upper_bound
- * returns float8
+ * inputs are int numvals, float8 mean, and float8 stddev
+ * returns setof float8
  */
 PG_FUNCTION_INFO_V1(normal_rand);
 Datum
@@ -213,12 +213,6 @@ normal_rand(PG_FUNCTION_ARGS)
 
                funcctx->user_fctx = fctx;
 
-               /*
-                * we might actually get passed a negative number, but for this
-                * purpose it doesn't matter, just cast it as an unsigned value
-                */
-               srandom(PG_GETARG_UINT32(3));
-
                MemoryContextSwitchTo(oldcontext);
        }
 
index 2714db199c8df67bf26a70864573715f478a1b1e..f3d5d3d8a1a6b371271250175a7ed878bdac0a10 100644 (file)
@@ -1,7 +1,7 @@
 -- Adjust this setting to control where the objects get created.
 SET search_path = public;
 
-CREATE OR REPLACE FUNCTION normal_rand(int4, float8, float8, int4)
+CREATE OR REPLACE FUNCTION normal_rand(int4, float8, float8)
 RETURNS setof float8
 AS 'MODULE_PATHNAME','normal_rand'
 LANGUAGE 'C' VOLATILE STRICT;