| 1 |
# |
| 2 |
# Bug 35333 "If a Federated table can't connect to the remote hose, can't retrieve metadata" |
| 3 |
# |
| 4 |
# Queries such as SHOW TABLE STATUS and SELECT * FROM INFORMATION_SCHEMA.TABLES fail |
| 5 |
# when encountering a federated table that cannot connect to its remote table. |
| 6 |
# |
| 7 |
# The fix is to store the error text in the TABLE COMMENTS column of I_S.TABLES, clear |
| 8 |
# the remote connection error and push a warning instead. This allows the SELECT operation |
| 9 |
# to complete while still indicating a problem. This fix applies to any non-fatal system |
| 10 |
# error that occurs during a query against I_S.TABLES.de |
| 11 |
CREATE DATABASE federated; |
| 12 |
CREATE DATABASE federated; |
| 13 |
CREATE DATABASE IF NOT EXISTS realdb; |
| 14 |
DROP TABLE IF EXISTS realdb.t0; |
| 15 |
DROP TABLE IF EXISTS federated.t0; |
| 16 |
# |
| 17 |
# Create the base table to be referenced |
| 18 |
# |
| 19 |
CREATE TABLE realdb.t0 (a text, b text) ENGINE=MYISAM; |
| 20 |
# |
| 21 |
# Create a federated table with a bogus port number |
| 22 |
# |
| 23 |
CREATE TABLE federated.t0 (a text, b text) ENGINE=FEDERATED |
| 24 |
CONNECTION='mysql://[email protected]:63333/realdb/t0'; |
| 25 |
# |
| 26 |
# Trigger a federated system error during a INFORMATION_SCHEMA.TABLES query |
| 27 |
# |
| 28 |
SET SESSION information_schema_stats_expiry=0; |
| 29 |
SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, TABLE_ROWS, DATA_LENGTH, TABLE_COMMENT |
| 30 |
FROM INFORMATION_SCHEMA.TABLES |
| 31 |
WHERE TABLE_SCHEMA = 'realdb' OR TABLE_SCHEMA = 'federated' |
| 32 |
ORDER BY TABLE_SCHEMA, TABLE_NAME; |
| 33 |
TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE ROW_FORMAT TABLE_ROWS DATA_LENGTH TABLE_COMMENT |
| 34 |
federated t0 BASE TABLE FEDERATED Dynamic NULL 0 Unable to connect to foreign data source: Can't connect to MySQL server on '127.0.0.1:63333' (socket errno) |
| 35 |
realdb t0 BASE TABLE MyISAM Dynamic 0 0 |
| 36 |
Warnings: |
| 37 |
Warning 1429 Unable to connect to foreign data source: Can't connect to MySQL server on '127.0.0.1:63333' (socket errno) |
| 38 |
SHOW WARNINGS; |
| 39 |
Level Code Message |
| 40 |
Warning 1429 Unable to connect to foreign data source: Can't connect to MySQL server on '127.0.0.1:63333' (socket errno) |
| 41 |
# |
| 42 |
# Create a MyISAM table then corrupt the file |
| 43 |
# |
| 44 |
USE realdb; |
| 45 |
CREATE TABLE t1 (c1 int) ENGINE=MYISAM; |
| 46 |
# |
| 47 |
# Corrupt the MyISAM table by deleting the base file |
| 48 |
# |
| 49 |
# |
| 50 |
# Trigger a MyISAM system error during an INFORMATION_SCHEMA.TABLES query |
| 51 |
# |
| 52 |
SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, ENGINE, ROW_FORMAT, TABLE_ROWS, DATA_LENGTH, TABLE_COMMENT |
| 53 |
FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; |
| 54 |
TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE ROW_FORMAT TABLE_ROWS DATA_LENGTH TABLE_COMMENT |
| 55 |
realdb t1 BASE TABLE MyISAM Fixed 0 0 Can't find file: 't1' (errno: 2 - No such file or directory) |
| 56 |
Warnings: |
| 57 |
Warning 1017 Can't find file: 't1' (errno: 2 - No such file or directory) |
| 58 |
SHOW WARNINGS; |
| 59 |
Level Code Message |
| 60 |
Warning 1017 Can't find file: 't1' (errno: 2 - No such file or directory) |
| 61 |
# |
| 62 |
# Cleanup |
| 63 |
# |
| 64 |
DROP TABLE IF EXISTS realdb.t0; |
| 65 |
DROP TABLE IF EXISTS federated.t0; |
| 66 |
DROP DATABASE realdb; |
| 67 |
SET SESSION information_schema_stats_expiry=default; |
| 68 |
DROP TABLE IF EXISTS federated.t1; |
| 69 |
DROP DATABASE federated; |
| 70 |
DROP TABLE IF EXISTS federated.t1; |
| 71 |
DROP DATABASE federated; |