=== modified file 'storage/oqgraph/ha_oqgraph.cc'
--- storage/oqgraph/ha_oqgraph.cc	2014-05-09 10:35:11 +0000
+++ storage/oqgraph/ha_oqgraph.cc	2014-06-20 18:07:06 +0000
@@ -124,7 +124,8 @@ const char *oqlatchToCode(int latch) {
   return "unknown";
 }
 
-struct oqgraph_table_option_struct
+
+struct ha_table_option_struct
 {
   const char *table_name;
 
@@ -133,7 +134,6 @@ struct oqgraph_table_option_struct
   const char *weight; // name of the weight column (optional)
 };
 
-#define ha_table_option_struct oqgraph_table_option_struct
 static const ha_create_table_option oqgraph_table_option_list[]=
 {
   HA_TOPTION_STRING("data_table", table_name),
@@ -193,6 +193,41 @@ static handler* oqgraph_create_handler(h
   return new (mem_root) ha_oqgraph(hton, table);
 }
 
+#define OQGRAPH_CREATE_TABLE                              \
+"         CREATE TABLE oq_graph (                        "\
+"           latch VARCHAR(32) NULL,                      "\
+"           origid BIGINT UNSIGNED NULL,                 "\
+"           destid BIGINT UNSIGNED NULL,                 "\
+"           weight DOUBLE NULL,                          "\
+"           seq BIGINT UNSIGNED NULL,                    "\
+"           linkid BIGINT UNSIGNED NULL,                 "\
+"           KEY (latch, origid, destid) USING HASH,      "\
+"           KEY (latch, destid, origid) USING HASH       "\
+"         )                                              " 
+
+#define append_opt(NAME,VAL)                                    \
+  if (share->option_struct->VAL)                                \
+  {                                                             \
+    sql.append(STRING_WITH_LEN(" " NAME "='"));                  \
+    sql.append_for_single_quote(share->option_struct->VAL);     \
+    sql.append('\'');                                           \
+  }
+
+int oqgraph_discover_table_structure(handlerton *hton, THD* thd,
+                                     TABLE_SHARE *share, HA_CREATE_INFO *info)
+{
+  StringBuffer<1024> sql(system_charset_info);
+  sql.copy(STRING_WITH_LEN(OQGRAPH_CREATE_TABLE), system_charset_info);
+
+  append_opt("data_table", table_name);
+  append_opt("origid", origid);
+  append_opt("destid", destid);
+  append_opt("weight", weight);
+
+  return 
+    share->init_from_sql_statement_string(thd, true, sql.ptr(), sql.length());
+}
+
 #if MYSQL_VERSION_ID >= 50100
 static int oqgraph_init(handlerton *hton)
 {
@@ -217,6 +252,8 @@ static bool oqgraph_init()
   // HTON_NO_FLAGS;
   
   hton->table_options= (ha_create_table_option*)oqgraph_table_option_list;
+
+  hton->discover_table_structure= oqgraph_discover_table_structure;
   oqgraph_init_done= TRUE;
   return 0;
 }
@@ -509,8 +546,7 @@ int ha_oqgraph::open(const char *name, i
   DBUG_ASSERT(graph == NULL);
 
   THD* thd = current_thd;
-  oqgraph_table_option_struct *options=
-    reinterpret_cast<oqgraph_table_option_struct*>(table->s->option_struct);
+  ha_table_option_struct *options= table->s->option_struct;
 
   // Catch cases where table was not constructed properly
   // Note - need to return -1 so our error text gets reported
@@ -1271,8 +1307,7 @@ ha_rows ha_oqgraph::records_in_range(uin
 int ha_oqgraph::create(const char *name, TABLE *table_arg,
 		    HA_CREATE_INFO *create_info)
 {
-  oqgraph_table_option_struct *options=
-    reinterpret_cast<oqgraph_table_option_struct*>(table_arg->s->option_struct);
+  ha_table_option_struct *options= table_arg->s->option_struct;
 
 	DBUG_ENTER("ha_oqgraph::create");
   DBUG_PRINT( "oq-debug", ("create(name=%s)", name));

=== modified file 'storage/oqgraph/mysql-test/oqgraph/general-innodb.result'
--- storage/oqgraph/mysql-test/oqgraph/general-innodb.result	2014-04-02 12:36:35 +0000
+++ storage/oqgraph/mysql-test/oqgraph/general-innodb.result	2014-06-20 18:07:50 +0000
@@ -8,16 +8,7 @@ to_id INT UNSIGNED NOT NULL,
 PRIMARY KEY (from_id,to_id),
 INDEX (to_id)
 ) ENGINE= innodb ;
-CREATE TABLE graph (
-latch   VARCHAR(32) NULL,
-origid  BIGINT    UNSIGNED NULL,
-destid  BIGINT    UNSIGNED NULL,
-weight  DOUBLE    NULL,
-seq     BIGINT    UNSIGNED NULL,
-linkid  BIGINT    UNSIGNED NULL,
-KEY (latch, origid, destid) USING HASH,
-KEY (latch, destid, origid) USING HASH
-) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
+CREATE TABLE graph ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
 select * from graph;
 latch	origid	destid	weight	seq	linkid
 INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1);

=== modified file 'storage/oqgraph/mysql-test/oqgraph/general.inc'
--- storage/oqgraph/mysql-test/oqgraph/general.inc	2014-04-02 12:36:05 +0000
+++ storage/oqgraph/mysql-test/oqgraph/general.inc	2014-06-20 17:57:07 +0000
@@ -15,16 +15,7 @@ eval CREATE TABLE graph_base (
   ) ENGINE= $oqgraph_use_table_type ;
 
 
-CREATE TABLE graph (
-    latch   VARCHAR(32) NULL,
-    origid  BIGINT    UNSIGNED NULL,
-    destid  BIGINT    UNSIGNED NULL,
-    weight  DOUBLE    NULL,
-    seq     BIGINT    UNSIGNED NULL,
-    linkid  BIGINT    UNSIGNED NULL,
-    KEY (latch, origid, destid) USING HASH,
-    KEY (latch, destid, origid) USING HASH
-  ) ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
+CREATE TABLE graph ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
 
 # Regression for MDEV-5891
 select * from graph;

