diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-07-02 17:00:05 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-07-02 17:00:05 +0300 |
commit | 0ad8a825a8901d4b5e704fed3fc65e93cea18f18 (patch) | |
tree | 69238e9b52a7166b603e3ebbb2c7ea1b616765ed /sql/sql_show.cc | |
parent | 315380a4d16ddb16461d906a23be341e354c30ed (diff) | |
parent | 779262842edf86c989c099c6930ae4683cbde609 (diff) | |
download | mariadb-git-0ad8a825a8901d4b5e704fed3fc65e93cea18f18.tar.gz |
Merge 10.5 into 10.6
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r-- | sql/sql_show.cc | 82 |
1 files changed, 81 insertions, 1 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc index e2ffc3c5da9..326f04dad29 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2015, Oracle and/or its affiliates. - Copyright (c) 2009, 2020, MariaDB + Copyright (c) 2009, 2021, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -66,6 +66,18 @@ #include "opt_trace.h" #include "my_cpu.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_array native_func_registry_array; + enum enum_i_s_events_fields { ISE_EVENT_CATALOG= 0, @@ -7860,6 +7872,58 @@ 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"); + + size_t 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++) + if (add_symbol_to_table(sql_functions[i].name, table)) + DBUG_RETURN(1); + + for (uint i= 0; i < native_func_registry_array.count(); i++) + if (add_symbol_to_table(native_func_registry_array.element(i).name.str, + table)) + DBUG_RETURN(1); + + DBUG_RETURN(0); +} + int fill_status(THD *thd, TABLE_LIST *tables, COND *cond) { @@ -9011,6 +9075,18 @@ ST_FIELD_INFO enabled_roles_fields_info[]= CEnd() }; +ST_FIELD_INFO keywords_field_info[]= +{ + Column("WORD", Varchar(KEYWORD_SIZE), NULLABLE), + CEnd() +}; + +ST_FIELD_INFO sql_functions_field_info[]= +{ + Column("FUNCTION", Varchar(KEYWORD_SIZE), NULLABLE), + CEnd() +}; + ST_FIELD_INFO engines_fields_info[]= { @@ -9590,6 +9666,8 @@ ST_SCHEMA_TABLE schema_tables[]= fill_status, make_old_format, 0, 0, -1, 0, 0}, {"GLOBAL_VARIABLES", Show::variables_fields_info, 0, fill_variables, make_old_format, 0, 0, -1, 0, 0}, + {"KEYWORDS", Show::keywords_field_info, 0, + fill_i_s_keywords, 0, 0, -1, -1, 0, 0}, {"KEY_CACHES", Show::keycache_fields_info, 0, fill_key_cache_tables, 0, 0, -1,-1, 0, 0}, {"KEY_COLUMN_USAGE", Show::key_column_usage_fields_info, 0, @@ -9627,6 +9705,8 @@ ST_SCHEMA_TABLE schema_tables[]= {"STATISTICS", Show::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", Show::sql_functions_field_info, 0, + fill_i_s_sql_functions, 0, 0, -1, -1, 0, 0}, {"SYSTEM_VARIABLES", Show::sysvars_fields_info, 0, fill_sysvars, make_old_format, 0, 0, -1, 0, 0}, {"TABLES", Show::tables_fields_info, 0, |