diff options
author | Sergei Golubchik <serg@mariadb.org> | 2014-11-26 20:34:40 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2014-12-04 10:41:52 +0100 |
commit | 69d700ace31887714be026b7c1526ee7832fba94 (patch) | |
tree | 86afaece09a37e624d1b6e1339b1e29c4ff38951 /storage/oqgraph | |
parent | 2ef0312cd97a6cd6973a3e1221c127adf669bd72 (diff) | |
download | mariadb-git-69d700ace31887714be026b7c1526ee7832fba94.tar.gz |
MDEV-5871 support assisted discovery in oqgraph v3
Diffstat (limited to 'storage/oqgraph')
-rw-r--r-- | storage/oqgraph/ha_oqgraph.cc | 37 | ||||
-rw-r--r-- | storage/oqgraph/mysql-test/oqgraph/general-Aria.result | 11 | ||||
-rw-r--r-- | storage/oqgraph/mysql-test/oqgraph/general-MyISAM.result | 11 | ||||
-rw-r--r-- | storage/oqgraph/mysql-test/oqgraph/general-innodb.result | 11 | ||||
-rw-r--r-- | storage/oqgraph/mysql-test/oqgraph/general.inc | 11 |
5 files changed, 41 insertions, 40 deletions
diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index 9e93f2094ca..b81ca3d2210 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -195,6 +195,41 @@ static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *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 static int oqgraph_init(handlerton *hton) { @@ -219,6 +254,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; } diff --git a/storage/oqgraph/mysql-test/oqgraph/general-Aria.result b/storage/oqgraph/mysql-test/oqgraph/general-Aria.result index f0c5b51a266..a35b5182611 100644 --- a/storage/oqgraph/mysql-test/oqgraph/general-Aria.result +++ b/storage/oqgraph/mysql-test/oqgraph/general-Aria.result @@ -8,16 +8,7 @@ to_id INT UNSIGNED NOT NULL, PRIMARY KEY (from_id,to_id), INDEX (to_id) ) ENGINE= Aria ; -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); diff --git a/storage/oqgraph/mysql-test/oqgraph/general-MyISAM.result b/storage/oqgraph/mysql-test/oqgraph/general-MyISAM.result index c08e0c295d2..f12e160a2b7 100644 --- a/storage/oqgraph/mysql-test/oqgraph/general-MyISAM.result +++ b/storage/oqgraph/mysql-test/oqgraph/general-MyISAM.result @@ -8,16 +8,7 @@ to_id INT UNSIGNED NOT NULL, PRIMARY KEY (from_id,to_id), INDEX (to_id) ) ENGINE= MyISAM ; -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); diff --git a/storage/oqgraph/mysql-test/oqgraph/general-innodb.result b/storage/oqgraph/mysql-test/oqgraph/general-innodb.result index cf9c83144b8..b390dd38e34 100644 --- a/storage/oqgraph/mysql-test/oqgraph/general-innodb.result +++ b/storage/oqgraph/mysql-test/oqgraph/general-innodb.result @@ -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); diff --git a/storage/oqgraph/mysql-test/oqgraph/general.inc b/storage/oqgraph/mysql-test/oqgraph/general.inc index 7c49c72b4de..357a8c786ee 100644 --- a/storage/oqgraph/mysql-test/oqgraph/general.inc +++ b/storage/oqgraph/mysql-test/oqgraph/general.inc @@ -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; |