summaryrefslogtreecommitdiff
path: root/storage/example
diff options
context:
space:
mode:
authorAshish Agarwal <ashish.y.agarwal@oracle.com>2013-05-19 23:38:06 +0530
committerAshish Agarwal <ashish.y.agarwal@oracle.com>2013-05-19 23:38:06 +0530
commit0c4f4ff015f7c4a06b9d4c9e8f22f44a57e2a318 (patch)
tree24753afbd8c14c24de460f691e8e4a67e50a32c8 /storage/example
parent5ca36b3b46de00e9eb8030c0551e7e97bc8e24eb (diff)
downloadmariadb-git-0c4f4ff015f7c4a06b9d4c9e8f22f44a57e2a318.tar.gz
Bug#16194302: SUPPORT FOR FLOATING-POINT SYSTEM VARIABLES
USING THE PLUGIN INTERFACE. ISSUE: No support for floating-point plugin system variables. SOLUTION: Allowing plugins to define and expose floating-point system variables of type double. MYSQL_SYSVAR_DOUBLE and MYSQL_THDVAR_DOUBLE are added. ISSUE: Fractional part of the def, min, max values of system variables are ignored. SOLUTION: Adding functions that are used to store the raw representation of a double in the raw bits of unsigned longlong in a way that the binary representation remains the same.
Diffstat (limited to 'storage/example')
-rw-r--r--storage/example/ha_example.cc31
1 files changed, 29 insertions, 2 deletions
diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc
index c4ed4d5d2c2..68cd3fa2138 100644
--- a/storage/example/ha_example.cc
+++ b/storage/example/ha_example.cc
@@ -1004,6 +1004,7 @@ struct st_mysql_storage_engine example_storage_engine=
static ulong srv_enum_var= 0;
static ulong srv_ulong_var= 0;
+static double srv_double_var= 0;
const char *enum_var_names[]=
{
@@ -1038,9 +1039,34 @@ static MYSQL_SYSVAR_ULONG(
1000,
0);
+static MYSQL_SYSVAR_DOUBLE(
+ double_var,
+ srv_double_var,
+ PLUGIN_VAR_RQCMDARG,
+ "0.500000..1000.500000",
+ NULL,
+ NULL,
+ 8.5,
+ 0.5,
+ 1000.5,
+ 0); // reserved always 0
+
+static MYSQL_THDVAR_DOUBLE(
+ double_thdvar,
+ PLUGIN_VAR_RQCMDARG,
+ "0.500000..1000.500000",
+ NULL,
+ NULL,
+ 8.5,
+ 0.5,
+ 1000.5,
+ 0);
+
static struct st_mysql_sys_var* example_system_variables[]= {
MYSQL_SYSVAR(enum_var),
MYSQL_SYSVAR(ulong_var),
+ MYSQL_SYSVAR(double_var),
+ MYSQL_SYSVAR(double_thdvar),
NULL
};
@@ -1051,8 +1077,9 @@ static int show_func_example(MYSQL_THD thd, struct st_mysql_show_var *var,
var->type= SHOW_CHAR;
var->value= buf; // it's of SHOW_VAR_FUNC_BUFF_SIZE bytes
my_snprintf(buf, SHOW_VAR_FUNC_BUFF_SIZE,
- "enum_var is %lu, ulong_var is %lu, %.6b", // %b is MySQL extension
- srv_enum_var, srv_ulong_var, "really");
+ "enum_var is %lu, ulong_var is %lu, "
+ "double_var is %f, %.6b", // %b is a MySQL extension
+ srv_enum_var, srv_ulong_var, srv_double_var, "really");
return 0;
}