PostgreSQL Source Code  git master
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-2022, 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  pg_prng_fseed(&private->random_state, seed);
25 }
26 
27 double
29 {
31 
32  return pg_prng_double(&private->random_state);
33 }
34 
35 int
37 {
39 
40  /*
41  * In current usage, "lower" is never negative so we can just use
42  * pg_prng_uint64_range directly.
43  */
44  return (int) pg_prng_uint64_range(&private->random_state, lower, upper);
45 }
void geqo_set_seed(PlannerInfo *root, double seed)
Definition: geqo_random.c:20
int geqo_randint(PlannerInfo *root, int upper, int lower)
Definition: geqo_random.c:36
double geqo_rand(PlannerInfo *root)
Definition: geqo_random.c:28
Datum lower(PG_FUNCTION_ARGS)
Definition: oracle_compat.c:46
Datum upper(PG_FUNCTION_ARGS)
Definition: oracle_compat.c:77
double pg_prng_double(pg_prng_state *state)
Definition: pg_prng.c:226
uint64 pg_prng_uint64_range(pg_prng_state *state, uint64 rmin, uint64 rmax)
Definition: pg_prng.c:138
void pg_prng_fseed(pg_prng_state *state, double fseed)
Definition: pg_prng.c:96
void * join_search_private
Definition: pathnodes.h:377