Skip to content

Commit

Permalink
MDEV-15915 Add Feature_json status variable.
Browse files Browse the repository at this point in the history
Related implementations.
  • Loading branch information
Alexey Botchkov committed Apr 26, 2018
1 parent cd48c1e commit 6e42d19
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions mysql-test/main/features.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions mysql-test/main/status.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
7 changes: 7 additions & 0 deletions mysql-test/main/status.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 26 additions & 0 deletions sql/item_create.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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;
}

Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
1 change: 1 addition & 0 deletions sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 6e42d19

Please sign in to comment.