[Commits] 6e42d19: MDEV-15915 Add Feature_json status variable.

Alexey Botchkov holyfoot at askmonty.org
Thu Apr 26 22:13:42 EEST 2018


revision-id: 6e42d19f2599b12ac3ff5a82fdcd59e2c261f98c (mariadb-10.3.6-55-g6e42d19)
parent(s): cd48c1e23a0ca203d87786ae9b0f53aff4c1b433
committer: Alexey Botchkov
timestamp: 2018-04-26 23:12:51 +0400
message:

MDEV-15915 Add Feature_json status variable.

Related implementations.

---
 mysql-test/main/features.result |  1 +
 mysql-test/main/status.result   | 12 ++++++++++++
 mysql-test/main/status.test     |  7 +++++++
 sql/item_create.cc              | 26 ++++++++++++++++++++++++++
 sql/mysqld.cc                   |  1 +
 sql/sql_class.h                 |  1 +
 6 files changed, 48 insertions(+)

diff --git a/mysql-test/main/features.result b/mysql-test/main/features.result
index a12b41c..8a4a200 100644
--- a/mysql-test/main/features.result
+++ b/mysql-test/main/features.result
@@ -10,6 +10,7 @@ Feature_dynamic_columns	0
 Feature_fulltext	0
 Feature_gis	0
 Feature_invisible_columns	0
+Feature_json	0
 Feature_locale	0
 Feature_subquery	0
 Feature_timezone	0
diff --git a/mysql-test/main/status.result b/mysql-test/main/status.result
index 18cde57..688d8ac 100644
--- a/mysql-test/main/status.result
+++ b/mysql-test/main/status.result
@@ -426,6 +426,18 @@ Threads_running	1
 SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='THREADS_RUNNING';
 VARIABLE_VALUE
 1
+#
+# MDEV-15915 Add Feature_json status variable.
+#
+SHOW STATUS LIKE 'Feature_json';
+Variable_name	Value
+Feature_json	0
+select json_valid('123');
+json_valid('123')
+1
+SHOW STATUS LIKE 'Feature_json';
+Variable_name	Value
+Feature_json	1
 connection default;
 set @@global.concurrent_insert= @old_concurrent_insert;
 SET GLOBAL log_output = @old_log_output;
diff --git a/mysql-test/main/status.test b/mysql-test/main/status.test
index 92fba9a..221a24a 100644
--- a/mysql-test/main/status.test
+++ b/mysql-test/main/status.test
@@ -430,6 +430,13 @@ FLUSH STATUS;
 SHOW STATUS LIKE 'Threads_running';
 SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='THREADS_RUNNING';
 
+--echo #
+--echo # MDEV-15915 Add Feature_json status variable.
+--echo #
+SHOW STATUS LIKE 'Feature_json';
+select json_valid('123');
+SHOW STATUS LIKE 'Feature_json';
+
 # Restore global concurrent_insert value. Keep in the end of the test file.
 --connection default
 set @@global.concurrent_insert= @old_concurrent_insert;
diff --git a/sql/item_create.cc b/sql/item_create.cc
index 901dfa0..8b8476b 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -5118,6 +5118,7 @@ Create_func_json_exists Create_func_json_exists::s_singleton;
 Item*
 Create_func_json_exists::create_2_arg(THD *thd, Item *arg1, Item *arg2)
 {
+  status_var_increment(current_thd->status_var.feature_json);
   return new (thd->mem_root) Item_func_json_exists(thd, arg1, arg2);
 }
 
@@ -5143,6 +5144,7 @@ Create_func_json_detailed::create_native(THD *thd, LEX_CSTRING *name,
     func= new (thd->mem_root) Item_func_json_format(thd, *item_list);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5152,6 +5154,7 @@ Create_func_json_loose Create_func_json_loose::s_singleton;
 Item*
 Create_func_json_loose::create_1_arg(THD *thd, Item *arg1)
 {
+  status_var_increment(current_thd->status_var.feature_json);
   return new (thd->mem_root) Item_func_json_format(thd, arg1,
                Item_func_json_format::LOOSE);
 }
@@ -5162,6 +5165,7 @@ Create_func_json_compact Create_func_json_compact::s_singleton;
 Item*
 Create_func_json_compact::create_1_arg(THD *thd, Item *arg1)
 {
+  status_var_increment(current_thd->status_var.feature_json);
   return new (thd->mem_root) Item_func_json_format(thd, arg1,
                Item_func_json_format::COMPACT);
 }
@@ -5172,6 +5176,7 @@ Create_func_json_valid Create_func_json_valid::s_singleton;
 Item*
 Create_func_json_valid::create_1_arg(THD *thd, Item *arg1)
 {
+  status_var_increment(current_thd->status_var.feature_json);
   return new (thd->mem_root) Item_func_json_valid(thd, arg1);
 }
 
@@ -5181,6 +5186,7 @@ Create_func_json_type Create_func_json_type::s_singleton;
 Item*
 Create_func_json_type::create_1_arg(THD *thd, Item *arg1)
 {
+  status_var_increment(current_thd->status_var.feature_json);
   return new (thd->mem_root) Item_func_json_type(thd, arg1);
 }
 
@@ -5190,6 +5196,7 @@ Create_func_json_depth Create_func_json_depth::s_singleton;
 Item*
 Create_func_json_depth::create_1_arg(THD *thd, Item *arg1)
 {
+  status_var_increment(current_thd->status_var.feature_json);
   return new (thd->mem_root) Item_func_json_depth(thd, arg1);
 }
 
@@ -5199,6 +5206,7 @@ Create_func_json_value Create_func_json_value::s_singleton;
 Item*
 Create_func_json_value::create_2_arg(THD *thd, Item *arg1, Item *arg2)
 {
+  status_var_increment(current_thd->status_var.feature_json);
   return new (thd->mem_root) Item_func_json_value(thd, arg1, arg2);
 }
 
@@ -5208,6 +5216,7 @@ Create_func_json_query Create_func_json_query::s_singleton;
 Item*
 Create_func_json_query::create_2_arg(THD *thd, Item *arg1, Item *arg2)
 {
+  status_var_increment(current_thd->status_var.feature_json);
   return new (thd->mem_root) Item_func_json_query(thd, arg1, arg2);
 }
 
@@ -5217,6 +5226,7 @@ Create_func_json_quote Create_func_json_quote::s_singleton;
 Item*
 Create_func_json_quote::create_1_arg(THD *thd, Item *arg1)
 {
+  status_var_increment(current_thd->status_var.feature_json);
   return new (thd->mem_root) Item_func_json_quote(thd, arg1);
 }
 
@@ -5226,6 +5236,7 @@ Create_func_json_unquote Create_func_json_unquote::s_singleton;
 Item*
 Create_func_json_unquote::create_1_arg(THD *thd, Item *arg1)
 {
+  status_var_increment(current_thd->status_var.feature_json);
   return new (thd->mem_root) Item_func_json_unquote(thd, arg1);
 }
 
@@ -5256,6 +5267,7 @@ Create_func_json_array::create_native(THD *thd, LEX_CSTRING *name,
     func= new (thd->mem_root) Item_func_json_array(thd);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5281,6 +5293,7 @@ Create_func_json_array_append::create_native(THD *thd, LEX_CSTRING *name,
     func= new (thd->mem_root) Item_func_json_array_append(thd, *item_list);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5306,6 +5319,7 @@ Create_func_json_array_insert::create_native(THD *thd, LEX_CSTRING *name,
     func= new (thd->mem_root) Item_func_json_array_insert(thd, *item_list);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5332,6 +5346,7 @@ Create_func_json_insert::create_native(THD *thd, LEX_CSTRING *name,
                                                     thd, *item_list);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5358,6 +5373,7 @@ Create_func_json_set::create_native(THD *thd, LEX_CSTRING *name,
                                                     thd, *item_list);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5384,6 +5400,7 @@ Create_func_json_replace::create_native(THD *thd, LEX_CSTRING *name,
                                                     thd, *item_list);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5409,6 +5426,7 @@ Create_func_json_remove::create_native(THD *thd, LEX_CSTRING *name,
     func= new (thd->mem_root) Item_func_json_remove(thd, *item_list);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5441,6 +5459,7 @@ Create_func_json_object::create_native(THD *thd, LEX_CSTRING *name,
     func= new (thd->mem_root) Item_func_json_object(thd);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5465,6 +5484,7 @@ Create_func_json_length::create_native(THD *thd, LEX_CSTRING *name,
     func= new (thd->mem_root) Item_func_json_length(thd, *item_list);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5489,6 +5509,7 @@ Create_func_json_merge::create_native(THD *thd, LEX_CSTRING *name,
     func= new (thd->mem_root) Item_func_json_merge(thd, *item_list);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5514,6 +5535,7 @@ Create_func_json_contains::create_native(THD *thd, LEX_CSTRING *name,
     my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5539,6 +5561,7 @@ Create_func_json_keys::create_native(THD *thd, LEX_CSTRING *name,
     func= new (thd->mem_root) Item_func_json_keys(thd, *item_list);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5564,6 +5587,7 @@ Create_func_json_contains_path::create_native(THD *thd, LEX_CSTRING *name,
     func= new (thd->mem_root) Item_func_json_contains_path(thd, *item_list);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5589,6 +5613,7 @@ Create_func_json_extract::create_native(THD *thd, LEX_CSTRING *name,
     func= new (thd->mem_root) Item_func_json_extract(thd, *item_list);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
@@ -5614,6 +5639,7 @@ Create_func_json_search::create_native(THD *thd, LEX_CSTRING *name,
     func= new (thd->mem_root) Item_func_json_search(thd, *item_list);
   }
 
+  status_var_increment(current_thd->status_var.feature_json);
   return func;
 }
 
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 2b1b09c..286a73d 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -8553,6 +8553,7 @@ SHOW_VAR status_vars[]= {
   {"Feature_fulltext",         (char*) offsetof(STATUS_VAR, feature_fulltext), SHOW_LONG_STATUS},
   {"Feature_gis",              (char*) offsetof(STATUS_VAR, feature_gis), SHOW_LONG_STATUS},
   {"Feature_invisible_columns",   (char*) offsetof(STATUS_VAR, feature_invisible_columns), SHOW_LONG_STATUS},
+  {"Feature_json",             (char*) offsetof(STATUS_VAR, feature_json), SHOW_LONG_STATUS},
   {"Feature_locale",           (char*) offsetof(STATUS_VAR, feature_locale), SHOW_LONG_STATUS},
   {"Feature_subquery",         (char*) offsetof(STATUS_VAR, feature_subquery), SHOW_LONG_STATUS},
   {"Feature_timezone",         (char*) offsetof(STATUS_VAR, feature_timezone), SHOW_LONG_STATUS},
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 81cf592..75e3f99 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -820,6 +820,7 @@ typedef struct system_status_var
   ulong feature_fulltext;	    /* +1 when MATCH is used */
   ulong feature_gis;                /* +1 opening a table with GIS features */
   ulong feature_invisible_columns;     /* +1 opening a table with invisible column */
+  ulong feature_json;		    /* +1 when JSON function appears in the statement */
   ulong feature_locale;		    /* +1 when LOCALE is set */
   ulong feature_subquery;	    /* +1 when subqueries are used */
   ulong feature_timezone;	    /* +1 when XPATH is used */


More information about the commits mailing list