List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:November 16 2010 2:08am
Subject:bzr commit into mysql-5.5-bugteam branch (chris.powers:3115) Bug#35333
View as plain text  
#At file:///home/cpowers/work/dev/mysql-5.5-bugteam/ based on revid:georgi.kodinov@stripped

 3115 Christopher Powers	2010-11-15
      Bug#35333, "If a Federated Table can't connect to the remote host, can't retrieve metadata"
      
      Improved error handling such that queries against Information_Schema.Tables won't fail if
      a Federated table is unable to connect to remote host.
     @ sql/sql_show.cc
        If Handler::Info() fails, save error text in TABLE COMMENTS column,
        clear error.

    modified:
      sql/sql_show.cc
=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2010-11-02 14:02:16 +0000
+++ b/sql/sql_show.cc	2010-11-16 02:08:47 +0000
@@ -3778,6 +3778,7 @@ static int get_schema_tables_record(THD
 {
   const char *tmp_buff;
   MYSQL_TIME time;
+  int info_error= 0;
   CHARSET_INFO *cs= system_charset_info;
   DBUG_ENTER("get_schema_tables_record");
 
@@ -3785,20 +3786,16 @@ static int get_schema_tables_record(THD
   table->field[0]->store(STRING_WITH_LEN("def"), cs);
   table->field[1]->store(db_name->str, db_name->length, cs);
   table->field[2]->store(table_name->str, table_name->length, cs);
+
   if (res)
   {
-    /*
-      there was errors during opening tables
-    */
-    const char *error= thd->is_error() ? thd->stmt_da->message() : "";
+    /* There was a table open error, so set the table type and fall through */
     if (tables->view)
       table->field[3]->store(STRING_WITH_LEN("VIEW"), cs);
     else if (tables->schema_table)
       table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
     else
       table->field[3]->store(STRING_WITH_LEN("BASE TABLE"), cs);
-    table->field[20]->store(error, strlen(error), cs);
-    thd->clear_error();
   }
   else if (tables->view)
   {
@@ -3815,6 +3812,7 @@ static int get_schema_tables_record(THD
 #ifdef WITH_PARTITION_STORAGE_ENGINE
     bool is_partitioned= FALSE;
 #endif
+
     if (share->tmp_table == SYSTEM_TMP_TABLE)
       table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
     else if (share->tmp_table)
@@ -3828,6 +3826,11 @@ static int get_schema_tables_record(THD
         continue;
       table->field[i]->set_notnull();
     }
+
+    /*
+       Collect table info from the table share
+     */
+
 #ifdef WITH_PARTITION_STORAGE_ENGINE
     if (share->db_type() == partition_hton &&
         share->partition_info_str_len)
@@ -3836,62 +3839,82 @@ static int get_schema_tables_record(THD
       is_partitioned= TRUE;
     }
 #endif
+
     tmp_buff= (char *) ha_resolve_storage_engine_name(tmp_db_type);
     table->field[4]->store(tmp_buff, strlen(tmp_buff), cs);
     table->field[5]->store((longlong) share->frm_version, TRUE);
 
     ptr=option_buff;
+
     if (share->min_rows)
     {
       ptr=strmov(ptr," min_rows=");
       ptr=longlong10_to_str(share->min_rows,ptr,10);
     }
+
     if (share->max_rows)
     {
       ptr=strmov(ptr," max_rows=");
       ptr=longlong10_to_str(share->max_rows,ptr,10);
     }
+
     if (share->avg_row_length)
     {
       ptr=strmov(ptr," avg_row_length=");
       ptr=longlong10_to_str(share->avg_row_length,ptr,10);
     }
+
     if (share->db_create_options & HA_OPTION_PACK_KEYS)
       ptr=strmov(ptr," pack_keys=1");
+
     if (share->db_create_options & HA_OPTION_NO_PACK_KEYS)
       ptr=strmov(ptr," pack_keys=0");
+
     /* We use CHECKSUM, instead of TABLE_CHECKSUM, for backward compability */
     if (share->db_create_options & HA_OPTION_CHECKSUM)
       ptr=strmov(ptr," checksum=1");
+
     if (share->db_create_options & HA_OPTION_DELAY_KEY_WRITE)
       ptr=strmov(ptr," delay_key_write=1");
+
     if (share->row_type != ROW_TYPE_DEFAULT)
       ptr=strxmov(ptr, " row_format=", 
                   ha_row_type[(uint) share->row_type],
                   NullS);
+
     if (share->key_block_size)
     {
       ptr= strmov(ptr, " KEY_BLOCK_SIZE=");
       ptr= longlong10_to_str(share->key_block_size, ptr, 10);
     }
+
 #ifdef WITH_PARTITION_STORAGE_ENGINE
     if (is_partitioned)
       ptr= strmov(ptr, " partitioned");
 #endif
+
     table->field[19]->store(option_buff+1,
                             (ptr == option_buff ? 0 : 
                              (uint) (ptr-option_buff)-1), cs);
 
     tmp_buff= (share->table_charset ?
                share->table_charset->name : "default");
+
     table->field[17]->store(tmp_buff, strlen(tmp_buff), cs);
 
     if (share->comment.str)
       table->field[20]->store(share->comment.str, share->comment.length, cs);
 
+    /*
+       Collect table info from the storage engine
+     */
+
     if(file)
     {
-      file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO);
+      /* If info() returns an error, then there's nothing else to do except return */
+      if ((info_error= file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO)) != 0)
+        goto exit;
+
       enum row_type row_type = file->get_row_type();
       switch (row_type) {
       case ROW_TYPE_NOT_USED:
@@ -3920,7 +3943,9 @@ static int get_schema_tables_record(THD
         tmp_buff= "Paged";
         break;
       }
+
       table->field[6]->store(tmp_buff, strlen(tmp_buff), cs);
+
       if (!tables->schema_table)
       {
         table->field[7]->store((longlong) file->stats.records, TRUE);
@@ -3969,6 +3994,19 @@ static int get_schema_tables_record(THD
       }
     }
   }
+
+exit:
+  if (info_error || res)
+  {
+    /*
+       If an error was encountered, set the TABLE COMMENT column with the
+       error text and clear any errors so that the operation can continue.
+     */
+    const char *error= thd->is_error() ? thd->stmt_da->message() : "";
+    table->field[20]->store(error, strlen(error), cs);
+    thd->clear_error();
+  }
+
   DBUG_RETURN(schema_table_store_record(thd, table));
 }
 


Attachment: [text/bzr-bundle] bzr/chris.powers@oracle.com-20101116020847-tevwv0sdwjjlx971.bundle
Thread
bzr commit into mysql-5.5-bugteam branch (chris.powers:3115) Bug#35333Christopher Powers16 Nov