diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2021-06-30 15:06:54 +0300 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2021-06-30 15:06:54 +0300 |
commit | 586870f9effa48831fda2590f2aee2b95b30be39 (patch) | |
tree | bc674573cb34b871045c4db1ebd7d7eea1349314 /sql/sql_show.cc | |
parent | 29098083f7ac3b445ee59c3e765eb634ec70b947 (diff) | |
parent | eb20c91b55e4b51be533314994b36bf9b24016f3 (diff) | |
download | mariadb-git-586870f9effa48831fda2590f2aee2b95b30be39.tar.gz |
Merge 10.2->10.3
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r-- | sql/sql_show.cc | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 2e02d418210..e7c42cbc8e4 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -64,6 +64,19 @@ #endif #include "transaction.h" + +#include "lex_symbol.h" +#define KEYWORD_SIZE 64 + +extern SYMBOL symbols[]; +extern size_t symbols_length; + +extern SYMBOL sql_functions[]; +extern size_t sql_functions_length; + +extern Native_func_registry func_array[]; +extern size_t func_array_length; + enum enum_i_s_events_fields { ISE_EVENT_CATALOG= 0, @@ -7894,6 +7907,60 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond) DBUG_RETURN(res); } +int add_symbol_to_table(const char* name, TABLE* table){ + DBUG_ENTER("add_symbol_to_table"); + + uint length= strlen(name); + + // If you've added a new SQL keyword longer than KEYWORD_SIZE, + // please increase the defined max length + DBUG_ASSERT(length < KEYWORD_SIZE); + + restore_record(table, s->default_values); + table->field[0]->set_notnull(); + table->field[0]->store(name, length, + system_charset_info); + if (schema_table_store_record(table->in_use, table)) + DBUG_RETURN(1); + + DBUG_RETURN(0); +} + +int fill_i_s_keywords(THD *thd, TABLE_LIST *tables, COND *cond) +{ + DBUG_ENTER("fill_i_s_keywords"); + + TABLE *table= tables->table; + + for (uint i= 0; i < symbols_length; i++){ + const char *name= symbols[i].name; + if (add_symbol_to_table(name, table)) + DBUG_RETURN(1); + } + + DBUG_RETURN(0); +} + +int fill_i_s_sql_functions(THD *thd, TABLE_LIST *tables, COND *cond) { + DBUG_ENTER("fill_i_s_sql_functions"); + + TABLE *table= tables->table; + + for (uint i= 0; i < sql_functions_length; i++){ + const char *name= sql_functions[i].name; + if (add_symbol_to_table(name, table)) + DBUG_RETURN(1); + } + + for (uint i= 0; i < func_array_length; i++){ + const char *name= func_array[i].name.str; + if (add_symbol_to_table(name, table)) + DBUG_RETURN(1); + } + + DBUG_RETURN(0); +} + int fill_status(THD *thd, TABLE_LIST *tables, COND *cond) { @@ -9187,6 +9254,18 @@ ST_FIELD_INFO enabled_roles_fields_info[]= {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} }; +ST_FIELD_INFO keywords_field_info[]= +{ + {"WORD", KEYWORD_SIZE, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} +}; + +ST_FIELD_INFO sql_functions_field_info[]= +{ + {"FUNCTION", KEYWORD_SIZE, MYSQL_TYPE_STRING, 0, MY_I_S_MAYBE_NULL, 0, SKIP_OPEN_TABLE}, + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE} +}; + ST_FIELD_INFO engines_fields_info[]= { @@ -9890,6 +9969,8 @@ ST_SCHEMA_TABLE schema_tables[]= fill_status, make_old_format, 0, 0, -1, 0, 0}, {"GLOBAL_VARIABLES", variables_fields_info, 0, fill_variables, make_old_format, 0, 0, -1, 0, 0}, + {"KEYWORDS", keywords_field_info, 0, + fill_i_s_keywords, 0, 0, -1, -1, 0, 0}, {"KEY_CACHES", keycache_fields_info, 0, fill_key_cache_tables, 0, 0, -1,-1, 0, 0}, {"KEY_COLUMN_USAGE", key_column_usage_fields_info, 0, @@ -9925,6 +10006,8 @@ ST_SCHEMA_TABLE schema_tables[]= {"STATISTICS", stat_fields_info, 0, get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0, OPEN_TABLE_ONLY|OPTIMIZE_I_S_TABLE}, + {"SQL_FUNCTIONS", sql_functions_field_info, 0, + fill_i_s_sql_functions, 0, 0, -1, -1, 0, 0}, {"SYSTEM_VARIABLES", sysvars_fields_info, 0, fill_sysvars, make_old_format, 0, 0, -1, 0, 0}, {"TABLES", tables_fields_info, 0, |