import java.sql.SQLException;

public class Bug11781 extends testsuite.BaseTestCase
{
   public Bug11781(String name)
   {
      super(name);
   }

   public void setUp() throws Exception
   {
      super.setUp();
      stmt.executeUpdate("drop table if exists `app tab`");   
      stmt.executeUpdate("CREATE TABLE `app tab`( C1 int(11) NULL, INDEX NEWINX (C1), INDEX NEWINX2 (C1)) ENGINE = InnoDB CHECKSUM = 0 COMMENT = 'InnoDB free: 3072 kB; (`C1`) REFER`test/app tab`(`C1`)' PACK_KEYS = 0");
      stmt.executeUpdate("ALTER TABLE `app tab` ADD CONSTRAINT APPFK FOREIGN KEY (C1) REFERENCES `app tab` (C1)");
   }

    public void tearDown() throws Exception {

     stmt.executeUpdate("drop table if exists `app tab`");   
     super.tearDown();

    }

   public void testMetadataBug11781() throws SQLException
   {
     com.mysql.jdbc.DatabaseMetaData md = null;
     md = (com.mysql.jdbc.DatabaseMetaData)conn.getMetaData();
     rs = md.extractForeignKeyFromCreateTable(conn,md,"test","app tab");
     assertTrue("must return a row",rs.next()) ;
     System.out.println(rs.getString(1));  
     System.out.println(rs.getString(2));  
     System.out.println(rs.getString(3));  

   }

   public static void  main(String args[]) throws Exception
   {
      junit.textui.TestRunner.run(Bug11781.class);      
   }

}


