PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
geqo_random.c
Go to the documentation of this file.
1 /*------------------------------------------------------------------------
2  *
3  * geqo_random.c
4  * random number generator
5  *
6  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/backend/optimizer/geqo/geqo_random.c
10  *
11  *-------------------------------------------------------------------------
12  */
13 
14 #include "postgres.h"
15 
16 #include "optimizer/geqo_random.h"
17 
18 
19 void
20 geqo_set_seed(PlannerInfo *root, double seed)
21 {
23 
24  /*
25  * XXX. This seeding algorithm could certainly be improved - but it is not
26  * critical to do so.
27  */
28  memset(private->random_state, 0, sizeof(private->random_state));
29  memcpy(private->random_state,
30  &seed,
31  Min(sizeof(private->random_state), sizeof(seed)));
32 }
33 
34 double
36 {
38 
39  return pg_erand48(private->random_state);
40 }
double geqo_rand(PlannerInfo *root)
Definition: geqo_random.c:35
void * join_search_private
Definition: relation.h:316
#define Min(x, y)
Definition: c.h:807
double pg_erand48(unsigned short xseed[3])
Definition: erand48.c:79
void geqo_set_seed(PlannerInfo *root, double seed)
Definition: geqo_random.c:20