Statistics for MySQL  1.1
 All Classes Files Functions Variables Typedefs Macros Pages
Functions
rand_mt.cc File Reference

Generate uniformly distributed random number from interval [0,1[. More...

#include "sqlstat.h"
#include "sqlrand.h"
Include dependency graph for rand_mt.cc:

Go to the source code of this file.

Functions

my_bool rand_mt_init (UDF_INIT *initid, UDF_ARGS *args, char *message)
 Called before first usage of function. More...
 
double rand_mt (UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
 Retrieve Mersenne Twister random number. More...
 
void rand_mt_deinit (UDF_INIT *initid)
 Called after last access to function. More...
 

Detailed Description

Generate uniformly distributed random number from interval [0,1[.

CREATE FUNCTION rand_mt RETURNS REAL SONAME 'libsqlstat.so';
SELECT rand_mt() FROM mytab;
DROP FUNCTION rand_mt;

Definition in file rand_mt.cc.

Function Documentation

double rand_mt ( UDF_INIT *  initid,
UDF_ARGS *  args,
char *  is_null,
char *  error 
)

Retrieve Mersenne Twister random number.

A double random number in the range [0,1[ is generated. It has 53 random bits.

Parameters
initidfunction description
argsargument values
is_nullresult is NULL
errorerror message
Returns
random number

Definition at line 81 of file rand_mt.cc.

Here is the call graph for this function:

rand_mt_deinit ( UDF_INIT *  initid)

Called after last access to function.

Deallocate memory for counter and sums.

Parameters
initid

Definition at line 92 of file rand_mt.cc.

my_bool rand_mt_init ( UDF_INIT *  initid,
UDF_ARGS *  args,
char *  message 
)

Called before first usage of function.

Checksparameters.
Indicate type of return value.

Parameters
initidfunction description
argsparameters
messageerror message
Returns
success = 0

Definition at line 48 of file rand_mt.cc.

Here is the call graph for this function: