List:Commits« Previous MessageNext Message »
From:gluh Date:June 26 2007 11:45am
Subject:bk commit into 5.1 tree (gluh:1.2575)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of gluh. When gluh does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-06-26 16:45:22+05:00, gluh@stripped +14 -0
  WL#3582 Online Backup: SHOW commands (USER, TRIGGER)
  2nd version

  mysql-test/r/show_check.result@stripped, 2007-06-26 16:45:20+05:00, gluh@stripped +27 -0
    test result

  mysql-test/t/show_check.test@stripped, 2007-06-26 16:45:20+05:00, gluh@stripped +33 -0
    test case

  sql/mysql_priv.h@stripped, 2007-06-26 16:45:20+05:00, gluh@stripped +1 -0
    added function declaration

  sql/mysqld.cc@stripped, 2007-06-26 16:45:20+05:00, gluh@stripped +2 -0
    add "Com_show_create_trigger", "Com_show_create_user" variables to status_var array

  sql/sp_head.cc@stripped, 2007-06-26 16:45:20+05:00, gluh@stripped +2 -0
    added SQLCOM_SHOW_CREATE_TRIGGER, SQLCOM_SHOW_CREATE_USER cases to
    sp_get_flags_for_command() function

  sql/sql_acl.cc@stripped, 2007-06-26 16:45:20+05:00, gluh@stripped +95 -0
    added new functions
    bool get_user_create_info(THD *thd, LEX_USER *user, String *buffer)
    bool mysql_show_create_user(THD *thd, LEX_USER *user)

  sql/sql_acl.h@stripped, 2007-06-26 16:45:20+05:00, gluh@stripped +1 -0
    added function declaration

  sql/sql_lex.h@stripped, 2007-06-26 16:45:20+05:00, gluh@stripped +2 -1
    added SQLCOM_SHOW_CREATE_TRIGGER, SQLCOM_SHOW_CREATE_USER command to 
    enum enum_sql_command

  sql/sql_parse.cc@stripped, 2007-06-26 16:45:20+05:00, gluh@stripped +18 -0
    added SQLCOM_SHOW_CREATE_USER, SQLCOM_SHOW_CREATE_TRIGGER processing

  sql/sql_prepare.cc@stripped, 2007-06-26 16:45:20+05:00, gluh@stripped +2 -0
    added SQLCOM_SHOW_CREATE_TRIGGER, SQLCOM_SHOW_CREATE_USER cases to
    check_prepared_statement() function

  sql/sql_show.cc@stripped, 2007-06-26 16:45:20+05:00, gluh@stripped +12 -8
    changed get_schema_triggers_record() code according to
    new Table_triggers_list::get_trigger_info() method

  sql/sql_trigger.cc@stripped, 2007-06-26 16:45:20+05:00, gluh@stripped +185 -5
    added new functions:
    bool get_trigger_create_info(THD* thd, sp_name *trig, TABLE_LIST *tables, String *buffer)
    bool mysql_show_create_trigger(THD *thd, sp_name *trig)

  sql/sql_trigger.h@stripped, 2007-06-26 16:45:20+05:00, gluh@stripped +2 -1
    splitted 'definer' parameter on LEX_STRING *definer_user & LEX_STRING *definer_host.

  sql/sql_yacc.yy@stripped, 2007-06-26 16:45:20+05:00, gluh@stripped +13 -1
    added SHOW_CREATE_TRIGGER, SHOW_CREATE_USER processing

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	gluh
# Host:	eagle.(none)
# Root:	/home/gluh/MySQL/WL/5.1.3582

--- 1.499/sql/mysql_priv.h	2007-04-20 13:50:45 +05:00
+++ 1.500/sql/mysql_priv.h	2007-06-26 16:45:20 +05:00
@@ -1016,6 +1016,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *
                   bool reset_auto_increment);
 bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok);
 bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create);
+bool mysql_show_create_trigger(THD *thd, sp_name *trig);
 uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list,
                           bool tmp_table);
 TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,

--- 1.633/sql/mysqld.cc	2007-04-20 13:50:45 +05:00
+++ 1.634/sql/mysqld.cc	2007-06-26 16:45:20 +05:00
@@ -6924,6 +6924,8 @@ SHOW_VAR status_vars[]= {
   {"Com_show_create_db",       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_DB]), SHOW_LONG_STATUS},
   {"Com_show_create_event",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_EVENT]), SHOW_LONG_STATUS},
   {"Com_show_create_table",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE]), SHOW_LONG_STATUS},
+  {"Com_show_create_trigger",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_TRIGGER]), SHOW_LONG_STATUS},
+  {"Com_show_create_user",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_CREATE_USER]), SHOW_LONG_STATUS},
   {"Com_show_databases",       (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_DATABASES]), SHOW_LONG_STATUS},
   {"Com_show_engine_logs",     (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_LOGS]), SHOW_LONG_STATUS},
   {"Com_show_engine_mutex",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_ENGINE_MUTEX]), SHOW_LONG_STATUS},

--- 1.234/sql/sql_acl.cc	2007-03-28 23:05:05 +05:00
+++ 1.235/sql/sql_acl.cc	2007-06-26 16:45:20 +05:00
@@ -5420,6 +5420,101 @@ static void append_user(String *str, LEX
 
 
 /*
+  Get user 'create statement' string
+
+  SYNOPSIS
+    get_user_create_info()
+    thd                         current thread context
+    user                        user name
+    buffer                      'create statement' string
+
+  RETURN
+    FALSE OK
+    TRUE  Error
+*/
+
+bool get_user_create_info(THD *thd, LEX_USER *user, String *buffer)
+{
+  buffer->append(STRING_WITH_LEN("CREATE USER "));
+  append_identifier(thd, buffer, user->user.str, user->user.length);
+  buffer->append('@');
+  append_identifier(thd, buffer, user->host.str, user->host.length);
+  return 0;
+}
+
+
+/*
+  Show user definition
+
+  SYNOPSIS
+    mysql_show_create_user()
+    thd                         The current thread.
+    user                        The users to show.
+    buffer                      String buffer where
+                               'show create' result statement is stored
+    send_result_to_client       the flag which indicates that
+                                the result should be sent to client
+  RETURN
+    FALSE       OK.
+    TRUE        Error.
+*/
+
+bool mysql_show_create_user(THD *thd, LEX_USER *user)
+{
+  int result= 1;
+  TABLE_LIST tables[GRANT_TABLES];
+  CHARSET_INFO *cs= system_charset_info;
+  char create_buff[2048];
+  String buffer(create_buff, sizeof(create_buff), cs);
+  DBUG_ENTER("mysql_show_create_user");
+
+  if ((result= open_grant_tables(thd, tables)))
+    DBUG_RETURN(result != 1);
+
+  rw_wrlock(&LOCK_grant);
+  VOID(pthread_mutex_lock(&acl_cache->lock));
+
+  buffer.length(0);
+  if (handle_grant_data(tables, 0, user, NULL))
+  {
+    if (!get_user_create_info(thd, user, &buffer))
+    {
+      char buff[USER_HOST_BUFF_SIZE];
+      Protocol *protocol= thd->protocol;
+      List<Item> field_list;
+
+      strxmov(buff, user->user.str, "@", user->host.str, NullS);
+      field_list.push_back(new Item_empty_string("USER_NAME",
+                                                 USER_HOST_BUFF_SIZE, cs));
+      field_list.push_back(new Item_empty_string("CREATE_USER",
+                                                 max(buffer.length(),1024), cs));
+      if (protocol->send_fields(&field_list,
+                                Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
+        goto err;
+      protocol->prepare_for_resend();
+      protocol->store(buff, strlen(buff), cs);
+      protocol->store(buffer.ptr(), buffer.length(), cs);
+      if (protocol->write())
+        goto err;
+      result= 0;
+      send_eof(thd);
+    }
+  }
+  else
+  {
+    append_user(&buffer, user);
+    my_error(ER_CANNOT_USER, MYF(0), "SHOW CREATE USER", buffer.c_ptr_safe());
+  }
+
+err:
+  VOID(pthread_mutex_unlock(&acl_cache->lock));
+  rw_unlock(&LOCK_grant);
+  close_thread_tables(thd);
+  DBUG_RETURN(result);
+}
+
+
+/*
   Create a list of users.
 
   SYNOPSIS

--- 1.55/sql/sql_acl.h	2007-03-21 17:31:43 +04:00
+++ 1.56/sql/sql_acl.h	2007-06-26 16:45:20 +05:00
@@ -257,6 +257,7 @@ ulong get_column_grant(THD *thd, GRANT_I
 bool mysql_show_grants(THD *thd, LEX_USER *user);
 void get_privilege_desc(char *to, uint max_length, ulong access);
 void get_mqh(const char *user, const char *host, USER_CONN *uc);
+bool mysql_show_create_user(THD *thd, LEX_USER *user);
 bool mysql_create_user(THD *thd, List <LEX_USER> &list);
 bool mysql_drop_user(THD *thd, List <LEX_USER> &list);
 bool mysql_rename_user(THD *thd, List <LEX_USER> &list);

--- 1.272/sql/sql_lex.h	2007-04-21 01:33:54 +05:00
+++ 1.273/sql/sql_lex.h	2007-06-26 16:45:20 +05:00
@@ -112,7 +112,8 @@ enum enum_sql_command {
   SQLCOM_SHOW_CONTRIBUTORS,
   SQLCOM_CREATE_SERVER, SQLCOM_DROP_SERVER, SQLCOM_ALTER_SERVER,
   SQLCOM_CREATE_EVENT, SQLCOM_ALTER_EVENT, SQLCOM_DROP_EVENT,
-  SQLCOM_SHOW_CREATE_EVENT, SQLCOM_SHOW_EVENTS, 
+  SQLCOM_SHOW_CREATE_EVENT, SQLCOM_SHOW_EVENTS,
+  SQLCOM_SHOW_CREATE_TRIGGER, SQLCOM_SHOW_CREATE_USER,
 
   /* This should be the last !!! */
 

--- 1.659/sql/sql_parse.cc	2007-04-13 14:47:39 +05:00
+++ 1.660/sql/sql_parse.cc	2007-06-26 16:45:20 +05:00
@@ -3233,6 +3233,19 @@ end_with_restore_list:
     break;
   }
 #ifndef NO_EMBEDDED_ACCESS_CHECKS
+  case SQLCOM_SHOW_CREATE_USER:
+  {
+    LEX_USER *grant_user= get_current_user(thd, lex->grant_user);
+    if (!grant_user)
+      goto error;
+    if ((thd->security_ctx->priv_user &&
+	 !strcmp(thd->security_ctx->priv_user, grant_user->user.str)) ||
+	!check_access(thd, SELECT_ACL, "mysql",0,1,0,0))
+    {
+      res= mysql_show_create_user(thd, lex->grant_user);
+    }
+    break;
+  }
   case SQLCOM_CREATE_USER:
   {
     if (check_access(thd, INSERT_ACL, "mysql", 0, 1, 1, 0) &&
@@ -4058,6 +4071,11 @@ create_sp_error:
 
     /* Conditionally writes to binlog. */
     res= mysql_create_or_drop_trigger(thd, all_tables, 0);
+    break;
+  }
+  case SQLCOM_SHOW_CREATE_TRIGGER:
+  {
+    res= mysql_show_create_trigger(thd, thd->lex->spname);
     break;
   }
   case SQLCOM_XA_START:

--- 1.407/sql/sql_show.cc	2007-04-21 13:20:10 +05:00
+++ 1.408/sql/sql_show.cc	2007-06-26 16:45:20 +05:00
@@ -3828,21 +3828,25 @@ static int get_schema_triggers_record(TH
         LEX_STRING trigger_name;
         LEX_STRING trigger_stmt;
         ulong sql_mode;
+        LEX_STRING definer_user, definer_host;
         char definer_holder[USER_HOST_BUFF_SIZE];
-        LEX_STRING definer_buffer;
-        definer_buffer.str= definer_holder;
+        LEX_STRING definer;
+
+        definer.length= 0;
+        definer.str= definer_holder;
         if (triggers->get_trigger_info(thd, (enum trg_event_type) event,
                                        (enum trg_action_time_type)timing,
                                        &trigger_name, &trigger_stmt,
                                        &sql_mode,
-                                       &definer_buffer))
+                                       &definer_user, &definer_host))
           continue;
-
+        if (&definer_user.str && &definer_host.str)
+          definer.length= strxmov(definer.str, definer_user.str, "@",
+                                  definer_host.str, NullS) - definer.str;
         if (store_trigger(thd, table, base_name, file_name, &trigger_name,
-                         (enum trg_event_type) event,
-                         (enum trg_action_time_type) timing, &trigger_stmt,
-                         sql_mode,
-                         &definer_buffer))
+                          (enum trg_event_type) event,
+                          (enum trg_action_time_type) timing, &trigger_stmt,
+                          sql_mode, &definer))
           DBUG_RETURN(1);
       }
     }

--- 1.563/sql/sql_yacc.yy	2007-04-07 14:55:25 +05:00
+++ 1.564/sql/sql_yacc.yy	2007-06-26 16:45:20 +05:00
@@ -8873,7 +8873,19 @@ show_param:
             Lex->spname= $3;
             Lex->sql_command = SQLCOM_SHOW_CREATE_EVENT;
           }
-      ;
+        | CREATE TRIGGER_SYM sp_name
+          {
+            Lex->spname= $3;
+            Lex->sql_command = SQLCOM_SHOW_CREATE_TRIGGER;
+          }
+        | CREATE USER user
+          {
+            LEX *lex= Lex;
+            lex->grant_user= $3;
+            lex->grant_user->password=null_lex_str;
+            lex->sql_command = SQLCOM_SHOW_CREATE_USER;
+          }
+        ;
 
 show_engine_param:
 	STATUS_SYM

--- 1.89/sql/sql_trigger.cc	2007-04-15 02:05:37 +05:00
+++ 1.90/sql/sql_trigger.cc	2007-06-26 16:45:20 +05:00
@@ -1130,7 +1130,8 @@ bool Table_triggers_list::get_trigger_in
                                            LEX_STRING *trigger_name,
                                            LEX_STRING *trigger_stmt,
                                            ulong *sql_mode,
-                                           LEX_STRING *definer)
+                                           LEX_STRING *definer_user,
+                                           LEX_STRING *definer_host)
 {
   sp_head *body;
   DBUG_ENTER("get_trigger_info");
@@ -1142,13 +1143,15 @@ bool Table_triggers_list::get_trigger_in
 
     if (body->m_chistics->suid == SP_IS_NOT_SUID)
     {
-      definer->str[0]= 0;
-      definer->length= 0;
+      definer_user->str= definer_host->str= 0;
+      definer_user->length= definer_host->length= 0;
     }
     else
     {
-      definer->length= strxmov(definer->str, body->m_definer_user.str, "@",
-                               body->m_definer_host.str, NullS) - definer->str;
+      definer_user->str= body->m_definer_user.str;
+      definer_user->length= body->m_definer_user.length;
+      definer_host->str= body->m_definer_host.str;
+      definer_host->length= body->m_definer_host.length;
     }
 
     DBUG_RETURN(0);
@@ -1732,4 +1735,181 @@ process_unknown_string(char *&unknown_ke
     unknown_key= ptr-1;
   }
   DBUG_RETURN(FALSE);
+}
+
+
+/*
+  Get trigger 'create statement' string
+
+  SYNOPSIS
+    get_trigger_create_info()
+    thd                         current thread context
+    trig                        Trigger name
+    tables                      table the trigger belongs to
+    buffer                      'create statement' string
+
+  RETURN
+    FALSE OK
+    TRUE  Error
+*/
+
+bool get_trigger_create_info(THD* thd, sp_name *trig,
+                             TABLE_LIST *tables, String *buffer)
+{
+  bool res= 1;
+  if (tables->table->triggers)
+  {
+    Table_triggers_list *triggers= tables->table->triggers;
+    int event, timing;
+    for (event= 0; event < (int)TRG_EVENT_MAX; event++)
+    {
+      for (timing= 0; timing < (int)TRG_ACTION_MAX; timing++)
+      {
+        LEX_STRING trigger_name;
+        LEX_STRING trigger_stmt;
+        ulong sql_mode;
+        LEX_STRING definer_user, definer_host;
+        char definer_holder[USER_HOST_BUFF_SIZE];
+        LEX_STRING definer;
+
+        definer.length= 0;
+        definer.str= definer_holder;
+        if (triggers->get_trigger_info(thd, (enum trg_event_type) event,
+                                       (enum trg_action_time_type)timing,
+                                       &trigger_name, &trigger_stmt,
+                                       &sql_mode,
+                                       &definer_user, &definer_host))
+          continue;
+
+        if (strcmp(trigger_name.str, trig->m_name.str))
+          continue;
+
+        buffer->length(0);
+        buffer->append(STRING_WITH_LEN("CREATE "));
+        if (definer_user.str && definer_host.str)
+          append_definer(thd, buffer, &definer_user, &definer_host);
+        buffer->append(STRING_WITH_LEN("TRIGGER "));
+        append_identifier(thd, buffer, trig->m_name.str, trig->m_name.length);
+        buffer->append(' ');
+        buffer->append(trg_action_time_type_names[timing].str,
+                       trg_action_time_type_names[timing].length);
+        buffer->append(' ');
+        buffer->append(trg_event_type_names[event].str,
+                       trg_event_type_names[event].length);
+        buffer->append(STRING_WITH_LEN(" ON "));
+        append_identifier(thd, buffer, tables->table_name, 
+                          tables->table_name_length);
+        buffer->append(STRING_WITH_LEN(" FOR EACH ROW "));
+        buffer->append(trigger_stmt.str, trigger_stmt.length);
+        res= 0;
+        goto end;
+      }
+    }
+  }
+end:
+  return res; 
+}
+
+
+/*
+  Show trigger definition
+
+  SYNOPSIS
+    mysql_show_create_trigger()
+    thd                         current thread context
+    trig                        Trigger name
+
+  RETURN
+    FALSE OK
+    TRUE  Error
+*/
+
+bool mysql_show_create_trigger(THD *thd, sp_name *trig)
+{
+  CHARSET_INFO *cs= system_charset_info;
+  char path_buff[FN_REFLEN];
+  LEX_STRING path;
+  File_parser *parser;
+  struct st_trigname trigname;  
+  Handle_old_incorrect_trigger_table_hook
+    trigger_table_hook(path_buff, &trigname.trigger_table);
+  TABLE_LIST tables;
+  TABLE table;
+  bool res= 1;
+  char buff[2048];
+  String buffer(buff, sizeof(buff), cs);
+  DBUG_ENTER("mysql_show_create_trigger");
+
+  path.length= build_table_filename(path_buff, FN_REFLEN-1,
+                                    trig->m_db.str, trig->m_name.str,
+                                    trigname_file_ext, 0);
+  path.str= path_buff;
+  if (access(path_buff, F_OK))
+  {
+    my_error(ER_TRG_DOES_NOT_EXIST, MYF(0));
+    DBUG_RETURN(1);
+  }
+
+  if (!(parser= sql_parse_prepare(&path, thd->mem_root, 1)))
+    DBUG_RETURN(1);
+
+  if (!is_equal(&trigname_file_type, parser->type()))
+  {
+    my_error(ER_WRONG_OBJECT, MYF(0), trig->m_name.str, trigname_file_ext+1,
+             "TRIGGERNAME");
+    DBUG_RETURN(1);
+  }
+
+  if (parser->parse((gptr)&trigname, thd->mem_root,
+                    trigname_file_parameters, 1,
+                    &trigger_table_hook))
+    DBUG_RETURN(1);
+
+  bzero((char*) &tables, sizeof(tables));
+  tables.db= trig->m_db.str;
+  tables.db_length= trig->m_db.length;
+  tables.table_name= trigname.trigger_table.str;
+  tables.table_name_length= trigname.trigger_table.length;
+#ifndef NO_EMBEDDED_ACCESS_CHECKS
+  {
+    if (check_table_access(thd, TRIGGER_ACL, &tables, 0))
+      DBUG_RETURN(1);
+  }
+#endif
+  bzero((char*) &table, sizeof(table));
+  tables.table= &table;
+  init_sql_alloc(&table.mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
+  if (Table_triggers_list::check_n_load(thd, trig->m_db.str,
+                                        trigname.trigger_table.str, &table,
+                                        true))
+  {
+    free_root(&table.mem_root, MYF(0));
+    DBUG_RETURN(1);
+  }
+
+  if (!get_trigger_create_info(thd, trig, &tables, &buffer))
+  {
+    List<Item> field_list;
+    Protocol *protocol= thd->protocol;
+    field_list.push_back(new Item_empty_string("TRIGGER_NAME",
+                                               NAME_CHAR_LEN, cs));
+    field_list.push_back(new Item_empty_string("CREATE_TRIGGER",
+                                               max(buffer.length(), 1024), cs));
+    if (protocol->send_fields(&field_list,
+                              Protocol::SEND_NUM_ROWS |
+                              Protocol::SEND_EOF))
+      goto err;
+    protocol->prepare_for_resend();
+    protocol->store(trig->m_name.str, trig->m_name.length, cs);
+    protocol->store(buffer.ptr(), buffer.length(), cs);
+    if (protocol->write())
+      goto err;
+    send_eof(thd);
+    res= 0;
+  }
+
+err:
+  delete table.triggers;
+  free_root(&table.mem_root, MYF(0));
+  DBUG_RETURN(res);
 }

--- 1.30/sql/sql_trigger.h	2007-04-05 14:17:46 +05:00
+++ 1.31/sql/sql_trigger.h	2007-06-26 16:45:20 +05:00
@@ -101,7 +101,8 @@ public:
                         trg_action_time_type time_type,
                         LEX_STRING *trigger_name, LEX_STRING *trigger_stmt,
                         ulong *sql_mode,
-                        LEX_STRING *definer);
+                        LEX_STRING *definer_user,
+                        LEX_STRING *definer_host);
 
   static bool check_n_load(THD *thd, const char *db, const char *table_name,
                            TABLE *table, bool names_only);

--- 1.111/mysql-test/r/show_check.result	2007-03-06 17:44:10 +04:00
+++ 1.112/mysql-test/r/show_check.result	2007-06-26 16:45:20 +05:00
@@ -752,4 +752,31 @@ Tables_in_test	Table_type
 été	BASE TABLE
 drop table `été`;
 set names latin1;
+show create trigger trg1;
+ERROR HY000: Trigger does not exist
+create table t1 (i int);
+create trigger trg1 before insert on t1 for each row set @a:=1;
+create trigger trg2 after insert on t1 for each row set @a:=1;
+create trigger TRG2 after update on t1 for each row set @a:=1;
+show create trigger trg1;
+TRIGGER_NAME	CREATE_TRIGGER
+trg1	CREATE DEFINER=`root`@`localhost` TRIGGER `trg1` BEFORE INSERT ON `t1` FOR EACH ROW set @a:=1
+show create trigger trg2;
+TRIGGER_NAME	CREATE_TRIGGER
+trg2	CREATE DEFINER=`root`@`localhost` TRIGGER `trg2` AFTER INSERT ON `t1` FOR EACH ROW set @a:=1
+show create trigger TRG2;
+TRIGGER_NAME	CREATE_TRIGGER
+TRG2	CREATE DEFINER=`root`@`localhost` TRIGGER `TRG2` AFTER UPDATE ON `t1` FOR EACH ROW set @a:=1
+grant select on test.* to mysqltest_1@localhost;
+show create trigger trg1;
+ERROR 42000: TRIGGER command denied to user 'mysqltest_1'@'localhost' for table 't1'
+drop user mysqltest_1@localhost;
+drop table t1;
+create user mysqltest_1@localhost;
+show create user not_existing@localhost;
+ERROR HY000: Operation SHOW CREATE USER failed for 'not_existing'@'localhost'
+show create user mysqltest_1@localhost;
+USER_NAME	CREATE_USER
+mysqltest_1@localhost	CREATE USER `mysqltest_1`@`localhost`
+drop user mysqltest_1@localhost;
 End of 5.1 tests

--- 1.76/mysql-test/t/show_check.test	2007-04-16 19:08:27 +05:00
+++ 1.77/mysql-test/t/show_check.test	2007-06-26 16:45:20 +05:00
@@ -593,4 +593,37 @@ show full tables;
 drop table `été`;
 set names latin1;
 
+
+#
+# SHOW CREATE TRIGGER
+#
+
+--error 1360
+show create trigger trg1;
+create table t1 (i int);
+create trigger trg1 before insert on t1 for each row set @a:=1;
+create trigger trg2 after insert on t1 for each row set @a:=1;
+create trigger TRG2 after update on t1 for each row set @a:=1;
+show create trigger trg1;
+show create trigger trg2;
+show create trigger TRG2;
+
+grant select on test.* to mysqltest_1@localhost;
+connect (con_show_create, localhost, mysqltest_1,, test);
+--error 1142
+show create trigger trg1;
+connection default;
+drop user mysqltest_1@localhost;
+drop table t1;
+
+#
+# SHOW CRATE USER
+#
+create user mysqltest_1@localhost;
+--error 1396
+show create user not_existing@localhost;
+show create user mysqltest_1@localhost;
+drop user mysqltest_1@localhost;
+
+
 --echo End of 5.1 tests

--- 1.266/sql/sp_head.cc	2007-04-21 02:31:06 +05:00
+++ 1.267/sql/sp_head.cc	2007-06-26 16:45:20 +05:00
@@ -180,6 +180,8 @@ sp_get_flags_for_command(LEX *lex)
   case SQLCOM_SHOW_CREATE_FUNC:
   case SQLCOM_SHOW_CREATE_PROC:
   case SQLCOM_SHOW_CREATE_EVENT:
+  case SQLCOM_SHOW_CREATE_TRIGGER:
+  case SQLCOM_SHOW_CREATE_USER:
   case SQLCOM_SHOW_DATABASES:
   case SQLCOM_SHOW_ERRORS:
   case SQLCOM_SHOW_FIELDS:

--- 1.210/sql/sql_prepare.cc	2007-04-04 22:33:34 +05:00
+++ 1.211/sql/sql_prepare.cc	2007-06-26 16:45:20 +05:00
@@ -1752,6 +1752,8 @@ static bool check_prepared_statement(Pre
   case SQLCOM_SHOW_CREATE_FUNC:
   case SQLCOM_SHOW_CREATE_EVENT:
   case SQLCOM_SHOW_CREATE:
+  case SQLCOM_SHOW_CREATE_TRIGGER:
+  case SQLCOM_SHOW_CREATE_USER:
   case SQLCOM_SHOW_PROC_CODE:
   case SQLCOM_SHOW_FUNC_CODE:
   case SQLCOM_SHOW_AUTHORS:
Thread
bk commit into 5.1 tree (gluh:1.2575)gluh26 Jun