List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:November 18 2010 7:56pm
Subject:bzr commit into mysql-5.5-bugteam branch (chris.powers:3129) Bug#35333
View as plain text  
#At file:///home/cpowers/work/dev/mysql-5.5-bugteam/ based on revid:chris.powers@stripped

 3129 Christopher Powers	2010-11-18
      Bug#35333, "If Federated table can't connect to remote host, can't retrieve metadata"
                  
      Improved error handling such that queries against Information_Schema.Tables won't
      fail if a federated table can't make a remote connection.
     @ mysql-test/r/lock_multi.result
        Updated with warnings that were previously masked.
     @ mysql-test/r/mdl_sync.result
        Updated with warnings that were previously masked.
     @ mysql-test/r/merge.result
        Updated with warnings that were previously masked.
     @ mysql-test/r/show_check.result
        Updated with warnings that were previously masked.
     @ mysql-test/r/view.result
        Updated with warnings that were previously masked.
     @ mysql-test/suite/federated/federated_bug_35333.result
        Changes per code review.
     @ mysql-test/suite/federated/federated_bug_35333.test
        Changes per code review.
     @ sql/sql_show.cc
        If get_schema_tables_record() encounters an error, push a warning,
        set the TABLE COMMENT column with the error text, and clear the
        error so that the operation can continue.

    modified:
      mysql-test/r/lock_multi.result
      mysql-test/r/mdl_sync.result
      mysql-test/r/merge.result
      mysql-test/r/show_check.result
      mysql-test/r/view.result
      mysql-test/suite/federated/federated_bug_35333.result
      mysql-test/suite/federated/federated_bug_35333.test
      sql/sql_show.cc
=== modified file 'mysql-test/r/lock_multi.result'
--- a/mysql-test/r/lock_multi.result	2010-02-26 12:40:25 +0000
+++ b/mysql-test/r/lock_multi.result	2010-11-18 19:56:42 +0000
@@ -430,6 +430,8 @@ SELECT table_name, table_comment FROM in
 WHERE table_schema= 'test' AND table_name= 't1';
 table_name	table_comment
 t1	Lock wait timeout exceeded; try restarting transaction
+Warnings:
+Warning	1205	Lock wait timeout exceeded; try restarting transaction
 # Connection default
 UNLOCK TABLES;
 # Connection con3

=== modified file 'mysql-test/r/mdl_sync.result'
--- a/mysql-test/r/mdl_sync.result	2010-10-06 14:34:28 +0000
+++ b/mysql-test/r/mdl_sync.result	2010-11-18 19:56:42 +0000
@@ -2322,6 +2322,8 @@ select table_name, table_type, auto_incr
 from information_schema.tables where table_schema='test' and table_name='t2';
 table_name	table_type	auto_increment	table_comment
 t2	BASE TABLE	NULL	Table 'test'.'t2' was skipped since its definition is being modified by concurrent DDL statement
+Warnings:
+Warning	1684	Table 'test'.'t2' was skipped since its definition is being modified by concurrent DDL statement
 # Switching to connection 'default'.
 unlock tables;
 # Switching to connection 'con46044'.

=== modified file 'mysql-test/r/merge.result'
--- a/mysql-test/r/merge.result	2010-10-06 07:56:29 +0000
+++ b/mysql-test/r/merge.result	2010-11-18 19:56:42 +0000
@@ -2084,6 +2084,8 @@ SELECT * FROM INFORMATION_SCHEMA.TABLES
 TABLE_SCHEMA = 'test' and TABLE_NAME='tm1';
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	TABLE_TYPE	ENGINE	VERSION	ROW_FORMAT	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	AUTO_INCREMENT	CREATE_TIME	UPDATE_TIME	CHECK_TIME	TABLE_COLLATION	CHECKSUM	CREATE_OPTIONS	TABLE_COMMENT
 def	test	tm1	BASE TABLE	NULL	NULL	NULL	#	#	#	#	#	#	#	#	#	#	NULL	#	#	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
+Warnings:
+Warning	1168	Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist
 DROP TABLE tm1;
 CREATE TABLE t1(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM;
 CREATE TABLE t2(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM;

=== modified file 'mysql-test/r/show_check.result'
--- a/mysql-test/r/show_check.result	2010-07-23 08:44:55 +0000
+++ b/mysql-test/r/show_check.result	2010-11-18 19:56:42 +0000
@@ -663,6 +663,8 @@ flush tables;
 SHOW TABLE STATUS like 't1';
 Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
 t1	NULL	NULL	NULL	NULL	#	#	#	#	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Incorrect information in file: './test/t1.frm'
+Warnings:
+Warning	1033	Incorrect information in file: './test/t1.frm'
 show create table t1;
 ERROR HY000: Incorrect information in file: './test/t1.frm'
 drop table if exists t1;

=== modified file 'mysql-test/r/view.result'
--- a/mysql-test/r/view.result	2010-07-30 15:28:36 +0000
+++ b/mysql-test/r/view.result	2010-11-18 19:56:42 +0000
@@ -840,6 +840,8 @@ show table status;
 Name	Engine	Version	Row_format	Rows	Avg_row_length	Data_length	Max_data_length	Index_length	Data_free	Auto_increment	Create_time	Update_time	Check_time	Collation	Checksum	Create_options	Comment
 t1	MyISAM	10	Fixed	0	0	0	#	1024	0	NULL	#	#	NULL	latin1_swedish_ci	NULL		
 v1	NULL	NULL	NULL	NULL	NULL	NULL	#	NULL	NULL	NULL	#	#	NULL	NULL	NULL	NULL	View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
+Warnings:
+Warning	1356	View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
 drop view v1;
 drop table t1;
 create view v1 as select 99999999999999999999999999999999999999999999999999999 as col1;

=== modified file 'mysql-test/suite/federated/federated_bug_35333.result'
--- a/mysql-test/suite/federated/federated_bug_35333.result	2010-11-18 00:22:58 +0000
+++ b/mysql-test/suite/federated/federated_bug_35333.result	2010-11-18 19:56:42 +0000
@@ -1,11 +1,30 @@
+#
+# Bug 35333 "If a Federated table can't connect to the remote hose, can't retrieve metadata"
+#
+# Queries such as SHOW TABLE STATUS and SELECT * FROM INFORMATION_SCHEMA.TABLES fail
+# when encountering a federated table that cannot connect to its remote table.
+#
+# The fix is to store the error text in the TABLE COMMENTS column of I_S.TABLES, clear
+# the remote connection error and push a warning instead. This allows the SELECT operation
+# to complete while still indicating a problem. This fix applies to any non-fatal system
+# error that occurs during a query against I_S.TABLES.
 CREATE DATABASE federated;
 CREATE DATABASE federated;
 CREATE DATABASE IF NOT EXISTS realdb;
 DROP TABLE IF EXISTS realdb.t0;
 DROP TABLE IF EXISTS federated.t0;
+#
+# Create the base table to be referenced
+#
 CREATE TABLE realdb.t0 (a text, b text) ENGINE=MYISAM;
+#
+# Create a federated table with a bogus port number
+#
 CREATE TABLE federated.t0 (a text, b text) ENGINE=FEDERATED
-CONNECTION='mysql://root@stripped:3333/realdb/t0';
+CONNECTION='mysql://root@stripped:63333/realdb/t0';
+#
+# Trigger a federated system error during a INFORMATION_SCHEMA.TABLES query
+#
 SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, TABLE_ROWS, DATA_LENGTH, TABLE_COMMENT
 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'realdb' or TABLE_SCHEMA = 'federated';
 TABLE_SCHEMA	TABLE_NAME	TABLE_TYPE	ENGINE	ROW_FORMAT	TABLE_ROWS	DATA_LENGTH	TABLE_COMMENT
@@ -16,6 +35,32 @@ Warning	1429	Unable to connect to foreig
 SHOW WARNINGS;
 Level	Code	Message
 Warning	1429	Unable to connect to foreign data source: Can't connect to MySQL server on '127.0.0.1' (111)
+#
+# Create a MyISAM table then corrupt the file
+#
+USE realdb;
+CREATE TABLE t1 (c1 int) ENGINE=MYISAM;
+#
+# Corrupt the MyISAM table by deleting the base file
+#
+/home/cpowers/work/dev/mysql-5.5-bugteam/mysql-test/var/mysqld.2/data/
+#
+# Trigger a MyISAM system error during an INFORMATION_SCHEMA.TABLES query
+#
+SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, TABLE_ROWS, DATA_LENGTH, TABLE_COMMENT
+FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
+TABLE_SCHEMA	TABLE_NAME	TABLE_TYPE	ENGINE	ROW_FORMAT	TABLE_ROWS	DATA_LENGTH	TABLE_COMMENT
+realdb	t1	BASE TABLE	NULL	NULL	NULL	NULL	Can't find file: 't1' (errno: 2)
+Warnings:
+Warning	1017	Can't find file: 't1' (errno: 2)
+SHOW WARNINGS;
+Level	Code	Message
+Warning	1017	Can't find file: 't1' (errno: 2)
+#
+# Cleanup
+#
+DROP TABLE IF EXISTS realdb.t0;
+DROP TABLE IF EXISTS federated.t0;
 DROP DATABASE realdb;
 DROP TABLE IF EXISTS federated.t1;
 DROP DATABASE federated;

=== modified file 'mysql-test/suite/federated/federated_bug_35333.test'
--- a/mysql-test/suite/federated/federated_bug_35333.test	2010-11-18 00:22:58 +0000
+++ b/mysql-test/suite/federated/federated_bug_35333.test	2010-11-18 19:56:42 +0000
@@ -1,58 +1,71 @@
-# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# 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
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
-
-# Test for Federated Engine
+--echo #
+--echo # Bug 35333 "If a Federated table can't connect to the remote hose, can't retrieve metadata"
+--echo #
+--echo # Queries such as SHOW TABLE STATUS and SELECT * FROM INFORMATION_SCHEMA.TABLES fail
+--echo # when encountering a federated table that cannot connect to its remote table.
+--echo #
+--echo # The fix is to store the error text in the TABLE COMMENTS column of I_S.TABLES, clear
+--echo # the remote connection error and push a warning instead. This allows the SELECT operation
+--echo # to complete while still indicating a problem. This fix applies to any non-fatal system
+--echo # error that occurs during a query against I_S.TABLES.
 
 --source federated.inc
 
-# Bug 35333 "If a Federated table can't connect to the remote hose, can't retrieve metadata"
-#
-# Queries such as SHOW TABLE STATUS and SELECT * FROM INFORMATION_SCHEMA.TABLES fail
-# when encountering a federated table that cannot connect to its remote table.
-#
-# The fix is to store the error text in the TABLE COMMENTS column of I_S.TABLES, clear
-# the remote connection error and push a warning instead. This allows the SELECT operation
-# to complete while still indicating a problem.
-
 --disable_warnings
 CREATE DATABASE IF NOT EXISTS realdb;
+# Federated database exists
 DROP TABLE IF EXISTS realdb.t0;
-# Federated database already exists
 DROP TABLE IF EXISTS federated.t0;
 --enable_warnings
 
-#
-# Create the base table to be referenced
-#
+--echo #
+--echo # Create the base table to be referenced
+--echo #
 CREATE TABLE realdb.t0 (a text, b text) ENGINE=MYISAM;
 
-#
-# Create a federated table with a bogus port number
-#
+--echo #
+--echo # Create a federated table with a bogus port number
+--echo #
 CREATE TABLE federated.t0 (a text, b text) ENGINE=FEDERATED
-    CONNECTION='mysql://root@stripped:3333/realdb/t0';
+    CONNECTION='mysql://root@stripped:63333/realdb/t0';
 
 #--warning ER_CONNECT_TO_FOREIGN_DATA_SOURCE
 
+--echo #
+--echo # Trigger a federated system error during a INFORMATION_SCHEMA.TABLES query
+--echo #
 SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, TABLE_ROWS, DATA_LENGTH, TABLE_COMMENT
        FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'realdb' or TABLE_SCHEMA = 'federated';
 
 SHOW WARNINGS;
 
-#
-# Cleanup
-#
+--echo #
+--echo # Create a MyISAM table then corrupt the file
+--echo #
+USE realdb;
+CREATE TABLE t1 (c1 int) ENGINE=MYISAM;
+--echo #
+--echo # Corrupt the MyISAM table by deleting the base file
+--echo #
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+--echo $MYSQLD_DATADIR
+--remove_file $MYSQLD_DATADIR/realdb/t1.MYD
+--remove_file $MYSQLD_DATADIR/realdb/t1.MYI
+
+--echo #
+--echo # Trigger a MyISAM system error during an INFORMATION_SCHEMA.TABLES query
+--echo #
+SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, TABLE_ROWS, DATA_LENGTH, TABLE_COMMENT
+       FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
+
+SHOW WARNINGS;
+--echo #
+--echo # Cleanup
+--echo #
+--disable_warnings
+DROP TABLE IF EXISTS realdb.t0;
+DROP TABLE IF EXISTS federated.t0;
 DROP DATABASE realdb;
-source federated_cleanup.inc;
+--enable_warnings
+
+--source federated_cleanup.inc

=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc	2010-11-18 00:22:58 +0000
+++ b/sql/sql_show.cc	2010-11-18 19:56:42 +0000
@@ -3789,15 +3789,18 @@ static int get_schema_tables_record(THD
 
   if (res)
   {
-    /* There was a table open error, so set the table type and fall through */
+    /* There was a table open error, so set the table type and return */
     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);
+
+    goto err;
   }
-  else if (tables->view)
+
+  if (tables->view)
   {
     table->field[3]->store(STRING_WITH_LEN("VIEW"), cs);
     table->field[20]->store(STRING_WITH_LEN("VIEW"), cs);
@@ -3827,9 +3830,7 @@ static int get_schema_tables_record(THD
       table->field[i]->set_notnull();
     }
 
-    /*
-       Collect table info from the table share
-     */
+    /* Collect table info from the table share */
 
 #ifdef WITH_PARTITION_STORAGE_ENGINE
     if (share->db_type() == partition_hton &&
@@ -3905,14 +3906,14 @@ static int get_schema_tables_record(THD
     if (share->comment.str)
       table->field[20]->store(share->comment.str, share->comment.length, cs);
 
-    /*
-       Collect table info from the storage engine
-     */
+    /* Collect table info from the storage engine  */
 
     if(file)
     {
-      /* 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)
+      /* If info() fails, then there's nothing else to do */
+      if ((info_error= file->info(HA_STATUS_VARIABLE |
+                                  HA_STATUS_TIME |
+                                  HA_STATUS_AUTO)) != 0)
         goto err;
 
       enum row_type row_type = file->get_row_type();
@@ -3999,10 +4000,10 @@ err:
   if (res || info_error)
   {
     /*
-       If an error was encountered, push a warning, set the TABLE COMMENT
-       column with the error text, and clear the error so that the operation
-       can continue.
-     */
+      If an error was encountered, push a warning, set the TABLE COMMENT
+      column with the error text, and clear the error so that the operation
+      can continue.
+    */
     const char *error= thd->is_error() ? thd->stmt_da->message() : "";
     table->field[20]->store(error, strlen(error), cs);
 


Attachment: [text/bzr-bundle] bzr/chris.powers@oracle.com-20101118195642-7p154b6frn4yk5eo.bundle
Thread
bzr commit into mysql-5.5-bugteam branch (chris.powers:3129) Bug#35333Christopher Powers18 Nov