Commit 69d700ac authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-5871 support assisted discovery in oqgraph v3

parent 2ef0312c
...@@ -195,6 +195,41 @@ static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table, ...@@ -195,6 +195,41 @@ static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table,
return new (mem_root) ha_oqgraph(hton, table); 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 #if MYSQL_VERSION_ID >= 50100
static int oqgraph_init(handlerton *hton) static int oqgraph_init(handlerton *hton)
{ {
...@@ -219,6 +254,8 @@ static bool oqgraph_init() ...@@ -219,6 +254,8 @@ static bool oqgraph_init()
// HTON_NO_FLAGS; // HTON_NO_FLAGS;
hton->table_options= (ha_create_table_option*)oqgraph_table_option_list; hton->table_options= (ha_create_table_option*)oqgraph_table_option_list;
hton->discover_table_structure= oqgraph_discover_table_structure;
oqgraph_init_done= TRUE; oqgraph_init_done= TRUE;
return 0; return 0;
} }
......
...@@ -8,16 +8,7 @@ to_id INT UNSIGNED NOT NULL, ...@@ -8,16 +8,7 @@ to_id INT UNSIGNED NOT NULL,
PRIMARY KEY (from_id,to_id), PRIMARY KEY (from_id,to_id),
INDEX (to_id) INDEX (to_id)
) ENGINE= Aria ; ) ENGINE= Aria ;
CREATE TABLE graph ( CREATE TABLE graph ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
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';
select * from graph; select * from graph;
latch origid destid weight seq linkid latch origid destid weight seq linkid
INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1); INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1);
......
...@@ -8,16 +8,7 @@ to_id INT UNSIGNED NOT NULL, ...@@ -8,16 +8,7 @@ to_id INT UNSIGNED NOT NULL,
PRIMARY KEY (from_id,to_id), PRIMARY KEY (from_id,to_id),
INDEX (to_id) INDEX (to_id)
) ENGINE= MyISAM ; ) ENGINE= MyISAM ;
CREATE TABLE graph ( CREATE TABLE graph ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
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';
select * from graph; select * from graph;
latch origid destid weight seq linkid latch origid destid weight seq linkid
INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1); INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1);
......
...@@ -8,16 +8,7 @@ to_id INT UNSIGNED NOT NULL, ...@@ -8,16 +8,7 @@ to_id INT UNSIGNED NOT NULL,
PRIMARY KEY (from_id,to_id), PRIMARY KEY (from_id,to_id),
INDEX (to_id) INDEX (to_id)
) ENGINE= innodb ; ) ENGINE= innodb ;
CREATE TABLE graph ( CREATE TABLE graph ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
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';
select * from graph; select * from graph;
latch origid destid weight seq linkid latch origid destid weight seq linkid
INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1); INSERT INTO graph_base(from_id, to_id) VALUES (1,2), (2,1);
......
...@@ -15,16 +15,7 @@ eval CREATE TABLE graph_base ( ...@@ -15,16 +15,7 @@ eval CREATE TABLE graph_base (
) ENGINE= $oqgraph_use_table_type ; ) ENGINE= $oqgraph_use_table_type ;
CREATE TABLE graph ( CREATE TABLE graph ENGINE=OQGRAPH DATA_TABLE='graph_base' ORIGID='from_id', DESTID='to_id';
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';
# Regression for MDEV-5891 # Regression for MDEV-5891
select * from graph; select * from graph;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment