Statistics for MySQL  1.1
 All Classes Files Functions Variables Typedefs Macros Pages
rand_mt.cc
Go to the documentation of this file.
1 /* rand_mt.cc (rand_mt) */
2 
3 /***********************************************************************
4 * This code is part of Statistics for MySQL.
5 *
6 * Copyright (C) 2011 Heinrich Schuchardt (xypron.glpk@gmx.de)
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 ***********************************************************************/
20 
32 #include "sqlstat.h"
33 #include "sqlrand.h"
34 
36 
48 my_bool rand_mt_init(UDF_INIT *initid, UDF_ARGS *args, char *message) {
49 
50  if (!sqlstat_plugin_isloaded()) {
51  strcpy(message,"libsqlstat plugin is not loaded. "
52  "Use 'INSTALL PLUGIN' for installation.");
53  return 1;
54  }
55 
56  if (args->arg_count != 0) {
57  strcpy(message,"rand_mt() requires no argument");
58  return 1;
59  }
60 
61  initid->maybe_null = 0;
62  initid->decimals = NOT_FIXED_DEC;
63  initid->max_length = 13 + initid->decimals;
64  initid->ptr = NULL;
65  initid->const_item = 0;
66  return 0;
67 }
68 
81 double rand_mt(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error) {
83 }
84 
92 void rand_mt_deinit(UDF_INIT *initid) {
93  return;
94 }
Definition of functions for UDFs and plugins.
double rand_mt(UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
Retrieve Mersenne Twister random number.
Definition: rand_mt.cc:81
Definitions for random number generations.
my_bool rand_mt_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
Called before first usage of function.
Definition: rand_mt.cc:48
static double nextDouble()
Returns random double number.
Definition: sqlrand.cc:104
void rand_mt_deinit(UDF_INIT *initid)
Called after last access to function.
Definition: rand_mt.cc:92
#define NOT_FIXED_DEC
Maximum number of digits in double As defined in mysql/sql_string.h.
Definition: sqlstat.h:77
Mersenne Twister random number generator.
Definition: sqlrand.h:60
int sqlstat_plugin_isloaded()
Check if plugin loaded.
Definition: sqlplugin.cc:70