| 1 |
--echo # |
| 2 |
--echo # Bug 35333 "If a Federated table can't connect to the remote hose, can't retrieve metadata" |
| 3 |
--echo # |
| 4 |
--echo # Queries such as SHOW TABLE STATUS and SELECT * FROM INFORMATION_SCHEMA.TABLES fail |
| 5 |
--echo # when encountering a federated table that cannot connect to its remote table. |
| 6 |
--echo # |
| 7 |
--echo # The fix is to store the error text in the TABLE COMMENTS column of I_S.TABLES, clear |
| 8 |
--echo # the remote connection error and push a warning instead. This allows the SELECT operation |
| 9 |
--echo # to complete while still indicating a problem. This fix applies to any non-fatal system |
| 10 |
--echo # error that occurs during a query against I_S.TABLES.de |
| 11 |
|
| 12 |
--source suite/federated/include/federated.inc |
| 13 |
|
| 14 |
--disable_warnings |
| 15 |
CREATE DATABASE IF NOT EXISTS realdb; |
| 16 |
# Federated database exists |
| 17 |
DROP TABLE IF EXISTS realdb.t0; |
| 18 |
DROP TABLE IF EXISTS federated.t0; |
| 19 |
--enable_warnings |
| 20 |
|
| 21 |
--echo # |
| 22 |
--echo # Create the base table to be referenced |
| 23 |
--echo # |
| 24 |
CREATE TABLE realdb.t0 (a text, b text) ENGINE=MYISAM; |
| 25 |
|
| 26 |
--echo # |
| 27 |
--echo # Create a federated table with a bogus port number |
| 28 |
--echo # |
| 29 |
CREATE TABLE federated.t0 (a text, b text) ENGINE=FEDERATED |
| 30 |
CONNECTION='mysql://[email protected]:63333/realdb/t0'; |
| 31 |
|
| 32 |
#--warning ER_CONNECT_TO_FOREIGN_DATA_SOURCE |
| 33 |
|
| 34 |
--echo # |
| 35 |
--echo # Trigger a federated system error during a INFORMATION_SCHEMA.TABLES query |
| 36 |
--echo # |
| 37 |
# Remove O/S-specific socket error |
| 38 |
SET SESSION information_schema_stats_expiry=0; |
| 39 |
--replace_regex /\(.*\)/(socket errno)/ |
| 40 |
SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, TABLE_ROWS, DATA_LENGTH, TABLE_COMMENT |
| 41 |
FROM INFORMATION_SCHEMA.TABLES |
| 42 |
WHERE TABLE_SCHEMA = 'realdb' OR TABLE_SCHEMA = 'federated' |
| 43 |
ORDER BY TABLE_SCHEMA, TABLE_NAME; |
| 44 |
|
| 45 |
# Remove O/S-specific socket error |
| 46 |
--replace_regex /\(.*\)/(socket errno)/ |
| 47 |
SHOW WARNINGS; |
| 48 |
|
| 49 |
--echo # |
| 50 |
--echo # Create a MyISAM table then corrupt the file |
| 51 |
--echo # |
| 52 |
USE realdb; |
| 53 |
CREATE TABLE t1 (c1 int) ENGINE=MYISAM; |
| 54 |
--echo # |
| 55 |
--echo # Corrupt the MyISAM table by deleting the base file |
| 56 |
--echo # |
| 57 |
let $MYSQLD_DATADIR= `SELECT @@datadir`; |
| 58 |
--remove_file $MYSQLD_DATADIR/realdb/t1.MYD |
| 59 |
--remove_file $MYSQLD_DATADIR/realdb/t1.MYI |
| 60 |
|
| 61 |
--echo # |
| 62 |
--echo # Trigger a MyISAM system error during an INFORMATION_SCHEMA.TABLES query |
| 63 |
--echo # |
| 64 |
SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, TABLE_ROWS, DATA_LENGTH, TABLE_COMMENT |
| 65 |
FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; |
| 66 |
|
| 67 |
SHOW WARNINGS; |
| 68 |
--echo # |
| 69 |
--echo # Cleanup |
| 70 |
--echo # |
| 71 |
--disable_warnings |
| 72 |
DROP TABLE IF EXISTS realdb.t0; |
| 73 |
DROP TABLE IF EXISTS federated.t0; |
| 74 |
DROP DATABASE realdb; |
| 75 |
SET SESSION information_schema_stats_expiry=default; |
| 76 |
--enable_warnings |
| 77 |
|
| 78 |
--source suite/federated/include/federated_cleanup.inc |