To provide complete and consistent DDL information on every
object, MySQL should implement the following statements:
SHOW CREATE USER
SHOW CREATE TRIGGER
The information is needed to ensure that our backup/restore
feature has easy access to all DDL and DCL information needed.
The Task
--------
Implement the following statements:
SHOW CREATE USER user_name;
SHOW CREATE TRIGGER trigger_name;
The "SHOW object_type object_name" statements are for creating a single
string that is useful for re-creating the object. They produce a one-row
result set. The new SHOW statements are all derived from older statements
(INFORMATION_SCHEMA selections or other SHOW statements), so the required
privileges and the format of each clause will be the same as for the
underlying statements.
The new SHOW statements will have the general form:
SHOW object_type [qualifier.] object_name;
The models will be the old SHOW statements:
SHOW CREATE { DATABASE | EVENT | TABLE | VIEW }
Rules
-----
- Every clause which is necessary to re-create the object will appear
in the output.
- If a clause would specify the default value, and the default is not
affected by other environment factors such as the mysqld --startup
options, then the implementer may decide to omit the clause.
- If sql_mode=ansi, the implementer may decide to omit all non-ANSI
clauses because that's what happens with CREATE TABLE (see BUG#3352).
- If sql_mode=oracle|etc., the implementer will ignore Guilhem's
suggestions for syntax to look similar to Oracle|etc. (see WL#2397).
- For each statement, there will be two columns: NAME and
CREATE_
sql_lex.h:
add SQLCOM_SHOW_CREATE_TRIGGER, SQLCOM_SHOW_CREATE_USER command to
enum enum_sql_command
mysqld.cc:
add "Com_show_create_trigger", "Com_show_create_user" to status_var array
sp_head.cc:
add SQLCOM_SHOW_CREATE_TRIGGER, SQLCOM_SHOW_CREATE_USER cases to
sp_get_flags_for_command() function
sql_prepare.cc:
add SQLCOM_SHOW_CREATE_TRIGGER, SQLCOM_SHOW_CREATE_USER cases to
check_prepared_statement() function
mysql_priv.h:
add function declaration
bool mysql_show_create_trigger(THD *thd, sp_name *trig);
sql_trigger.h:
method Table_triggers_list::get_trigger_info(), split 'definer' parameter on
two:
LEX_STRING *definer_user,
LEX_STRING *definer_host.
sql_trigger.cc:
add new function
bool mysql_show_create_trigger(THD *thd, sp_name *trig)
bool get_trigger_create_info(THD* thd, sp_name *trig, TABLE_LIST *tables,
String *buffer)
sql_show.cc:
change get_schema_triggers_record() code according to
new Table_triggers_list::get_trigger_info() method
sql_yacc.yy:
add SHOW_CREATE_TRIGGER, SHOW_CREATE_USER support
sql_acl.h:
add function declaration
bool mysql_show_create_user(THD *thd, LEX_USER *user);
sql_acl.cc:
add new functions
bool get_user_create_info(THD *thd, LEX_USER *user, String *buffer)
bool mysql_show_create_user(THD *thd, LEX_USER *user)
t/show_check.test
test case
Copyright (c) 2000, 2024, Oracle Corporation and/or its affiliates. All rights reserved.