Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions

geqo_random.c File Reference

#include "postgres.h"
#include "optimizer/geqo_random.h"
Include dependency graph for geqo_random.c:

Go to the source code of this file.

Functions

void geqo_set_seed (PlannerInfo *root, double seed)
double geqo_rand (PlannerInfo *root)

Function Documentation

double geqo_rand ( PlannerInfo root  ) 

Definition at line 35 of file geqo_random.c.

References PlannerInfo::join_search_private, and pg_erand48().

Referenced by linear_rand().

{
    GeqoPrivateData *private = (GeqoPrivateData *) root->join_search_private;

    return pg_erand48(private->random_state);
}

void geqo_set_seed ( PlannerInfo root,
double  seed 
)

Definition at line 20 of file geqo_random.c.

References PlannerInfo::join_search_private, and Min.

Referenced by geqo().

{
    GeqoPrivateData *private = (GeqoPrivateData *) root->join_search_private;

    /*
     * XXX. This seeding algorithm could certainly be improved - but it is not
     * critical to do so.
     */
    memset(private->random_state, 0, sizeof(private->random_state));
    memcpy(private->random_state,
           &seed,
           Min(sizeof(private->random_state), sizeof(seed)));
}