Index: doc/src/sgml/func.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/func.sgml,v
retrieving revision 1.423
diff -c -r1.423 func.sgml
*** doc/src/sgml/func.sgml 6 Mar 2008 18:49:32 -0000 1.423
--- doc/src/sgml/func.sgml 10 Mar 2008 06:11:55 -0000
***************
*** 828,834 ****
setseed(dp)
void
! set seed for subsequent random() calls (value between 0 and 1.0)
setseed(0.54823)
--- 828,834 ----
setseed(dp)
void
! set seed for subsequent random() calls (value between -1.0 and 1.0)
setseed(0.54823)
Index: src/backend/utils/adt/float.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/float.c,v
retrieving revision 1.153
diff -c -r1.153 float.c
*** src/backend/utils/adt/float.c 1 Jan 2008 19:45:52 -0000 1.153
--- src/backend/utils/adt/float.c 10 Mar 2008 06:11:55 -0000
***************
*** 1684,1691 ****
setseed(PG_FUNCTION_ARGS)
{
float8 seed = PG_GETARG_FLOAT8(0);
! int iseed = (int) (seed * MAX_RANDOM_VALUE);
srandom((unsigned int) iseed);
PG_RETURN_VOID();
--- 1684,1695 ----
setseed(PG_FUNCTION_ARGS)
{
float8 seed = PG_GETARG_FLOAT8(0);
! int iseed;
+ if (seed < -1 || seed > 1)
+ elog(ERROR, "setseed parameter %f out of range [-1,1]", seed);
+
+ iseed = (int) (seed * MAX_RANDOM_VALUE);
srandom((unsigned int) iseed);
PG_RETURN_VOID();
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.435
diff -c -r1.435 guc.c
*** src/backend/utils/misc/guc.c 10 Mar 2008 03:22:29 -0000 1.435
--- src/backend/utils/misc/guc.c 10 Mar 2008 06:11:55 -0000
***************
*** 1849,1855 ****
GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
},
&phony_random_seed,
! 0.5, 0.0, 1.0, assign_random_seed, show_random_seed
},
{
--- 1849,1855 ----
GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
},
&phony_random_seed,
! 0.5, -1.0, 1.0, assign_random_seed, show_random_seed
},
{