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

Median. More...

#include "sqlstat.h"
#include <set>
Include dependency graph for median.cc:

Go to the source code of this file.

Typedefs

typedef multiset< double, less
< double > > 
DoubleSet
 Multiset of doubles.
 

Functions

my_bool median_init (UDF_INIT *initid, UDF_ARGS *args, char *message)
 Called before first usage of function. More...
 
void median_reset (UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
 Reset function and add first group member Calls clear and add. More...
 
void median_clear (UDF_INIT *initid, char *is_null, char *error)
 Called at start of group. More...
 
void median_add (UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
 Add a member of the group. More...
 
double median (UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error)
 Retrieve median. Called at end of group. More...
 
void median_deinit (UDF_INIT *initid)
 Called after last access to function. More...
 

Detailed Description

Median.

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

Definition in file median.cc.

Function Documentation

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

Retrieve median. Called at end of group.

Parameters
initidfunction description
argsargument values
is_nullresult is NULL
errorerror occured
Returns
median

Definition at line 145 of file median.cc.

void median_add ( UDF_INIT *  initid,
UDF_ARGS *  args,
char *  is_null,
char *  error 
)

Add a member of the group.

The counter and sums are updated

Parameters
initidfunction description
argsargument values
is_null
errorerror occured

Definition at line 119 of file median.cc.

Here is the caller graph for this function:

void median_clear ( UDF_INIT *  initid,
char *  is_null,
char *  error 
)

Called at start of group.

The counter and sums are cleared.

Parameters
initidfunction description
is_null
errorerror message

Definition at line 102 of file median.cc.

Here is the caller graph for this function:

median_deinit ( UDF_INIT *  initid)

Called after last access to function.

Deallocate memory for counter and sums.

Parameters
initid

Definition at line 183 of file median.cc.

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

Called before first usage of function.

Check parameters.
Indicate type of return value.
Allocate memory for counter and sums.

Parameters
initidfunction description
argsparameters
messageerror message
Returns
success = 0

Definition at line 53 of file median.cc.

void median_reset ( UDF_INIT *  initid,
UDF_ARGS *  args,
char *  is_null,
char *  error 
)

Reset function and add first group member Calls clear and add.

Parameters
initidfunction description
argsargument values
is_null
errorerror message
Deprecated:
Reset is only called by MySQL 4.0 and below. It is implemented for backwards compatibility.

Definition at line 88 of file median.cc.

Here is the call graph for this function: