summaryrefslogtreecommitdiff
path: root/sql/sql_plugin.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-04-10 02:36:54 +0200
committerSergei Golubchik <serg@mariadb.org>2015-04-10 02:36:54 +0200
commitdd8f931957e0c6fb538fffff76f40239e624096c (patch)
treeb65e2cd8e312be4c44e12169ed5591e24c3ac3b4 /sql/sql_plugin.cc
parenteb29a63e4508359a44a29c192fae347196d5a6d3 (diff)
downloadmariadb-git-dd8f931957e0c6fb538fffff76f40239e624096c.tar.gz
be less annoying about sysvar-based table attributes
do not *always* add them to the create table definition, but only when a sysvar value is different from a default. also, when adding them - don't quote numbers
Diffstat (limited to 'sql/sql_plugin.cc')
-rw-r--r--sql/sql_plugin.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index ee6650e14e2..91b25ed417d 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -307,6 +307,7 @@ public:
virtual void global_save_default(THD *thd, set_var *var) {}
bool session_update(THD *thd, set_var *var);
bool global_update(THD *thd, set_var *var);
+ bool session_is_default(THD *thd);
};
@@ -3340,6 +3341,39 @@ uchar* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type)
}
+bool sys_var_pluginvar::session_is_default(THD *thd)
+{
+ uchar *value= plugin_var->flags & PLUGIN_VAR_THDLOCAL
+ ? intern_sys_var_ptr(thd, *(int*) (plugin_var+1), true)
+ : *(uchar**) (plugin_var+1);
+
+ real_value_ptr(thd, OPT_SESSION);
+
+ switch (plugin_var->flags & PLUGIN_VAR_TYPEMASK) {
+ case PLUGIN_VAR_BOOL:
+ return option.def_value == *(my_bool*)value;
+ case PLUGIN_VAR_INT:
+ return option.def_value == *(int*)value;
+ case PLUGIN_VAR_LONG:
+ case PLUGIN_VAR_ENUM:
+ return option.def_value == *(long*)value;
+ case PLUGIN_VAR_LONGLONG:
+ case PLUGIN_VAR_SET:
+ return option.def_value == *(longlong*)value;
+ case PLUGIN_VAR_STR:
+ {
+ const char *a=(char*)option.def_value;
+ const char *b=(char*)value;
+ return (!a && !b) || (a && b && strcmp(a,b));
+ }
+ case PLUGIN_VAR_DOUBLE:
+ return getopt_ulonglong2double(option.def_value) == *(double*)value;
+ default:
+ DBUG_ASSERT(0);
+ }
+}
+
+
TYPELIB* sys_var_pluginvar::plugin_var_typelib(void)
{
switch (plugin_var->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_THDLOCAL)) {