summaryrefslogtreecommitdiff
path: root/sql/sql_show.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_show.cc')
-rw-r--r--sql/sql_show.cc82
1 files changed, 81 insertions, 1 deletions
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index ab62a56b166..f9546b79e6f 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,
@@ -7837,6 +7849,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)
{
@@ -8988,6 +9052,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[]=
{
@@ -9566,6 +9642,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,
@@ -9603,6 +9681,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,