*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.12 1998/02/24 03:47:26 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.13 1998/06/09 19:20:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include
#include
+#include
#include "postgres.h"
#include "utils/datum.h"
#include "catalog/pg_type.h"
* will return about 1/10 of the tuples in TEMP
*
*/
+
+static bool random_initialized = false;
+
bool
oidrand(Oid o, int32 X)
{
if (X == 0)
return true;
+ /*
+ * We do this because the cancel key is actually a random, so we don't
+ * want them to be able to request random numbers using our postmaster
+ * seeded value.
+ */
+ if (!random_initialized)
+ {
+ srandom((unsigned int)time(NULL));
+ random_initialized = true;
+ }
+
result = (random() % X == 0);
return result;
}
oidsrand(int32 X)
{
srand(X);
+ random_initialized = true;
return true;
}