List:Commits« Previous MessageNext Message »
From:gluh Date:September 19 2007 10:30am
Subject:bk commit into 5.1 tree (gluh:1.2608)
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-09-19 13:30:10+05:00, gluh@stripped +10 -0
  WL#3732 Information schema optimization(addon)
  fill_schema_table_from_frm():
  1. skip open_table_from_share() call if it's possible.
  2. I_S TRIGGERS fields use OPEN_FRM_ONLY method
  3. I_S VIEWS fields(except IS_UPDATABLE) use OPEN_FRM_ONLY method

  mysql-test/r/trigger-compat.result@stripped, 2007-09-19 13:30:07+05:00, gluh@stripped +0 -2
    result fix

  mysql-test/r/trigger-grant.result@stripped, 2007-09-19 13:30:07+05:00, gluh@stripped +0 -4
    result fix

  sql/mysql_priv.h@stripped, 2007-09-19 13:30:07+05:00, gluh@stripped +4 -0
    open_new_frm() decalaration

  sql/sql_base.cc@stripped, 2007-09-19 13:30:07+05:00, gluh@stripped +1 -5
    changed open_new_frm() to global

  sql/sql_parse.cc@stripped, 2007-09-19 13:30:07+05:00, gluh@stripped +1 -1
    tables->table->s can be 0, added check

  sql/sql_show.cc@stripped, 2007-09-19 13:30:07+05:00, gluh@stripped +158 -117
    WL#3732 Information schema optimization(addon)
    fill_schema_table_from_frm():
    1. skip open_table_from_share() call if it's possible.
    2. I_S TRIGGERS fields use OPEN_FRM_ONLY method
    3. I_S VIEWS fields(except IS_UPDATABLE) use OPEN_FRM_ONLY method
    

  sql/sql_trigger.cc@stripped, 2007-09-19 13:30:07+05:00, gluh@stripped +11 -11
    skip warning if thd->no_warnings_for_error is enabled

  sql/sql_view.cc@stripped, 2007-09-19 13:30:07+05:00, gluh@stripped +10 -7
    view definition context is initialize before exit(if view is parsed with
OPEN_VIEW_NO_PARSE flag)

  sql/table.h@stripped, 2007-09-19 13:30:07+05:00, gluh@stripped +4 -0
    added new flag

  sql/unireg.h@stripped, 2007-09-19 13:30:07+05:00, gluh@stripped +5 -0
    added new flag

diff -Nrup a/mysql-test/r/trigger-compat.result b/mysql-test/r/trigger-compat.result
--- a/mysql-test/r/trigger-compat.result	2007-06-28 22:34:47 +05:00
+++ b/mysql-test/r/trigger-compat.result	2007-09-19 13:30:07 +05:00
@@ -28,8 +28,6 @@ SELECT trigger_name, definer FROM INFORM
 trigger_name	definer
 wl2818_trg1	
 wl2818_trg2	mysqltest_dfn@localhost
-Warnings:
-Warning	1454	No definer attribute for trigger 'mysqltest_db1'.'wl2818_trg1'. The trigger
will be activated under the authorization of the invoker, which may have insufficient
privileges. Please recreate the trigger.
 
 SELECT * FROM INFORMATION_SCHEMA.TRIGGERS ORDER BY trigger_name;
 TRIGGER_CATALOG	TRIGGER_SCHEMA	TRIGGER_NAME	EVENT_MANIPULATION	EVENT_OBJECT_CATALOG	EVENT_OBJECT_SCHEMA	EVENT_OBJECT_TABLE	ACTION_ORDER	ACTION_CONDITION	ACTION_STATEMENT	ACTION_ORIENTATION	ACTION_TIMING	ACTION_REFERENCE_OLD_TABLE	ACTION_REFERENCE_NEW_TABLE	ACTION_REFERENCE_OLD_ROW	ACTION_REFERENCE_NEW_ROW	CREATED	SQL_MODE	DEFINER	CHARACTER_SET_CLIENT	COLLATION_CONNECTION	DATABASE_COLLATION
diff -Nrup a/mysql-test/r/trigger-grant.result b/mysql-test/r/trigger-grant.result
--- a/mysql-test/r/trigger-grant.result	2007-06-28 22:34:48 +05:00
+++ b/mysql-test/r/trigger-grant.result	2007-09-19 13:30:07 +05:00
@@ -165,8 +165,6 @@ trg2	@
 trg3	@abc@def@@
 trg4	@hostname
 trg5	@abcdef@@@hostname
-Warnings:
-Warning	1454	No definer attribute for trigger 'mysqltest_db1'.'trg1'. The trigger will be
activated under the authorization of the invoker, which may have insufficient privileges.
Please recreate the trigger.
 
 SELECT * FROM INFORMATION_SCHEMA.TRIGGERS ORDER BY trigger_name;
 TRIGGER_CATALOG	TRIGGER_SCHEMA	TRIGGER_NAME	EVENT_MANIPULATION	EVENT_OBJECT_CATALOG	EVENT_OBJECT_SCHEMA	EVENT_OBJECT_TABLE	ACTION_ORDER	ACTION_CONDITION	ACTION_STATEMENT	ACTION_ORIENTATION	ACTION_TIMING	ACTION_REFERENCE_OLD_TABLE	ACTION_REFERENCE_NEW_TABLE	ACTION_REFERENCE_OLD_ROW	ACTION_REFERENCE_NEW_ROW	CREATED	SQL_MODE	DEFINER	CHARACTER_SET_CLIENT	COLLATION_CONNECTION	DATABASE_COLLATION
@@ -180,8 +178,6 @@ NULL	mysqltest_db1	trg5	DELETE	NULL	mysq
 DROP USER mysqltest_dfn@localhost;
 DROP USER mysqltest_inv@localhost;
 DROP DATABASE mysqltest_db1;
-Warnings:
-Warning	1454	No definer attribute for trigger 'mysqltest_db1'.'trg1'. The trigger will be
activated under the authorization of the invoker, which may have insufficient privileges.
Please recreate the trigger.
 DELETE FROM mysql.user WHERE User LIKE 'mysqltest_%';
 DELETE FROM mysql.db WHERE User LIKE 'mysqltest_%';
 DELETE FROM mysql.tables_priv WHERE User LIKE 'mysqltest_%';
diff -Nrup a/sql/mysql_priv.h b/sql/mysql_priv.h
--- a/sql/mysql_priv.h	2007-08-31 23:13:22 +05:00
+++ b/sql/mysql_priv.h	2007-09-19 13:30:07 +05:00
@@ -1147,6 +1147,10 @@ bool reopen_tables(THD *thd,bool get_loc
 void close_data_files_and_morph_locks(THD *thd, const char *db,
                                       const char *table_name);
 void close_handle_and_leave_table_as_lock(TABLE *table);
+bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
+                  uint db_stat, uint prgflag,
+                  uint ha_open_flags, TABLE *outparam,
+                  TABLE_LIST *table_desc, MEM_ROOT *mem_root);
 bool wait_for_tables(THD *thd);
 bool table_is_used(TABLE *table, bool wait_for_name_lock);
 TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name);
diff -Nrup a/sql/sql_base.cc b/sql/sql_base.cc
--- a/sql/sql_base.cc	2007-09-04 23:25:48 +05:00
+++ b/sql/sql_base.cc	2007-09-19 13:30:07 +05:00
@@ -99,10 +99,6 @@ static int open_unireg_entry(THD *thd, T
                              char *cache_key, uint cache_key_length,
 			     MEM_ROOT *mem_root, uint flags);
 static void free_cache_entry(TABLE *entry);
-static bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
-                         uint db_stat, uint prgflag,
-                         uint ha_open_flags, TABLE *outparam,
-                         TABLE_LIST *table_desc, MEM_ROOT *mem_root);
 static void close_old_data_files(THD *thd, TABLE *table, bool morph_locks,
                                  bool send_refresh);
 static bool
@@ -7350,7 +7346,7 @@ int init_ftfuncs(THD *thd, SELECT_LEX *s
     mem_root	  temporary MEM_ROOT for parsing
 */
 
-static bool
+bool
 open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
              uint db_stat, uint prgflag,
 	     uint ha_open_flags, TABLE *outparam, TABLE_LIST *table_desc,
diff -Nrup a/sql/sql_parse.cc b/sql/sql_parse.cc
--- a/sql/sql_parse.cc	2007-08-30 00:59:33 +05:00
+++ b/sql/sql_parse.cc	2007-09-19 13:30:07 +05:00
@@ -4949,7 +4949,7 @@ check_table_access(THD *thd, ulong want_
     }
 
     if (tables->derived ||
-        (tables->table && (int)tables->table->s->tmp_table))
+        (tables->table && tables->table->s &&
(int)tables->table->s->tmp_table))
       continue;
     thd->security_ctx= sctx;
     if ((sctx->master_access & want_access) ==
diff -Nrup a/sql/sql_show.cc b/sql/sql_show.cc
--- a/sql/sql_show.cc	2007-08-28 05:23:41 +05:00
+++ b/sql/sql_show.cc	2007-09-19 13:30:07 +05:00
@@ -2951,12 +2951,13 @@ static uint get_table_open_method(TABLE_
                               open_tables function for this table
 */
 
-static int fill_schema_table_from_frm(THD *thd,TABLE *table,
+static int fill_schema_table_from_frm(THD *thd,TABLE_LIST *tables,
                                       ST_SCHEMA_TABLE *schema_table, 
                                       LEX_STRING *db_name,
                                       LEX_STRING *table_name,
                                       enum enum_schema_tables schema_table_idx)
 {
+  TABLE *table= tables->table;
   TABLE_SHARE *share;
   TABLE tbl;
   TABLE_LIST table_list;
@@ -2970,6 +2971,23 @@ static int fill_schema_table_from_frm(TH
 
   table_list.table_name= table_name->str;
   table_list.db= db_name->str;
+
+  if (schema_table->i_s_requested_object & OPEN_TRIGGER_ONLY)
+  {
+    init_sql_alloc(&tbl.mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
+    if (!Table_triggers_list::check_n_load(thd, db_name->str,
+                                           table_name->str, &tbl, 1))
+    {
+      table_list.table= &tbl;
+      res= schema_table->process_table(thd, &table_list, table,
+                                       res, db_name, table_name);
+      delete tbl.triggers;
+    }
+    free_root(&tbl.mem_root, MYF(0));
+    thd->clear_error();
+    return res;
+  }
+
   key_length= create_table_def_key(thd, key, &table_list, 0);
   pthread_mutex_lock(&LOCK_open);
   share= get_table_share(thd, &table_list, key,
@@ -2999,7 +3017,22 @@ static int fill_schema_table_from_frm(TH
     }
   }
 
-  if (share->is_view ||
+  if (share->is_view)
+  {
+    if (open_new_frm(thd, share, table_name->str,
+                     (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
+                             HA_GET_INDEX | HA_TRY_READ_ONLY),
+                     READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD |
+                     OPEN_VIEW_NO_PARSE,
+                     thd->open_options, &tbl, &table_list, thd->mem_root))
+      goto err1;
+    table_list.view= (st_lex*) share->is_view;
+    res= schema_table->process_table(thd, &table_list, table,
+                                     res, db_name, table_name);
+    goto err1;
+  }
+
+  if (!(tables->table_open_method & OPEN_FRM_ONLY_WITH_TABLE) ||
       !open_table_from_share(thd, share, table_name->str, 0,
                              (READ_KEYINFO | COMPUTE_TYPES |
                               EXTRA_RECORD | OPEN_FRM_FILE_ONLY),
@@ -3010,8 +3043,11 @@ static int fill_schema_table_from_frm(TH
     table_list.view= (st_lex*) share->is_view;
     res= schema_table->process_table(thd, &table_list, table,
                                      res, db_name, table_name);
-    closefrm(&tbl, true);
-    goto err;
+    if (tables->table_open_method & OPEN_FRM_ONLY_WITH_TABLE)
+    {
+      closefrm(&tbl, true);
+      goto err;
+    }
   }
 
 err1:
@@ -3081,6 +3117,10 @@ int get_all_tables(THD *thd, TABLE_LIST 
   */
   thd->reset_n_backup_open_tables_state(&open_tables_state_backup);
 
+  schema_table_idx= get_schema_table_idx(schema_table);
+  tables->table_open_method= table_open_method=
+    get_table_open_method(tables, schema_table, schema_table_idx);
+    
   /* 
     this branch processes SHOW FIELDS, SHOW INDEXES commands.
     see sql_parse.cc, prepare_schema_table() function where
@@ -3088,12 +3128,13 @@ int get_all_tables(THD *thd, TABLE_LIST 
   */
   if (lsel && lsel->table_list.first)
   {
+    tables->table_open_method= table_open_method=
+      get_table_open_method(tables, schema_table, schema_table_idx);
     error= fill_schema_show_cols_or_idxs(thd, tables, schema_table,
                                          &open_tables_state_backup);
     goto err;
   }
 
-  schema_table_idx= get_schema_table_idx(schema_table);
   get_lookup_field_values(thd, cond, tables, &lookup_field_vals);
   DBUG_PRINT("INDEX VALUES",("db_name='%s', table_name='%s'",
                              lookup_field_vals.db_value.str,
@@ -3127,9 +3168,6 @@ int get_all_tables(THD *thd, TABLE_LIST 
   else
     partial_cond= make_cond_for_info_schema(cond, tables);
 
-  tables->table_open_method= table_open_method=
-    get_table_open_method(tables, schema_table, schema_table_idx);
-
   if (lex->describe)
   {
     /* EXPLAIN SELECT */
@@ -3198,7 +3236,7 @@ int get_all_tables(THD *thd, TABLE_LIST 
             if (!(table_open_method & ~OPEN_FRM_ONLY) && 
                 !with_i_schema)
             {
-              if (!fill_schema_table_from_frm(thd, table, schema_table, db_name,
+              if (!fill_schema_table_from_frm(thd, tables, schema_table, db_name,
                                               table_name, schema_table_idx))
                 continue;
             }
@@ -3589,10 +3627,19 @@ static int get_schema_column_record(THD 
 
   show_table= tables->table;
   count= 0;
-  restore_record(show_table, s->default_values);
-  show_table->use_all_columns();               // Required for default
+  if (table->pos_in_table_list->table_open_method & OPEN_FRM_ONLY_WITH_TABLE)
+  {
+    restore_record(show_table, s->default_values);
+    show_table->use_all_columns();               // Required for default
+  }
 
-  for (ptr= show_table->field; (field= *ptr) ; ptr++)
+  if (tables->view || tables->schema_table ||
+      (table->pos_in_table_list->table_open_method & OPEN_FRM_ONLY_WITH_TABLE))
+    ptr= show_table->field;
+  else
+    ptr= tables->table->s->field;
+
+  for (; (field= *ptr) ; ptr++)
   {
     const char *tmp_buff;
     uchar *pos;
@@ -3604,6 +3651,9 @@ static int get_schema_column_record(THD 
     char *end;
     int decimals, field_length;
 
+    field->table= show_table;
+    show_table->in_use= thd;
+
     if (wild && wild[0] &&
         wild_case_compare(system_charset_info, field->field_name,wild))
       continue;
@@ -3645,32 +3695,35 @@ static int get_schema_column_record(THD 
     table->field[7]->store(type.ptr(),
                            (tmp_buff ? tmp_buff - type.ptr() :
                             type.length()), cs);
-    if (show_table->timestamp_field == field &&
-        field->unireg_check != Field::TIMESTAMP_UN_FIELD)
-    {
-      table->field[5]->store(STRING_WITH_LEN("CURRENT_TIMESTAMP"), cs);
-      table->field[5]->set_notnull();
-    }
-    else if (field->unireg_check != Field::NEXT_NUMBER &&
-             !field->is_null() &&
-             !(field->flags & NO_DEFAULT_VALUE_FLAG))
-    {
-      String def(tmp1,sizeof(tmp1), cs);
-      type.set(tmp, sizeof(tmp), field->charset());
-      field->val_str(&type);
-      uint dummy_errors;
-      def.copy(type.ptr(), type.length(), type.charset(), cs, &dummy_errors);
-      table->field[5]->store(def.ptr(), def.length(), def.charset());
-      table->field[5]->set_notnull();
-    }
-    else if (field->unireg_check == Field::NEXT_NUMBER ||
-             lex->sql_command != SQLCOM_SHOW_FIELDS ||
-             field->maybe_null())
-      table->field[5]->set_null();                // Null as default
-    else
+    if (table->pos_in_table_list->table_open_method & OPEN_FRM_ONLY_WITH_TABLE)
     {
-      table->field[5]->store("",0, cs);
-      table->field[5]->set_notnull();
+      if (show_table->timestamp_field == field &&
+          field->unireg_check != Field::TIMESTAMP_UN_FIELD)
+      {
+        table->field[5]->store(STRING_WITH_LEN("CURRENT_TIMESTAMP"), cs);
+        table->field[5]->set_notnull();
+      }
+      else if (field->unireg_check != Field::NEXT_NUMBER &&
+               !field->is_null() &&
+               !(field->flags & NO_DEFAULT_VALUE_FLAG))
+      {
+        String def(tmp1,sizeof(tmp1), cs);
+        type.set(tmp, sizeof(tmp), field->charset());
+        field->val_str(&type);
+        uint dummy_errors;
+        def.copy(type.ptr(), type.length(), type.charset(), cs, &dummy_errors);
+        table->field[5]->store(def.ptr(), def.length(), def.charset());
+        table->field[5]->set_notnull();
+      }
+      else if (field->unireg_check == Field::NEXT_NUMBER ||
+               lex->sql_command != SQLCOM_SHOW_FIELDS ||
+               field->maybe_null())
+        table->field[5]->set_null();                // Null as default
+      else
+      {
+        table->field[5]->store("",0, cs);
+        table->field[5]->set_notnull();
+      }
     }
     pos=(uchar*) ((flags & NOT_NULL_FLAG) ?  "NO" : "YES");
     table->field[6]->store((const char*) pos,
@@ -4158,24 +4211,15 @@ static int get_schema_views_record(THD *
 				   LEX_STRING *table_name)
 {
   CHARSET_INFO *cs= system_charset_info;
-  DBUG_ENTER("get_schema_views_record");
-  LEX_STRING *tmp_db_name, *tmp_table_name;
   char definer[USER_HOST_BUFF_SIZE];
   uint definer_len;
   bool updatable_view;
-  /*
-    if SELECT FROM I_S.VIEWS uses only fields
-    which have OPEN_FRM_ONLY flag then 'tables'
-    structure is zeroed and only tables->view is set.
-    (see fill_schema_table_from_frm() function).
-    So we should disable other fields filling.
-  */
-  bool only_share= !tables->definer.user.str;
+  DBUG_ENTER("get_schema_views_record");
 
   if (tables->view)
   {
     Security_context *sctx= thd->security_ctx;
-    if (!only_share && !tables->allowed_show)
+    if (!tables->allowed_show)
     {
       if (!my_strcasecmp(system_charset_info, tables->definer.user.str,
                          sctx->priv_user) &&
@@ -4184,34 +4228,29 @@ static int get_schema_views_record(THD *
         tables->allowed_show= TRUE;
     }
     restore_record(table, s->default_values);
-    tmp_db_name= &tables->view_db;
-    tmp_table_name= &tables->view_name;
-    if (only_share)
+    table->field[1]->store(db_name->str, db_name->length, cs);
+    table->field[2]->store(table_name->str, table_name->length, cs);
+
+    if (tables->allowed_show)
     {
-      tmp_db_name= db_name;
-      tmp_table_name= table_name;
+      table->field[3]->store(tables->view_body_utf8.str,
+                             tables->view_body_utf8.length,
+                             cs);
     }
-    table->field[1]->store(tmp_db_name->str, tmp_db_name->length, cs);
-    table->field[2]->store(tmp_table_name->str, tmp_table_name->length, cs);
-    if (!only_share)
-    {
-      if (tables->allowed_show)
-      {
-        table->field[3]->store(tables->view_body_utf8.str,
-                               tables->view_body_utf8.length,
-                               cs);
-      }
 
-      if (tables->with_check != VIEW_CHECK_NONE)
-      {
-        if (tables->with_check == VIEW_CHECK_LOCAL)
-          table->field[4]->store(STRING_WITH_LEN("LOCAL"), cs);
-        else
-          table->field[4]->store(STRING_WITH_LEN("CASCADED"), cs);
-      }
+    if (tables->with_check != VIEW_CHECK_NONE)
+    {
+      if (tables->with_check == VIEW_CHECK_LOCAL)
+        table->field[4]->store(STRING_WITH_LEN("LOCAL"), cs);
       else
-        table->field[4]->store(STRING_WITH_LEN("NONE"), cs);
+        table->field[4]->store(STRING_WITH_LEN("CASCADED"), cs);
+    }
+    else
+      table->field[4]->store(STRING_WITH_LEN("NONE"), cs);
 
+    if (table->pos_in_table_list->table_open_method &
+        OPEN_FULL_TABLE)
+    {
       updatable_view= 0;
       if (tables->algorithm != VIEW_ALGORITHM_TMPTABLE)
       {
@@ -4245,24 +4284,26 @@ static int get_schema_views_record(THD *
         table->field[5]->store(STRING_WITH_LEN("YES"), cs);
       else
         table->field[5]->store(STRING_WITH_LEN("NO"), cs);
-      definer_len= (strxmov(definer, tables->definer.user.str, "@",
-                            tables->definer.host.str, NullS) - definer);
-      table->field[6]->store(definer, definer_len, cs);
-      if (tables->view_suid)
-        table->field[7]->store(STRING_WITH_LEN("DEFINER"), cs);
-      else
-        table->field[7]->store(STRING_WITH_LEN("INVOKER"), cs);
-
-     
table->field[8]->store(tables->view_creation_ctx->get_client_cs()->csname,
-                             strlen(tables->view_creation_ctx->
-                                    get_client_cs()->csname), cs);
-
-      table->field[9]->store(tables->view_creation_ctx->
-                             get_connection_cl()->name,
-                             strlen(tables->view_creation_ctx->
-                                    get_connection_cl()->name), cs);
     }
 
+    definer_len= (strxmov(definer, tables->definer.user.str, "@",
+                          tables->definer.host.str, NullS) - definer);
+    table->field[6]->store(definer, definer_len, cs);
+    if (tables->view_suid)
+      table->field[7]->store(STRING_WITH_LEN("DEFINER"), cs);
+    else
+      table->field[7]->store(STRING_WITH_LEN("INVOKER"), cs);
+
+   
table->field[8]->store(tables->view_creation_ctx->get_client_cs()->csname,
+                           strlen(tables->view_creation_ctx->
+                                  get_client_cs()->csname), cs);
+
+    table->field[9]->store(tables->view_creation_ctx->
+                           get_connection_cl()->name,
+                           strlen(tables->view_creation_ctx->
+                                  get_connection_cl()->name), cs);
+
+
     if (schema_table_store_record(thd, table))
       DBUG_RETURN(1);
     if (res && thd->net.last_errno)
@@ -5946,7 +5987,7 @@ ST_FIELD_INFO columns_fields_info[]=
   {"ORDINAL_POSITION", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0,
    MY_I_S_UNSIGNED, 0, OPEN_FRM_ONLY},
   {"COLUMN_DEFAULT", MAX_FIELD_VARCHARLENGTH, MYSQL_TYPE_STRING, 0,
-   1, "Default", OPEN_FRM_ONLY},
+   1, "Default", OPEN_FRM_ONLY | OPEN_FRM_ONLY_WITH_TABLE},
   {"IS_NULLABLE", 3, MYSQL_TYPE_STRING, 0, 0, "Null", OPEN_FRM_ONLY},
   {"DATA_TYPE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
   {"CHARACTER_MAXIMUM_LENGTH", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG,
@@ -6120,15 +6161,15 @@ ST_FIELD_INFO view_fields_info[]=
   {"TABLE_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY},
   {"TABLE_SCHEMA", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
   {"TABLE_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
-  {"VIEW_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
-  {"CHECK_OPTION", 8, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
+  {"VIEW_DEFINITION", 65535, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
+  {"CHECK_OPTION", 8, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
   {"IS_UPDATABLE", 3, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
-  {"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
-  {"SECURITY_TYPE", 7, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
+  {"DEFINER", 77, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
+  {"SECURITY_TYPE", 7, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
   {"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0,
-   OPEN_FULL_TABLE},
+   OPEN_FRM_ONLY},
   {"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0, 0,
-   OPEN_FULL_TABLE},
+   OPEN_FRM_ONLY},
   {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 };
 
@@ -6243,38 +6284,38 @@ ST_FIELD_INFO open_tables_fields_info[]=
 
 ST_FIELD_INFO triggers_fields_info[]=
 {
-  {"TRIGGER_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
-  {"TRIGGER_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
+  {"TRIGGER_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY},
+  {"TRIGGER_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
   {"TRIGGER_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Trigger",
-   OPEN_FULL_TABLE},
-  {"EVENT_MANIPULATION", 6, MYSQL_TYPE_STRING, 0, 0, "Event", OPEN_FULL_TABLE},
+   OPEN_FRM_ONLY},
+  {"EVENT_MANIPULATION", 6, MYSQL_TYPE_STRING, 0, 0, "Event", OPEN_FRM_ONLY},
   {"EVENT_OBJECT_CATALOG", FN_REFLEN, MYSQL_TYPE_STRING, 0, 1, 0,
-   OPEN_FULL_TABLE},
+   OPEN_FRM_ONLY},
   {"EVENT_OBJECT_SCHEMA",NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, 0,
-   OPEN_FULL_TABLE},
+   OPEN_FRM_ONLY},
   {"EVENT_OBJECT_TABLE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Table",
-   OPEN_FULL_TABLE},
-  {"ACTION_ORDER", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0, OPEN_FULL_TABLE},
-  {"ACTION_CONDITION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FULL_TABLE},
+   OPEN_FRM_ONLY},
+  {"ACTION_ORDER", 4, MYSQL_TYPE_LONGLONG, 0, 0, 0, OPEN_FRM_ONLY},
+  {"ACTION_CONDITION", 65535, MYSQL_TYPE_STRING, 0, 1, 0, OPEN_FRM_ONLY},
   {"ACTION_STATEMENT", 65535, MYSQL_TYPE_STRING, 0, 0, "Statement",
-   OPEN_FULL_TABLE},
-  {"ACTION_ORIENTATION", 9, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
-  {"ACTION_TIMING", 6, MYSQL_TYPE_STRING, 0, 0, "Timing", OPEN_FULL_TABLE},
+   OPEN_FRM_ONLY},
+  {"ACTION_ORIENTATION", 9, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
+  {"ACTION_TIMING", 6, MYSQL_TYPE_STRING, 0, 0, "Timing", OPEN_FRM_ONLY},
   {"ACTION_REFERENCE_OLD_TABLE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
-   OPEN_FULL_TABLE},
+   OPEN_FRM_ONLY},
   {"ACTION_REFERENCE_NEW_TABLE", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 1, 0,
-   OPEN_FULL_TABLE},
-  {"ACTION_REFERENCE_OLD_ROW", 3, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
-  {"ACTION_REFERENCE_NEW_ROW", 3, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FULL_TABLE},
-  {"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 1, "Created", OPEN_FULL_TABLE},
-  {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, "sql_mode", OPEN_FULL_TABLE},
-  {"DEFINER", 65535, MYSQL_TYPE_STRING, 0, 0, "Definer", OPEN_FULL_TABLE},
+   OPEN_FRM_ONLY},
+  {"ACTION_REFERENCE_OLD_ROW", 3, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
+  {"ACTION_REFERENCE_NEW_ROW", 3, MYSQL_TYPE_STRING, 0, 0, 0, OPEN_FRM_ONLY},
+  {"CREATED", 0, MYSQL_TYPE_DATETIME, 0, 1, "Created", OPEN_FRM_ONLY},
+  {"SQL_MODE", 65535, MYSQL_TYPE_STRING, 0, 0, "sql_mode", OPEN_FRM_ONLY},
+  {"DEFINER", 65535, MYSQL_TYPE_STRING, 0, 0, "Definer", OPEN_FRM_ONLY},
   {"CHARACTER_SET_CLIENT", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
-   "character_set_client", OPEN_FULL_TABLE},
+   "character_set_client", OPEN_FRM_ONLY},
   {"COLLATION_CONNECTION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
-   "collation_connection", OPEN_FULL_TABLE},
+   "collation_connection", OPEN_FRM_ONLY},
   {"DATABASE_COLLATION", MY_CS_NAME_SIZE, MYSQL_TYPE_STRING, 0, 0,
-   "Database Collation", OPEN_FULL_TABLE},
+   "Database Collation", OPEN_FRM_ONLY},
   {0, 0, MYSQL_TYPE_STRING, 0, 0, 0, SKIP_OPEN_TABLE}
 };
 
@@ -6523,7 +6564,7 @@ ST_SCHEMA_TABLE schema_tables[]=
    fill_schema_table_privileges, 0, 0, -1, -1, 0, 0},
   {"TRIGGERS", triggers_fields_info, create_schema_table,
    get_all_tables, make_old_format, get_schema_triggers_record, 5, 6, 0,
-   OPEN_TABLE_ONLY},
+   OPEN_TRIGGER_ONLY|OPTIMIZE_I_S_TABLE},
   {"USER_PRIVILEGES", user_privileges_fields_info, create_schema_table, 
    fill_schema_user_privileges, 0, 0, -1, -1, 0, 0},
   {"VARIABLES", variables_fields_info, create_schema_table, fill_variables,
diff -Nrup a/sql/sql_trigger.cc b/sql/sql_trigger.cc
--- a/sql/sql_trigger.cc	2007-09-05 03:50:03 +05:00
+++ b/sql/sql_trigger.cc	2007-09-19 13:30:07 +05:00
@@ -1152,12 +1152,12 @@ bool Table_triggers_list::check_n_load(T
 
           DBUG_RETURN(1); // EOM
         }
-
-        push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                            ER_TRG_NO_CREATION_CTX,
-                            ER(ER_TRG_NO_CREATION_CTX),
-                            (const char*) db,
-                            (const char*) table_name);
+        if (!thd->no_warnings_for_error)
+          push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                              ER_TRG_NO_CREATION_CTX,
+                              ER(ER_TRG_NO_CREATION_CTX),
+                              (const char*) db,
+                              (const char*) table_name);
 
         if (!(trg_client_cs_name= alloc_lex_string(&table->mem_root)) ||
             !(trg_connection_cl_name= alloc_lex_string(&table->mem_root)) ||
@@ -1284,11 +1284,11 @@ bool Table_triggers_list::check_n_load(T
             MySQL, which does not support triggers definers. We should emit
             warning here.
           */
-
-          push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
-                              ER_TRG_NO_DEFINER, ER(ER_TRG_NO_DEFINER),
-                              (const char*) db,
-                              (const char*) lex.sphead->m_name.str);
+          if (!thd->no_warnings_for_error)
+            push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+                                ER_TRG_NO_DEFINER, ER(ER_TRG_NO_DEFINER),
+                                (const char*) db,
+                                (const char*) lex.sphead->m_name.str);
 
           /*
             Set definer to the '' to correct displaying in the information
diff -Nrup a/sql/sql_view.cc b/sql/sql_view.cc
--- a/sql/sql_view.cc	2007-08-28 05:33:54 +05:00
+++ b/sql/sql_view.cc	2007-09-19 13:30:07 +05:00
@@ -1011,8 +1011,18 @@ bool mysql_make_view(THD *thd, File_pars
                         table->db, table->table_name);
     get_default_definer(thd, &table->definer);
   }
+
+  /*
+    Initialize view definition context by character set names loaded from
+    the view definition file. Use UTF8 character set if view definition
+    file is of old version and does not contain the character set names.
+  */
+  table->view_creation_ctx= View_creation_ctx::create(thd, table);
+
   if (flags & OPEN_VIEW_NO_PARSE)
   {
+    if (arena)
+      thd->restore_active_arena(arena, &backup);
     DBUG_RETURN(FALSE);
   }
 
@@ -1027,13 +1037,6 @@ bool mysql_make_view(THD *thd, File_pars
 
   /*TODO: md5 test here and warning if it is differ */
 
-  /*
-    Initialize view definition context by character set names loaded from
-    the view definition file. Use UTF8 character set if view definition
-    file is of old version and does not contain the character set names.
-  */
-
-  table->view_creation_ctx= View_creation_ctx::create(thd, table);
 
   /*
     TODO: TABLE mem root should be used here when VIEW will be stored in
diff -Nrup a/sql/table.h b/sql/table.h
--- a/sql/table.h	2007-08-25 13:43:15 +05:00
+++ b/sql/table.h	2007-09-19 13:30:07 +05:00
@@ -724,6 +724,10 @@ enum enum_schema_tables
 #define OPEN_FRM_ONLY   1                // open FRM file only
 #define OPEN_FULL_TABLE 2                // open FRM,MYD, MYI files
 
+#define OPEN_FRM_ONLY_WITH_TABLE   4     // open FRM file only but create
+                                         // table struct using
+                                         // open_table_from_share()
+
 typedef struct st_field_info
 {
   const char* field_name;
diff -Nrup a/sql/unireg.h b/sql/unireg.h
--- a/sql/unireg.h	2007-08-22 19:02:41 +05:00
+++ b/sql/unireg.h	2007-09-19 13:30:07 +05:00
@@ -189,6 +189,11 @@
 */
 #define OPTIMIZE_I_S_TABLE     OPEN_VIEW_FULL*2
 
+/*
+  The flag means that we need to process trigger files only.
+*/
+#define OPEN_TRIGGER_ONLY      OPTIMIZE_I_S_TABLE*2
+
 #define SC_INFO_LENGTH 4		/* Form format constant */
 #define TE_INFO_LENGTH 3
 #define MTYP_NOEMPTY_BIT 128
Thread
bk commit into 5.1 tree (gluh:1.2608)gluh19 Sep
  • Re: bk commit into 5.1 tree (gluh:1.2608) WL#3732Sergei Golubchik1 Oct
    • Re: bk commit into 5.1 tree (gluh:1.2608) WL#3732Sergey Glukhov24 Oct