Don’t Forget to Alter your Federated Tables!

May 5, 2009 · Posted in MySQL 

If you’re using the Federated engine, here’s something important to remember (apart from the usual advice of “please don’t”). If you need to change the structure of the remote table, always remember to update the Federated table. If not, when you try to use the table, you’ll get this error:

mysql> SELECT * FROM foo;
ERROR 1030 (HY000): Got error 1 from storage engine

This error isn’t really helpful. The problem is, the Federated engine only checks that the remote table structure is correct when it initially connects. Once it has connected, no more checks. When you restart the server, you get a much more helpful message:

mysql SELECT * FROM foo;
ERROR 1431 (HY000): The foreign data source you are trying to reference does not exist. Data source error:  error: 1054  'Unknown column 'b' in 'field list''

Also, keep your eye on the FederatedX project. It’s still under development, but will hopefully upgrade the Federated engine to being useful again.

  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • Reddit
  • Slashdot
  • Technorati
  • TwitThis

Comments

One Response to “Don’t Forget to Alter your Federated Tables!”

  1. CaptTofu on May 7th, 2009 3:30 pm

    In 5.1, you can use a federated server to do this:

    create server ’server_one’ foreign data wrapper ‘mysql’ options
    (HOST ‘127.0.0.1′,
    DATABASE ‘first_db’,
    USER ‘root’,
    PASSWORD ”,
    PORT 3306,
    SOCKET ”,
    OWNER ‘root’);

    CREATE TABLE t1 (
    `id` int(20) NOT NULL,
    `name` varchar(64) NOT NULL default ”
    )
    ENGINE=”FEDERATED” DEFAULT CHARSET=latin1
    CONNECTION=’server_one’;

    then, change what t1 connects to by:

    ALTER SERVER ’server_one’ options(DATABASE ’second_db’);

    This makes it so you don’t have to alter the table t1, so if you have 100s of tables pointing to a given server/database, you just have to change the server and not all 100 tables !

    Yes, I will be improving federatedx ;)

Leave a Reply




  • Gary Pendergast, noun: Gamer, developer, MySQL, WordPress, web and music geek. Currently taking a leave of absence from life as a MySQL Support Engineer for Oracle to tour around Europe. Can be observed in his natural habit at pento.net, or usually in Bologna, Italy.

  • My Twitter

    • Somewhat surprised at the number of #WordPress sites I see using "ugly" urls, /?page_id=555 14 hrs ago
    • Learned something today: .it domains need 1-2 days to change DNS servers, I guess the registry approves these changes manually. Oh, Italy. 1 day ago
    • SVN commit message to make me drop everything and run `svn up`: "Fix typo making all users admins" 1 day ago
    • Huh, #Filezilla owns #WinSCP for uploading large numbers of small files. 1 day ago
    • @assembla Using Google Code at the moment. Any advantage to using Assembla for an OSS project? in reply to assembla 2 days ago
    • More updates...