From 1973c009701f8b26eb3f1b40efa5bc2ee163ca34 Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Sun, 22 Jun 2014 19:59:42 +0930 Subject: [PATCH 01/14] Update 2014 (C) message --- storage/oqgraph/ha_oqgraph.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index 4411421c6698d..c68eeddb5ea6f 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -1,4 +1,5 @@ -/* Copyright (C) 2007-2013 Arjen G Lentz & Antony T Curtis for Open Query +/* Copyright (C) 2007-2014 Arjen G Lentz & Antony T Curtis for Open Query + Copyright (C) 2013-2014 Andrew McDonnell Portions of this file copyright (C) 2000-2006 MySQL AB This program is free software; you can redistribute it and/or modify From 826141368c83fe9e6cbda4c69f937ae1e526effd Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Sun, 15 Jun 2014 21:39:23 +0930 Subject: [PATCH 02/14] Added regression test for MDEV-6282 --- .../oqgraph/regression_mdev6282.result | 37 +++++++++++++++ .../oqgraph/regression_mdev6282.test | 47 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 storage/oqgraph/mysql-test/oqgraph/regression_mdev6282.result create mode 100644 storage/oqgraph/mysql-test/oqgraph/regression_mdev6282.test diff --git a/storage/oqgraph/mysql-test/oqgraph/regression_mdev6282.result b/storage/oqgraph/mysql-test/oqgraph/regression_mdev6282.result new file mode 100644 index 0000000000000..42c8640550366 --- /dev/null +++ b/storage/oqgraph/mysql-test/oqgraph/regression_mdev6282.result @@ -0,0 +1,37 @@ +CREATE TABLE `db_history` ( +`version` VARCHAR(10) NOT NULL, +`updateJSON` MEDIUMTEXT, +`prevVersion` VARCHAR(10) NOT NULL, +`nodeID` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0', +`prevNodeID` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0', +PRIMARY KEY (`prevNodeID`,`nodeID`), +KEY `version` (`version`) USING BTREE, +KEY `prevVersion` (`prevVersion`) USING BTREE, +KEY `nodeID` (`nodeID`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +INSERT INTO `db_history` VALUES +('0.0.1','{}','0.0.0',1,0), +('0.0.2','{\"data\":{\"add\":{},\"update\":{},\"delete\":{}}}','0.0.1',2,1), +('0.0.3','{\"data\":{\"add\":{},\"update\":{},\"delete\":{}}}','0.0.2',3,2); +CREATE TABLE IF NOT EXISTS version_history ( +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='db_history' ORIGID='prevNodeID' DESTID='nodeID'; +SELECT `db`.`version`, `db`.`nodeID` +FROM `version_history` AS `v` INNER JOIN `db_history` AS `db` ON `db`.`nodeID` = `v`.`linkid` +WHERE `latch` = 'breadth_first' AND `origid` = '1' ORDER BY `weight` DESC LIMIT 1; +version nodeID +0.0.3 3 +SELECT `db`.`version`, `db`.`nodeID` +FROM `version_history` AS `v` INNER JOIN `db_history` AS `db` ON `db`.`nodeID` = `v`.`linkid` +WHERE `latch` = 'breadth_first' AND `origid` = '1' ORDER BY `weight` DESC LIMIT 1; +version nodeID +0.0.3 3 +DROP TABLE db_history; +DROP TABLE version_history; diff --git a/storage/oqgraph/mysql-test/oqgraph/regression_mdev6282.test b/storage/oqgraph/mysql-test/oqgraph/regression_mdev6282.test new file mode 100644 index 0000000000000..3a7a0e5af08d7 --- /dev/null +++ b/storage/oqgraph/mysql-test/oqgraph/regression_mdev6282.test @@ -0,0 +1,47 @@ +--connect (con1,localhost,root,,test) + + CREATE TABLE `db_history` ( + `version` VARCHAR(10) NOT NULL, + `updateJSON` MEDIUMTEXT, + `prevVersion` VARCHAR(10) NOT NULL, + `nodeID` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0', + `prevNodeID` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0', + PRIMARY KEY (`prevNodeID`,`nodeID`), + KEY `version` (`version`) USING BTREE, + KEY `prevVersion` (`prevVersion`) USING BTREE, + KEY `nodeID` (`nodeID`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8; + + INSERT INTO `db_history` VALUES + ('0.0.1','{}','0.0.0',1,0), + ('0.0.2','{\"data\":{\"add\":{},\"update\":{},\"delete\":{}}}','0.0.1',2,1), + ('0.0.3','{\"data\":{\"add\":{},\"update\":{},\"delete\":{}}}','0.0.2',3,2); + + CREATE TABLE IF NOT EXISTS version_history ( + 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='db_history' ORIGID='prevNodeID' DESTID='nodeID'; + + SELECT `db`.`version`, `db`.`nodeID` + FROM `version_history` AS `v` INNER JOIN `db_history` AS `db` ON `db`.`nodeID` = `v`.`linkid` + WHERE `latch` = 'breadth_first' AND `origid` = '1' ORDER BY `weight` DESC LIMIT 1; +--disconnect con1 + +--connect (con2,localhost,root,,test) + SELECT `db`.`version`, `db`.`nodeID` + FROM `version_history` AS `v` INNER JOIN `db_history` AS `db` ON `db`.`nodeID` = `v`.`linkid` + WHERE `latch` = 'breadth_first' AND `origid` = '1' ORDER BY `weight` DESC LIMIT 1; +--disconnect con2 + +--connect (con3,localhost,root,,test) +DROP TABLE db_history; +DROP TABLE version_history; +--disconnect con3 + + From abf1e259f6e8e023c3b0baf14602074c5d195353 Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Sat, 25 Oct 2014 20:00:41 +1030 Subject: [PATCH 03/14] Partial whitespace cleanup. Conflicts: storage/oqgraph/ha_oqgraph.cc Conflicts: storage/oqgraph/ha_oqgraph.cc --- storage/oqgraph/ha_oqgraph.cc | 142 +++++++++++++++++----------------- 1 file changed, 69 insertions(+), 73 deletions(-) diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index c68eeddb5ea6f..969f1c99837f9 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -24,12 +24,12 @@ */ #ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation // gcc: Class implementation +#pragma implementation // gcc: Class implementation #endif #include +#define MYSQL_SERVER 1 // to have THD -#define MYSQL_SERVER // to have THD #include #include "sql_class.h" @@ -41,12 +41,12 @@ #include "graphcore.h" #include -#if MYSQL_VERSION_ID >= 100004 +#if MYSQL_VERSION_ID >= 100004 // Interim workaround for rename in sql_error.h from this point #define MYSQL_ERROR Sql_condition #endif -#if MYSQL_VERSION_ID < 100000 +#if MYSQL_VERSION_ID < 100000 // Allow compatibility with build for 5.5.32 #define user_defined_key_parts key_parts #define open_table_error(a,b,c) open_table_error(a,b,c,0) @@ -84,8 +84,8 @@ using namespace open_query; #ifdef RETAIN_INT_LATCH_COMPATIBILITY /* In normal operation, no new tables using an integer latch can be created, * but they can still be used if they already exist, to allow for upgrades. - * - * However to ensure the legacy function is properly tested, we add a + * + * However to ensure the legacy function is properly tested, we add a * server variable "oggraph_allow_create_integer_latch" which if set to TRUE * allows new engine tables to be created with integer latches. */ @@ -103,8 +103,8 @@ struct oqgraph_latch_op_table { const char *key; int latch; }; static const oqgraph_latch_op_table latch_ops_table[] = { { "", oqgraph::NO_SEARCH } , // suggested by Arjen, use empty string instead of no_search { "dijkstras", oqgraph::DIJKSTRAS } , - { "breadth_first", oqgraph::BREADTH_FIRST } , - { NULL, -1 } + { "breadth_first", oqgraph::BREADTH_FIRST } , + { NULL, -1 } }; static uint32 findLongestLatch() { @@ -216,9 +216,9 @@ static bool oqgraph_init() hton->flags= HTON_ALTER_NOT_SUPPORTED; // Prevent ALTER, because the core crashes when the user provides a // non-existing backing store field for ORIGID, etc - // 'Fixes' bug 1134355 + // 'Fixes' bug 1134355 // HTON_NO_FLAGS; - + hton->table_options= (ha_create_table_option*)oqgraph_table_option_list; oqgraph_init_done= TRUE; return 0; @@ -268,10 +268,10 @@ static int error_code(int res) * linkid BIGINT UNSIGNED NULL * ================================= * - + The latch may be a varchar of any length, however if it is too short to hold the longest latch value, table creation is aborted. - + CREATE TABLE foo ( latch VARCHAR(32) NULL, origid BIGINT UNSIGNED NULL, @@ -293,12 +293,12 @@ static int error_code(int res) integer and change behaviour accordingly. Note that if a table was constructed with varchar and an attempt is made to select with latch=(some integer number) then MYSQL will autocast - and no data will be returned... so retaining compatibility does not and cannot + and no data will be returned... so retaining compatibility does not and cannot extend to making old queries work with new style tables. This method is only called on table creation, so here we ensure new tables can only be created with varchar. - + This does present a small problem with regression testing; so we work around that by using an system variable to allow integer latch tables to be created. @@ -336,11 +336,11 @@ int ha_oqgraph::oqgraph_check_table_structure (TABLE *table_arg) DBUG_PRINT( "oq-debug", ("Allowing integer latch anyway!")); isStringLatch = false; /* Make a warning */ - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DEPRECATED_SYNTAX, ER(ER_WARN_DEPRECATED_SYNTAX), "latch SMALLINT UNSIGNED NULL", "'latch VARCHAR(32) NULL'"); } else -#endif +#endif if (isLatchColumn && ((*field)->type() == MYSQL_TYPE_SHORT)) { DBUG_PRINT( "oq-debug", ("Allowing integer no more!")); @@ -352,7 +352,7 @@ int ha_oqgraph::oqgraph_check_table_structure (TABLE *table_arg) badColumn = true; push_warning_printf( current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Column %d is wrong type.", i); } - + // Make sure latch column is large enough for all possible latch values if (isLatchColumn && isStringLatch) { if ((*field)->char_length() < findLongestLatch()) { @@ -498,7 +498,7 @@ void ha_oqgraph::fprint_error(const char* fmt, ...) * * An OQGRAPH table is effectively similar to a view over the underlying backing table, * attribute 'data_table', but where the result returned by a query depends on the - * value of the 'latch' column specified to the query. Therefore, + * value of the 'latch' column specified to the query. Therefore, * when mysqld opens us, we need to open the corresponding backing table 'data_table' * */ @@ -553,7 +553,7 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) // * plen seems to be then set to length of `database_blah/options_data_table_name` // * then we set share->normalized_path.str and share->path.str to `database_blah/options_data_table_name` // * I assume that this verbiage is needed so the memory used by share->path.str is set in the share mem root - // * because otherwise one could simply build the string more simply using malloc and pass it instead of "" above + // * because otherwise one could simply build the string more simply using malloc and pass it instead of "" above const char* p= strend(name)-1; while (p > name && *p != '\\' && *p != '/') --p; @@ -568,11 +568,11 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) share->normalized_path.str= share->path.str; share->path.length= share->normalized_path.length= plen; - DBUG_PRINT( "oq-debug", ("share:(normalized_path=%s,path.length=%zu)", + DBUG_PRINT( "oq-debug", ("share:(normalized_path=%s,path.length=%zu)", share->normalized_path.str, share->path.length)); int open_def_flags = 0; -#if MYSQL_VERSION_ID >= 100002 +#if MYSQL_VERSION_ID>= 100002 open_def_flags = GTS_TABLE; #endif // We want to open the definition for the given backing table @@ -584,7 +584,7 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) // Lets try without this, and see if all the tests pass... while (open_table_def(thd, share, open_def_flags)) { -#if MYSQL_VERSION_ID < 100002 +#if MYSQL_VERSION_ID < 100002 if (thd->is_error() && thd->stmt_da->sql_errno() != ER_NO_SUCH_TABLE) { free_table_share(share); @@ -602,7 +602,7 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) #else open_table_error(share, OPEN_FRM_OPEN_ERROR, ENOENT); free_table_share(share); - if (thd->is_error()) + if (thd->is_error()) DBUG_RETURN(thd->get_stmt_da()->sql_errno()); DBUG_RETURN(HA_ERR_NO_SUCH_TABLE); #endif @@ -703,7 +703,7 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) free_table_share(share); DBUG_RETURN(-1); } - + // Make sure origid column != destid column if (strcmp( origid->field_name, destid->field_name)==0) { fprint_error("Invalid OQGRAPH backing store ('%s.destid' attribute set to same column as origid attribute)", p+1, options->table_name); @@ -809,8 +809,7 @@ int ha_oqgraph::delete_row(const byte * buf) return HA_ERR_TABLE_READONLY; } -int ha_oqgraph::index_read(byte * buf, const byte * key, uint key_len, - enum ha_rkey_function find_flag) +int ha_oqgraph::index_read(byte * buf, const byte * key, uint key_len, enum ha_rkey_function find_flag) { DBUG_ASSERT(inited==INDEX); // reset before we have a cursor, so the memory is not junk, avoiding the sefgault in position() when select with order by (bug #1133093) @@ -833,7 +832,7 @@ int ha_oqgraph::index_next_same(byte *buf, const byte *key, uint key_len) #define LATCH_WAS_NUMBER 1 /** - * This function parse the VARCHAR(n) latch specification into an integer operation specification compatible with + * This function parse the VARCHAR(n) latch specification into an integer operation specification compatible with * v1-v3 oqgraph::search(). * * If the string contains a number, this is directly converted from a decimal integer. @@ -844,19 +843,19 @@ int ha_oqgraph::index_next_same(byte *buf, const byte *key, uint key_len) * * FIXME: For the time being, only handles latin1 character set. * @return false if parsing fails. - */ + */ static int parse_latch_string_to_legacy_int(const String& value, int &latch) { // Attempt to parse as exactly an integer first. - + // Note: we are strict about not having whitespace, or garbage characters, - // so that the query result gets returned properly: + // so that the query result gets returned properly: // Because of the way the result is built and used in fill_result, // we have to exactly return in the latch column what was in the latch= clause // otherwise the rows get filtered out by the query optimiser. - + // For the same reason, we cant simply treat latch='' as NO_SEARCH either. - + String latchValue = value; char *eptr; unsigned long int v = strtoul( latchValue.c_ptr_safe(), &eptr, 10); @@ -866,7 +865,7 @@ static int parse_latch_string_to_legacy_int(const String& value, int &latch) latch = v; return true; } - // fall through and test as a string (although it is unlikely we might have an operator starting with a number) + // fall through and test as a string (although it is unlikely we might have an operator starting with a number) } const oqgraph_latch_op_table* entry = latch_ops_table; @@ -880,7 +879,7 @@ static int parse_latch_string_to_legacy_int(const String& value, int &latch) } int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key, - uint key_len, enum ha_rkey_function find_flag) + uint key_len, enum ha_rkey_function find_flag) { Field **field= table->field; KEY *key_info= table->key_info + index; @@ -910,7 +909,7 @@ int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key, #ifdef RETAIN_INT_LATCH_COMPATIBILITY if (field[0]->type() == MYSQL_TYPE_SHORT) { latch= (int) field[0]->val_int(); - } else + } else #endif { field[0]->val_str(&latchFieldValue, &latchFieldValue); @@ -918,13 +917,13 @@ int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key, // Invalid, so warn & fail push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WRONG_ARGUMENTS, ER(ER_WRONG_ARGUMENTS), "OQGRAPH latch"); table->status = STATUS_NOT_FOUND; - if (ptrdiff) /* fixes debug build assert - should be a tidier way to do this */ - { - field[0]->move_field_offset(-ptrdiff); - field[1]->move_field_offset(-ptrdiff); - field[2]->move_field_offset(-ptrdiff); - } - dbug_tmp_restore_column_map(table->read_set, old_map); + if (ptrdiff) /* fixes debug build assert - should be a tidier way to do this */ + { + field[0]->move_field_offset(-ptrdiff); + field[1]->move_field_offset(-ptrdiff); + field[2]->move_field_offset(-ptrdiff); + } + dbug_tmp_restore_column_map(table->read_set, old_map); return error_code(oqgraph::NO_MORE_DATA); } } @@ -961,11 +960,11 @@ int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key, graph->retainLatchFieldValue(latchFieldValue.c_ptr_safe()); else graph->retainLatchFieldValue(NULL); - - - DBUG_PRINT( "oq-debug", ("index_read_idx ::>> search(latch:%s,%ld,%ld)", + + + DBUG_PRINT( "oq-debug", ("index_read_idx ::>> search(latch:%s,%ld,%ld)", oqlatchToCode(latch), orig_idp?(long)*orig_idp:-1, dest_idp?(long)*dest_idp:-1)); - + res= graph->search(latchp, orig_idp, dest_idp); DBUG_PRINT( "oq-debug", ("search() = %d", res)); @@ -996,7 +995,7 @@ int ha_oqgraph::fill_record(byte *record, const open_query::row &row) field[5]->move_field_offset(ptrdiff); } - DBUG_PRINT( "oq-debug", ("fill_record() ::>> %s,%ld,%ld,%lf,%ld,%ld", + DBUG_PRINT( "oq-debug", ("fill_record() ::>> %s,%ld,%ld,%lf,%ld,%ld", row.latch_indicator ? oqlatchToCode((int)row.latch) : "-", row.orig_indicator ? (long)row.orig : -1, row.dest_indicator ? (long)row.dest : -1, @@ -1014,10 +1013,10 @@ int ha_oqgraph::fill_record(byte *record, const open_query::row &row) } #ifdef RETAIN_INT_LATCH_COMPATIBILITY else if (field[0]->type() == MYSQL_TYPE_SHORT) { - field[0]->store((longlong) row.latch, 0); + field[0]->store((longlong) row.latch, 0); } #endif - + } if (row.orig_indicator) @@ -1094,7 +1093,7 @@ int ha_oqgraph::rnd_pos(byte * buf, byte *pos) void ha_oqgraph::position(const byte *record) { - graph->row_ref((void*) ref); // Ref is aligned + graph->row_ref((void*) ref); // Ref is aligned } int ha_oqgraph::cmp_ref(const byte *ref1, const byte *ref2) @@ -1141,9 +1140,7 @@ int ha_oqgraph::external_lock(THD *thd, int lock_type) } -THR_LOCK_DATA **ha_oqgraph::store_lock(THD *thd, - THR_LOCK_DATA **to, - enum thr_lock_type lock_type) +THR_LOCK_DATA **ha_oqgraph::store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type) { return edges->file->store_lock(thd, to, lock_type); } @@ -1168,10 +1165,10 @@ ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key, key_range *max_key) { KEY *key=table->key_info+inx; -#ifdef VERBOSE_DEBUG +#ifdef VERBOSE_DEBUG { String temp; - key->key_part[0].field->val_str(&temp); + key->key_part[0].field->val_str(&temp); temp.c_ptr_safe(); DBUG_PRINT( "oq-debug", ("records_in_range ::>> inx=%u", inx)); DBUG_PRINT( "oq-debug", ("records_in_range ::>> key0=%s.", temp.c_ptr())); // for some reason when I had ...inx=%u key=%s", inx, temp.c_ptr_safe()) it printed nothing ... @@ -1186,28 +1183,28 @@ ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key, { if (min_key->length == key->key_part[0].store_length && !key->key_part[0].field->is_null()) /* ensure select * from x where latch is null is consistent with no latch */ { - // If latch is not null and equals 0, return # nodes - + // If latch is not null and equals 0, return # nodes + // How to decode the key, For VARCHAR(32), from empirical observation using the debugger // and information gleaned from: // http://grokbase.com/t/mysql/internals/095h6ch1q7/parsing-key-information // http://dev.mysql.com/doc/internals/en/support-for-indexing.html#parsing-key-information // comments in opt_range.cc // POSSIBLY ONLY VALID FOR INNODB! - + // For a the following query: // SELECT * FROM graph2 WHERE latch = 'breadth_first' AND origid = 123 AND weight = 1; // key->key_part[0].field->ptr is the value of latch, which is a 1-byte string length followed by the value ('breadth_first') // key->key_part[2].field->ptr is the value of origid (123) // key->key_part[1].field->ptr is the value of destid which is not specified in the query so we ignore it in this case // so given this ordering we seem to be using the second key specified in create table (aka KEY (latch, destid, origid) USING HASH )) - + // min_key->key[0] is the 'null' bit and contains 0 in this instance // min_key->key[1..2] seems to be 16-bit string length // min_key->key[3..34] hold the varchar(32) value which is that specified in the query // min_key->key[35] is the null bit of origid // min_key->key[36..43] is the value in the query (123) - + // max_key->key[0] is the ;null' bit and contains 0 in this instance // max_key->key[1..2] seems to be 16-bit string length // max_key->key[3..34] hold the varchar(32) value which is that specified in the query @@ -1215,9 +1212,9 @@ ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key, // max_key->key[36..43] is the value in the query (123) // But after knowing all that, all we care about is the latch value - + // First draft - ignore most of the stuff, but will likely break if query altered - + // It turns out there is a better way though, to access the string, // as demonstrated in key_unpack() of sql/key.cc String latchCode; @@ -1225,12 +1222,12 @@ ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key, if (key->key_part[0].field->type() == MYSQL_TYPE_VARCHAR) { key->key_part[0].field->val_str(&latchCode); - + parse_latch_string_to_legacy_int( latchCode, latch); } - + // what if someone did something dumb, like mismatching the latches? - + #ifdef RETAIN_INT_LATCH_COMPATIBILITY else if (key->key_part[0].field->type() == MYSQL_TYPE_SHORT) { // If not null, and zero ... @@ -1243,17 +1240,17 @@ ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key, latch = oqgraph::NO_SEARCH; } } -#endif +#endif if (latch != oqgraph::NO_SEARCH) { - // Invalid key type... + // Invalid key type... // Don't assert, in case the user used alter table on us - return HA_POS_ERROR; // Can only use exact keys + return HA_POS_ERROR; // Can only use exact keys } unsigned N = graph->vertices_count(); DBUG_PRINT( "oq-debug", ("records_in_range ::>> N=%u (vertices)", N)); return N; } - return HA_POS_ERROR; // Can only use exact keys + return HA_POS_ERROR; // Can only use exact keys } if (stats.records <= 1) { @@ -1271,13 +1268,12 @@ ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key, } -int ha_oqgraph::create(const char *name, TABLE *table_arg, - HA_CREATE_INFO *create_info) +int ha_oqgraph::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info) { oqgraph_table_option_struct *options= reinterpret_cast(table_arg->s->option_struct); - DBUG_ENTER("ha_oqgraph::create"); + DBUG_ENTER("ha_oqgraph::create"); DBUG_PRINT( "oq-debug", ("create(name=%s)", name)); if (oqgraph_check_table_structure(table_arg)) { @@ -1330,7 +1326,7 @@ maria_declare_plugin(oqgraph) oqgraph_sysvars, /* system variables */ #else NULL, -#endif +#endif "3.0", MariaDB_PLUGIN_MATURITY_BETA } From 13e30c00634bd3e2c92cbac41241bfef97ae7d84 Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Sat, 25 Oct 2014 21:17:13 +1030 Subject: [PATCH 04/14] Removed dead code and support for dead (<10.0.5) versions of mariadb Conflicts: storage/oqgraph/ha_oqgraph.cc Conflicts: storage/oqgraph/ha_oqgraph.cc --- storage/oqgraph/ha_oqgraph.cc | 178 ++++++++------------------------ storage/oqgraph/oqgraph_judy.cc | 6 -- 2 files changed, 45 insertions(+), 139 deletions(-) diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index 969f1c99837f9..1147f04295a71 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -23,45 +23,36 @@ ====================================================================== */ +/* + Changelog since 10.0.13 + ----------------------- + * Removed compatibility hacks for 5.5.32 and 10.0.4. + I expect no issues building oqgraph into Mariadb 5.5.40 but I think the better approach is maintain a separate fork / patches. + +*/ + #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif #include #define MYSQL_SERVER 1 // to have THD +/* For the moment, include code to deal with integer latches. + * I have wrapped it with this #ifdef to make it easier to find and remove in the future. + */ +#define RETAIN_INT_LATCH_COMPATIBILITY // for the time being, recognise integer latches to simplify upgrade. #include -#include "sql_class.h" - -#include -#include - #include #include "ha_oqgraph.h" #include "graphcore.h" - #include -#if MYSQL_VERSION_ID >= 100004 -// Interim workaround for rename in sql_error.h from this point -#define MYSQL_ERROR Sql_condition -#endif - -#if MYSQL_VERSION_ID < 100000 -// Allow compatibility with build for 5.5.32 -#define user_defined_key_parts key_parts -#define open_table_error(a,b,c) open_table_error(a,b,c,0) -#define enum_open_frm_error int -#else -#define enum_open_frm_error enum open_frm_error -#endif - -#include "table.h" -#include "field.h" -#include "key.h" -#include "unireg.h" -#include "sql_class.h" - -#include "my_dbug.h" +#include +#include +#include +#include +#include +#include // Uncomment this for extra debug, but expect a performance hit in large queries #define VERBOSE_DEBUG @@ -71,16 +62,8 @@ #define DBUG_PRINT(x ...) #endif -#define OQGRAPH_STATS_UPDATE_THRESHOLD 10 - using namespace open_query; -/* For the moment, include code to deal with integer latches. - * I have wrapped it with this #ifdef to make it easier to find and remove - * in the future. - */ -#define RETAIN_INT_LATCH_COMPATIBILITY - #ifdef RETAIN_INT_LATCH_COMPATIBILITY /* In normal operation, no new tables using an integer latch can be created, * but they can still be used if they already exist, to allow for upgrades. @@ -127,16 +110,14 @@ const char *oqlatchToCode(int latch) { return "unknown"; } -struct oqgraph_table_option_struct +struct ha_table_option_struct { const char *table_name; - const char *origid; // name of the origin id column const char *destid; // name of the target id column 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), @@ -150,43 +131,6 @@ static const char oqgraph_description[]= "Open Query Graph Computation Engine " "(http://openquery.com/graph)"; -#if MYSQL_VERSION_ID < 50100 -static bool oqgraph_init(); - -handlerton oqgraph_hton= { - "OQGRAPH", - SHOW_OPTION_YES, - oqgraph_description, - DB_TYPE_OQGRAPH, - oqgraph_init, - 0, /* slot */ - 0, /* savepoint size. */ - NULL, /* close_connection */ - NULL, /* savepoint */ - NULL, /* rollback to savepoint */ - NULL, /* release savepoint */ - NULL, /* commit */ - NULL, /* rollback */ - NULL, /* prepare */ - NULL, /* recover */ - NULL, /* commit_by_xid */ - NULL, /* rollback_by_xid */ - NULL, /* create_cursor_read_view */ - NULL, /* set_cursor_read_view */ - NULL, /* close_cursor_read_view */ - HTON_NO_FLAGS -}; - -#define STATISTIC_INCREMENT(X) \ -statistic_increment(table->in_use->status_var.X, &LOCK_status) -#define MOVE(X) move_field(X) -#define RECORDS records -#else -#define STATISTIC_INCREMENT(X) /* nothing */ -#define MOVE(X) move_field_offset(X) -#define RECORDS stats.records -#endif - static bool oqgraph_init_done= 0; static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table, @@ -196,20 +140,12 @@ static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table, return new (mem_root) ha_oqgraph(hton, table); } -#if MYSQL_VERSION_ID >= 50100 -static int oqgraph_init(handlerton *hton) -{ -#else -static bool oqgraph_init() -{ - if (have_oqgraph == SHOW_OPTION_DISABLED) - return 1; -#endif +static int oqgraph_init(void *p) +{ + handlerton *hton= (handlerton *)p; DBUG_PRINT( "oq-debug", ("oqgraph_init")); - -#if MYSQL_VERSION_ID >= 50100 hton->state= SHOW_OPTION_YES; hton->db_type= DB_TYPE_AUTOASSIGN; hton->create= oqgraph_create_handler; @@ -228,7 +164,6 @@ static int oqgraph_fini(void *) { DBUG_PRINT( "oq-debug", ("oqgraph_fini")); oqgraph_init_done= FALSE; -#endif return 0; } @@ -336,7 +271,7 @@ int ha_oqgraph::oqgraph_check_table_structure (TABLE *table_arg) DBUG_PRINT( "oq-debug", ("Allowing integer latch anyway!")); isStringLatch = false; /* Make a warning */ - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, + push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN, ER_WARN_DEPRECATED_SYNTAX, ER(ER_WARN_DEPRECATED_SYNTAX), "latch SMALLINT UNSIGNED NULL", "'latch VARCHAR(32) NULL'"); } else @@ -345,19 +280,19 @@ int ha_oqgraph::oqgraph_check_table_structure (TABLE *table_arg) { DBUG_PRINT( "oq-debug", ("Allowing integer no more!")); badColumn = true; - push_warning_printf( current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Integer latch is not supported for new tables.", i); + push_warning_printf( current_thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Integer latch is not supported for new tables.", i); } else /* Check Column Type */ if ((*field)->type() != skel[i].coltype) { badColumn = true; - push_warning_printf( current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Column %d is wrong type.", i); + push_warning_printf( current_thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Column %d is wrong type.", i); } // Make sure latch column is large enough for all possible latch values if (isLatchColumn && isStringLatch) { if ((*field)->char_length() < findLongestLatch()) { badColumn = true; - push_warning_printf( current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Column %d is too short.", i); + push_warning_printf( current_thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Column %d is too short.", i); } } @@ -365,18 +300,18 @@ int ha_oqgraph::oqgraph_check_table_structure (TABLE *table_arg) /* Check Is UNSIGNED */ if ( (!((*field)->flags & UNSIGNED_FLAG ))) { badColumn = true; - push_warning_printf( current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Column %d must be UNSIGNED.", i); + push_warning_printf( current_thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Column %d must be UNSIGNED.", i); } } /* Check THAT NOT NULL isn't set */ if (!badColumn) if ((*field)->flags & NOT_NULL_FLAG) { badColumn = true; - push_warning_printf( current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Column %d must be NULL.", i); + push_warning_printf( current_thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Column %d must be NULL.", i); } /* Check the column name */ if (!badColumn) if (strcmp(skel[i].colname,(*field)->field_name)) { badColumn = true; - push_warning_printf( current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Column %d must be named '%s'.", i, skel[i].colname); + push_warning_printf( current_thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Column %d must be named '%s'.", i, skel[i].colname); } if (badColumn) { DBUG_RETURN(-1); @@ -384,16 +319,16 @@ int ha_oqgraph::oqgraph_check_table_structure (TABLE *table_arg) } if (skel[i].colname) { - push_warning_printf( current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Not enough columns."); + push_warning_printf( current_thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Not enough columns."); DBUG_RETURN(-1); } if (*field) { - push_warning_printf( current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Too many columns."); + push_warning_printf( current_thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Too many columns."); DBUG_RETURN(-1); } if (!table_arg->key_info || !table_arg->s->keys) { - push_warning_printf( current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "No vaild key specification."); + push_warning_printf( current_thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "No vaild key specification."); DBUG_RETURN(-1); } @@ -406,7 +341,7 @@ int ha_oqgraph::oqgraph_check_table_structure (TABLE *table_arg) /* check that the first key part is the latch and it is a hash key */ if (!(field[0] == key->key_part[0].field && HA_KEY_ALG_HASH == key->algorithm)) { - push_warning_printf( current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Incorrect keys algorithm on key %d.", i); + push_warning_printf( current_thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Incorrect keys algorithm on key %d.", i); DBUG_RETURN(-1); } if (key->user_defined_key_parts == 3) @@ -418,12 +353,12 @@ int ha_oqgraph::oqgraph_check_table_structure (TABLE *table_arg) !(field[1] == key->key_part[2].field && field[2] == key->key_part[1].field)) { - push_warning_printf( current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Keys parts mismatch on key %d.", i); + push_warning_printf( current_thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Keys parts mismatch on key %d.", i); DBUG_RETURN(-1); } } else { - push_warning_printf( current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Too many key parts on key %d.", i); + push_warning_printf( current_thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "Too many key parts on key %d.", i); DBUG_RETURN(-1); } } @@ -572,9 +507,8 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) share->normalized_path.str, share->path.length)); int open_def_flags = 0; -#if MYSQL_VERSION_ID>= 100002 open_def_flags = GTS_TABLE; -#endif + // We want to open the definition for the given backing table // Once can assume this loop exists because sometimes open_table_def() fails for a reason other than not exist // and not 'exist' is valid, because we use ha_create_table_from_engine() to force it to 'exist' @@ -584,28 +518,11 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) // Lets try without this, and see if all the tests pass... while (open_table_def(thd, share, open_def_flags)) { -#if MYSQL_VERSION_ID < 100002 - if (thd->is_error() && thd->stmt_da->sql_errno() != ER_NO_SUCH_TABLE) - { - free_table_share(share); - DBUG_RETURN(thd->stmt_da->sql_errno()); - } - - if (ha_create_table_from_engine(thd, table->s->db.str, options->table_name)) - { - free_table_share(share); - DBUG_RETURN(thd->stmt_da->sql_errno()); - } - /*mysql_reset_errors(thd, 1);*/ - thd->clear_error(); - continue; -#else open_table_error(share, OPEN_FRM_OPEN_ERROR, ENOENT); free_table_share(share); if (thd->is_error()) DBUG_RETURN(thd->get_stmt_da()->sql_errno()); DBUG_RETURN(HA_ERR_NO_SUCH_TABLE); -#endif } @@ -623,7 +540,7 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) DBUG_RETURN(-1); } - if (enum_open_frm_error err= open_table_from_share(thd, share, "", + if (enum open_frm_error err= open_table_from_share(thd, share, "", (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE | HA_GET_INDEX | HA_TRY_READ_ONLY), READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD, @@ -915,7 +832,7 @@ int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key, field[0]->val_str(&latchFieldValue, &latchFieldValue); if (!parse_latch_string_to_legacy_int(latchFieldValue, latch)) { // Invalid, so warn & fail - push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_WRONG_ARGUMENTS, ER(ER_WRONG_ARGUMENTS), "OQGRAPH latch"); + push_warning_printf(current_thd, Sql_condition::WARN_LEVEL_WARN, ER_WRONG_ARGUMENTS, ER(ER_WRONG_ARGUMENTS), "OQGRAPH latch"); table->status = STATUS_NOT_FOUND; if (ptrdiff) /* fixes debug build assert - should be a tidier way to do this */ { @@ -1103,7 +1020,7 @@ int ha_oqgraph::cmp_ref(const byte *ref1, const byte *ref2) int ha_oqgraph::info(uint flag) { - RECORDS= graph->edges_count(); + stats.records = graph->edges_count(); /* If info() is called for the first time after open(), we will still @@ -1270,9 +1187,6 @@ ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key, int ha_oqgraph::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *create_info) { - oqgraph_table_option_struct *options= - reinterpret_cast(table_arg->s->option_struct); - DBUG_ENTER("ha_oqgraph::create"); DBUG_PRINT( "oq-debug", ("create(name=%s)", name)); @@ -1280,7 +1194,6 @@ int ha_oqgraph::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *creat DBUG_RETURN(HA_WRONG_CREATE_OPTION); } - (void)(options); DBUG_RETURN(0); } @@ -1294,12 +1207,11 @@ struct st_mysql_storage_engine oqgraph_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; extern "C" const char* const oqgraph_boost_version; -extern "C" const char* const oqgraph_judy_version; static struct st_mysql_show_var oqgraph_status[]= { { "OQGraph_Boost_Version", (char*) &oqgraph_boost_version, SHOW_CHAR_PTR }, - /*{ "OQGraph_Judy_Version", (char*) &oqgraph_judy_version, SHOW_CHAR_PTR },*/ + /* We thought about reporting the Judy version, but there seems to be no way to get that from code in the first place. */ { 0, 0, SHOW_UNDEF } }; @@ -1318,12 +1230,12 @@ maria_declare_plugin(oqgraph) "Arjen Lentz & Antony T Curtis, Open Query, and Andrew McDonnell", oqgraph_description, PLUGIN_LICENSE_GPL, - (int (*)(void*)) oqgraph_init, /* Plugin Init */ - oqgraph_fini, /* Plugin Deinit */ - 0x0300, /* Version: 3s.0 */ - oqgraph_status, /* status variables */ + oqgraph_init, /* Plugin Init */ + oqgraph_fini, /* Plugin Deinit */ + 0x0300, /* Version: 3s.0 */ + oqgraph_status, /* status variables */ #ifdef RETAIN_INT_LATCH_COMPATIBILITY - oqgraph_sysvars, /* system variables */ + oqgraph_sysvars, /* system variables */ #else NULL, #endif diff --git a/storage/oqgraph/oqgraph_judy.cc b/storage/oqgraph/oqgraph_judy.cc index acd7c2ae4c122..020cab57ed290 100644 --- a/storage/oqgraph/oqgraph_judy.cc +++ b/storage/oqgraph/oqgraph_judy.cc @@ -25,12 +25,6 @@ #include "oqgraph_judy.h" #include -#ifndef JUDY_LIB_VERSION -#define JUDY_LIB_VERSION "(unknown)" -#endif - -extern "C" const char* const oqgraph_judy_version= JUDY_LIB_VERSION; - void open_query::judy_bitset::clear() { int rc; From 79246ebfe9f24eb1c868a1e3fab063cd1c1ec870 Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Thu, 30 Oct 2014 23:00:07 +1030 Subject: [PATCH 05/14] Partial code tidy: move plugin description to end with other items, and added status variable for debug. --- storage/oqgraph/ha_oqgraph.cc | 52 ++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index 1147f04295a71..fa8b23fb5a787 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -28,6 +28,7 @@ ----------------------- * Removed compatibility hacks for 5.5.32 and 10.0.4. I expect no issues building oqgraph into Mariadb 5.5.40 but I think the better approach is maintain a separate fork / patches. + * Added status variable to report if verbose debug is on */ @@ -62,8 +63,6 @@ #define DBUG_PRINT(x ...) #endif -using namespace open_query; - #ifdef RETAIN_INT_LATCH_COMPATIBILITY /* In normal operation, no new tables using an integer latch can be created, * but they can still be used if they already exist, to allow for upgrades. @@ -74,12 +73,10 @@ using namespace open_query; */ static my_bool g_allow_create_integer_latch = FALSE; - -static MYSQL_SYSVAR_BOOL(allow_create_integer_latch, g_allow_create_integer_latch, - PLUGIN_VAR_RQCMDARG, "Allow creation of integer latches " - "so the upgrade logic can be tested", NULL, NULL, FALSE); #endif +using namespace open_query; + // Table of varchar latch operations. // In the future this needs to be refactactored to live somewhere else struct oqgraph_latch_op_table { const char *key; int latch; }; @@ -127,10 +124,6 @@ static const ha_create_table_option oqgraph_table_option_list[]= HA_TOPTION_END }; -static const char oqgraph_description[]= - "Open Query Graph Computation Engine " - "(http://openquery.com/graph)"; - static bool oqgraph_init_done= 0; static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table, @@ -1203,24 +1196,55 @@ void ha_oqgraph::update_create_info(HA_CREATE_INFO *create_info) table->file->info(HA_STATUS_AUTO); } +// -------------------- +// Handler description. +// -------------------- + + +static const char oqgraph_description[]= + "Open Query Graph Computation Engine " + "(http://openquery.com/graph)"; + struct st_mysql_storage_engine oqgraph_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; extern "C" const char* const oqgraph_boost_version; +static const char *oqgraph_status_verbose_debug = +#ifdef VERBOSE_DEBUG + "Verbose Debug is enabled. Performance may be adversely impacted."; +#else + "Verbose Debug is not enabled."; +#endif + +static const char *oqgraph_status_latch_compat_mode = +#ifdef RETAIN_INT_LATCH_COMPATIBILITY + "Legacy tables with integer latches are supported."; +#else + "Legacy tables with integer latches are not supported."; +#endif + static struct st_mysql_show_var oqgraph_status[]= { { "OQGraph_Boost_Version", (char*) &oqgraph_boost_version, SHOW_CHAR_PTR }, /* We thought about reporting the Judy version, but there seems to be no way to get that from code in the first place. */ + { "OQGraph_Verbose_Debug", (char*) &oqgraph_status_verbose_debug, SHOW_CHAR_PTR }, + { "OQGraph_Compat_mode", (char*) &oqgraph_status_latch_compat_mode, SHOW_CHAR_PTR }, { 0, 0, SHOW_UNDEF } }; #ifdef RETAIN_INT_LATCH_COMPATIBILITY +static MYSQL_SYSVAR_BOOL( allow_create_integer_latch, g_allow_create_integer_latch, PLUGIN_VAR_RQCMDARG, + "Allow creation of integer latches so the upgrade logic can be tested. Not for normal use.", + NULL, NULL, FALSE); +#endif + static struct st_mysql_sys_var* oqgraph_sysvars[]= { +#ifdef RETAIN_INT_LATCH_COMPATIBILITY MYSQL_SYSVAR(allow_create_integer_latch), +#endif 0 }; -#endif maria_declare_plugin(oqgraph) { @@ -1234,11 +1258,7 @@ maria_declare_plugin(oqgraph) oqgraph_fini, /* Plugin Deinit */ 0x0300, /* Version: 3s.0 */ oqgraph_status, /* status variables */ -#ifdef RETAIN_INT_LATCH_COMPATIBILITY - oqgraph_sysvars, /* system variables */ -#else - NULL, -#endif + oqgraph_sysvars, /* system variables */ "3.0", MariaDB_PLUGIN_MATURITY_BETA } From e72abc5a96c8169e4142cceac32c305135e9064b Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Sat, 25 Oct 2014 21:23:34 +1030 Subject: [PATCH 06/14] Minor fix: make sure alter table wont try to change our storage engine to something else. --- storage/oqgraph/ha_oqgraph.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/storage/oqgraph/ha_oqgraph.h b/storage/oqgraph/ha_oqgraph.h index 1449027003143..110416831abec 100644 --- a/storage/oqgraph/ha_oqgraph.h +++ b/storage/oqgraph/ha_oqgraph.h @@ -78,6 +78,9 @@ class ha_oqgraph: public handler double read_time(uint index, uint ranges, ha_rows rows) { return 1; } + // Doesn't make sense to change the engine on a virtual table. + virtual bool can_switch_engines() { return false; } + int open(const char *name, int mode, uint test_if_locked); int close(void); int write_row(byte * buf); From a657abd63fdb77c20e5d5f91e77a3febb4cce5b2 Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Sat, 25 Oct 2014 21:36:29 +1030 Subject: [PATCH 07/14] Added extra debug to support MDEV-6282 Conflicts: storage/oqgraph/ha_oqgraph.cc --- storage/oqgraph/ha_oqgraph.cc | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index fa8b23fb5a787..d312ed0f0a255 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -133,6 +133,7 @@ static handler* oqgraph_create_handler(handlerton *hton, TABLE_SHARE *table, return new (mem_root) ha_oqgraph(hton, table); } +int oqgraph_close_connection(handlerton *hton, THD *thd); static int oqgraph_init(void *p) { @@ -149,6 +150,9 @@ static int oqgraph_init(void *p) // HTON_NO_FLAGS; hton->table_options= (ha_create_table_option*)oqgraph_table_option_list; + + hton->close_connection = oqgraph_close_connection; + oqgraph_init_done= TRUE; return 0; } @@ -363,6 +367,14 @@ int ha_oqgraph::oqgraph_check_table_structure (TABLE *table_arg) ** OQGRAPH tables *****************************************************************************/ +int oqgraph_close_connection(handlerton *hton, THD *thd) +{ + DBUG_PRINT( "oq-debug", ("thd: 0x%lx; oqgraph_close_connection.", (long) thd)); + // close_thread_tables(thd); // maybe this? + return 0; +} + + ha_oqgraph::ha_oqgraph(handlerton *hton, TABLE_SHARE *table_arg) : handler(hton, table_arg) , have_table_share(false) @@ -372,7 +384,8 @@ ha_oqgraph::ha_oqgraph(handlerton *hton, TABLE_SHARE *table_arg) , graph_share(0) , graph(0) , error_message("", 0, &my_charset_latin1) -{ } +{ +} ha_oqgraph::~ha_oqgraph() { } @@ -434,14 +447,15 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) { DBUG_ENTER("ha_oqgraph::open"); - DBUG_PRINT( "oq-debug", ("open(name=%s,mode=%d,test_if_locked=%u)", name, mode, test_if_locked)); + DBUG_PRINT( "oq-debug", ("thd: 0x%lx; open(name=%s,mode=%d,test_if_locked=%u)", (long) current_thd, name, mode, test_if_locked)); DBUG_ASSERT(!have_table_share); DBUG_ASSERT(graph == NULL); THD* thd = current_thd; - oqgraph_table_option_struct *options= - reinterpret_cast(table->s->option_struct); + thd_set_ha_data( thd, ht, (void*)1); + + 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 @@ -663,6 +677,7 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) int ha_oqgraph::close(void) { + DBUG_PRINT( "oq-debug", ("close()")); oqgraph::free(graph); graph= 0; oqgraph::free(graph_share); graph_share= 0; @@ -678,6 +693,7 @@ int ha_oqgraph::close(void) void ha_oqgraph::update_key_stats() { + DBUG_PRINT( "oq-debug", ("update_key_stats()")); for (uint i= 0; i < table->s->keys; i++) { KEY *key=table->key_info+i; @@ -800,6 +816,8 @@ int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key, int* latchp=0; open_query::row row; + DBUG_PRINT("oq-debug", ("thd: 0x%lx; index_read_idx()", (long) current_thd)); + bmove_align(buf, table->s->default_values, table->s->reclength); key_restore(buf, (byte*) key, key_info, key_len); @@ -1062,11 +1080,13 @@ THR_LOCK_DATA **ha_oqgraph::store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lo int ha_oqgraph::delete_table(const char *) { + DBUG_PRINT( "oq-debug", ("delete_table()")); return 0; } int ha_oqgraph::rename_table(const char *, const char *) { + DBUG_PRINT( "oq-debug", ("rename_table()")); return 0; } @@ -1080,7 +1100,7 @@ ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key, String temp; key->key_part[0].field->val_str(&temp); temp.c_ptr_safe(); - DBUG_PRINT( "oq-debug", ("records_in_range ::>> inx=%u", inx)); + DBUG_PRINT( "oq-debug", ("thd: 0x%lx; records_in_range ::>> inx=%u", (long) current_thd, inx)); DBUG_PRINT( "oq-debug", ("records_in_range ::>> key0=%s.", temp.c_ptr())); // for some reason when I had ...inx=%u key=%s", inx, temp.c_ptr_safe()) it printed nothing ... } #endif From 6ff6bf8aa3d5f4c635aa75f966160ccaeec34973 Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Sat, 25 Oct 2014 21:36:55 +1030 Subject: [PATCH 08/14] Added regression test for MDEV-6345 --- .../oqgraph/regression_mdev6345.result | 12 ++++++++++++ .../oqgraph/regression_mdev6345.test | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 storage/oqgraph/mysql-test/oqgraph/regression_mdev6345.result create mode 100644 storage/oqgraph/mysql-test/oqgraph/regression_mdev6345.test diff --git a/storage/oqgraph/mysql-test/oqgraph/regression_mdev6345.result b/storage/oqgraph/mysql-test/oqgraph/regression_mdev6345.result new file mode 100644 index 0000000000000..8e680e1520691 --- /dev/null +++ b/storage/oqgraph/mysql-test/oqgraph/regression_mdev6345.result @@ -0,0 +1,12 @@ +DROP TABLE IF EXISTS oq_backing; +DROP TABLE IF EXISTS oq_graph; +CREATE TABLE oq_backing (origid INT UNSIGNED NOT NULL, destid INT UNSIGNED NOT NULL, PRIMARY KEY (origid, destid), KEY (destid)); +INSERT INTO oq_backing(origid, destid) VALUES (1,2), (2,3), (3,4), (4,5), (2,6), (5,6); +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) ENGINE=OQGRAPH data_table='oq_backing' origid='origid' destid='destid'; +SELECT * FROM oq_graph WHERE latch='breadth_first' AND origid=1 AND destid=6; +latch origid destid weight seq linkid +breadth_first 1 6 NULL 0 1 +breadth_first 1 6 1 1 2 +breadth_first 1 6 1 2 6 +DROP TABLE IF EXISTS oq_backing; +DROP TABLE IF EXISTS oq_graph; diff --git a/storage/oqgraph/mysql-test/oqgraph/regression_mdev6345.test b/storage/oqgraph/mysql-test/oqgraph/regression_mdev6345.test new file mode 100644 index 0000000000000..72de926da2ec3 --- /dev/null +++ b/storage/oqgraph/mysql-test/oqgraph/regression_mdev6345.test @@ -0,0 +1,19 @@ +#-- This test is probably not right, because the real bug manifested over a network connection on a busy server. + +--disable_warnings +DROP TABLE IF EXISTS oq_backing; +DROP TABLE IF EXISTS oq_graph; +--enable_warnings + + +CREATE TABLE oq_backing (origid INT UNSIGNED NOT NULL, destid INT UNSIGNED NOT NULL, PRIMARY KEY (origid, destid), KEY (destid)); + +INSERT INTO oq_backing(origid, destid) VALUES (1,2), (2,3), (3,4), (4,5), (2,6), (5,6); + +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) ENGINE=OQGRAPH data_table='oq_backing' origid='origid' destid='destid'; + +SELECT * FROM oq_graph WHERE latch='breadth_first' AND origid=1 AND destid=6; + +DROP TABLE IF EXISTS oq_backing; +DROP TABLE IF EXISTS oq_graph; + From fbcabb24ce145f2e413007b8f515d3b9b811cf34 Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Tue, 28 Oct 2014 21:45:47 +1030 Subject: [PATCH 09/14] Fixed minor spelling mistake. --- storage/oqgraph/ha_oqgraph.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index d312ed0f0a255..1352d5d854583 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -325,7 +325,7 @@ int ha_oqgraph::oqgraph_check_table_structure (TABLE *table_arg) } if (!table_arg->key_info || !table_arg->s->keys) { - push_warning_printf( current_thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "No vaild key specification."); + push_warning_printf( current_thd, Sql_condition::WARN_LEVEL_WARN, HA_WRONG_CREATE_OPTION, "No valid key specification."); DBUG_RETURN(-1); } From f8e0f1a823a32266572bfe12363db68ab67f08ee Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Tue, 28 Oct 2014 21:50:34 +1030 Subject: [PATCH 10/14] Minor code cleanup: validation of options to member function. --- storage/oqgraph/ha_oqgraph.cc | 93 +++++++++++++------ storage/oqgraph/ha_oqgraph.h | 4 +- .../mysql-test/oqgraph/create_attr.result | 40 ++++---- .../mysql-test/oqgraph/create_attr.test | 20 ++-- .../oqgraph/create_attr_legacy.result | 20 ++-- 5 files changed, 107 insertions(+), 70 deletions(-) diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index 1352d5d854583..833143dd57c2a 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -434,56 +434,91 @@ void ha_oqgraph::fprint_error(const char* fmt, ...) va_end(ap); } +/** + * Check that the currently referenced OQGRAPH table definition, on entry to open(), has sane OQGRAPH options. + * (This does not check the backing store, but the OQGRAPH virtual table options) + * + * @return true if OK, or false if an option is invalid. + */ +bool ha_oqgraph::validate_oqgraph_table_options() +{ + // Note when called from open(), we should not expect this method to fail except in the case of bugs; the fact that it does is + // could be construed as a bug. I think in practice however, this is because CREATE TABLE calls both create() and open(), + // and it is possible to do something like ALTER TABLE x DESTID='y' to _change_ the options. + // Thus we need to sanity check from open() until and unless we get around to extending ha_oqgraph to properly handle ALTER TABLE, + // after which we could change things to call this method from create() and the ALTER TABLE handling code instead. + // It may still be sensible to call this from open() anyway, in case someone somewhere upgrades from a broken table definition... + + 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 + if (!options) { + // This should only happen if there is a bug elsewhere in the storage engine, because ENGINE itself is an attribute + fprint_error("Invalid OQGRAPH backing store (null attributes)"); + } + else if (!options->table_name || !*options->table_name) { + // The first condition indicates no DATA_TABLE option, the second if the user specified DATA_TABLE='' + fprint_error("Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)"); + // if table_name option is present but doesn't actually exist, we will fail later + } + else if (!options->origid || !*options->origid) { + // The first condition indicates no ORIGID option, the second if the user specified ORIGID='' + fprint_error("Invalid OQGRAPH backing store description (unspecified or empty origid attribute)"); + // if ORIGID option is present but doesn't actually exist, we will fail later + } + else if (!options->destid || !*options->destid) { + // The first condition indicates no DESTID option, the second if the user specified DESTID='' + fprint_error("Invalid OQGRAPH backing store description (unspecified or empty destid attribute)"); + // if DESTID option is present but doesn't actually exist, we will fail later + } else { + // weight is optional... + return true; + } + // Fault + return false; +} + /** * Open the OQGRAPH engine 'table'. * - * An OQGRAPH table is effectively similar to a view over the underlying backing table, - * attribute 'data_table', but where the result returned by a query depends on the - * value of the 'latch' column specified to the query. Therefore, - * when mysqld opens us, we need to open the corresponding backing table 'data_table' + * An OQGRAPH table is effectively similar to a view over the underlying backing table, attribute 'data_table', but where the + * result returned by a query depends on the value of the 'latch' column specified to the query. + * Therefore, when mysqld opens us, we need to open the corresponding backing table 'data_table'. + * + * Conceptually, the backing store could be any kind of object having queryable semantics, including a SQL VIEW. + * However, for that to work in practice would require us to hook into the right level of the MYSQL API. + * Presently, only objects that can be opened using the internal mechanisms can be used: INNODB, MYISAM, etc. + * The intention is to borrow from ha_connect and use the mysql client library to access the backing store. * */ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked) { DBUG_ENTER("ha_oqgraph::open"); - DBUG_PRINT( "oq-debug", ("thd: 0x%lx; open(name=%s,mode=%d,test_if_locked=%u)", (long) current_thd, name, mode, test_if_locked)); + // So, we took a peek inside handler::ha_open() and learned a few things: + // * this->table is set by handler::ha_open() before calling open(). + // Note that from this we can only assume that MariaDB knows what it is doing and wont call open() other anything else + // relying on this-0>table, re-entrantly... + // * this->table_share should never be set back to NULL, an assertion checks for this in ha_open() after open() + // * this->table_share is initialised in the constructor of handler + // * this->table_share is only otherwise changed by this->change_table_ptr()) + // We also discovered that an assertion is raised if table->s is not table_share before calling open()) + DBUG_ASSERT(!have_table_share); DBUG_ASSERT(graph == NULL); - THD* thd = current_thd; - thd_set_ha_data( thd, ht, (void*)1); + // Before doing anything, make sure we have DATA_TABLE, ORIGID and DESTID not empty + if (!validate_oqgraph_table_options()) { DBUG_RETURN(-1); } 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 - if (!options) { - fprint_error("Invalid OQGRAPH backing store (null attributes)"); - DBUG_RETURN(-1); - } - if (!options->table_name || !*options->table_name) { - fprint_error("Invalid OQGRAPH backing store (unspecified or empty data_table attribute)"); - // if table_name if present but doesnt actually exist, we will fail out below - // when we call open_table_def(). same probably applies for the id fields - DBUG_RETURN(-1); - } - if (!options->origid || !*options->origid) { - fprint_error("Invalid OQGRAPH backing store (unspecified or empty origid attribute)"); - DBUG_RETURN(-1); - } - if (!options->destid || !*options->destid) { - fprint_error("Invalid OQGRAPH backing store (unspecified or empty destid attribute)"); - DBUG_RETURN(-1); - } - // weight is optional error_message.length(0); - origid= destid= weight= 0; // Here we're abusing init_tmp_table_share() which is normally only works for thread-local shares. + THD* thd = current_thd; init_tmp_table_share( thd, share, table->s->db.str, table->s->db.length, options->table_name, ""); // because of that, we need to reinitialize the memroot (to reset MY_THREAD_SPECIFIC flag) DBUG_ASSERT(share->mem_root.used == NULL); // it's still empty diff --git a/storage/oqgraph/ha_oqgraph.h b/storage/oqgraph/ha_oqgraph.h index 110416831abec..6013df43e6b1d 100644 --- a/storage/oqgraph/ha_oqgraph.h +++ b/storage/oqgraph/ha_oqgraph.h @@ -133,8 +133,10 @@ class ha_oqgraph: public handler } private: - int oqgraph_check_table_structure (TABLE *table_arg); + // Various helper functions + int oqgraph_check_table_structure (TABLE *table_arg); + bool validate_oqgraph_table_options(); void update_key_stats(); String error_message; }; diff --git a/storage/oqgraph/mysql-test/oqgraph/create_attr.result b/storage/oqgraph/mysql-test/oqgraph/create_attr.result index e9499cb7d21b4..c7c4b068dbe14 100644 --- a/storage/oqgraph/mysql-test/oqgraph/create_attr.result +++ b/storage/oqgraph/mysql-test/oqgraph/create_attr.result @@ -19,29 +19,29 @@ PRIMARY KEY (id), KEY name (info) ) DEFAULT CHARSET=latin1; CREATE TABLE oqtable ( 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; -# Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' +# Expect: 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( 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, ORIGID='id', DESTID='id2'; -# Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' +# Expect: 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( 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='', ORIGID='id', DESTID='id2'; -# Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' +# Expect: 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( 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='', ORIGID='id'; -# Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' +# Expect: 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( 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='', DESTID='id2'; -# Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' +# Expect: 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( 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='bogus', ORIGID='id', DESTID='id2'; # Expect: 'Table 'test.bogus' doesn't exist'' @@ -49,19 +49,19 @@ DESCRIBE oqtable; ERROR 42S02: Table 'test.bogus' doesn't exist DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( 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='not_backing'; -# Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)' +# Expect 'Invalid OQGRAPH backing store description (unspecified or empty origid attribute)' DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty origid attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( 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='backing', DESTID='id2'; -# Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)' +# Expect 'Invalid OQGRAPH backing store description (unspecified or empty origid attribute)' DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty origid attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( 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='backing',ORIGID='', DESTID='id2'; -# Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)' +# Expect 'Invalid OQGRAPH backing store description (unspecified or empty origid attribute)' DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty origid attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( 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='backing',ORIGID='bogus', DESTID='id2'; # Expect Invalid OQGRAPH backing store ('/oqtable'.origid attribute not set to a valid column of 'backing')' @@ -74,14 +74,14 @@ DESCRIBE oqtable; ERROR HY000: Got error -1 'Column 'backing.not_id_type' (origid) is not a not-null integer type' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( 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='backing',ORIGID='id'; -# Expect 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' +# Expect 'Invalid OQGRAPH backing store description (unspecified or empty destid attribute)' DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty destid attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( 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='backing',ORIGID='id',DESTID=''; -# Expect 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' +# Expect 'Invalid OQGRAPH backing store description (unspecified or empty destid attribute)' DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty destid attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( 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='backing',ORIGID='id',DESTID='bogus'; # Expect Invalid OQGRAPH backing store ('/oqtable'.destid attribute not set to a valid column of 'backing')' diff --git a/storage/oqgraph/mysql-test/oqgraph/create_attr.test b/storage/oqgraph/mysql-test/oqgraph/create_attr.test index d681d601faeff..c2ca4816d09fc 100644 --- a/storage/oqgraph/mysql-test/oqgraph/create_attr.test +++ b/storage/oqgraph/mysql-test/oqgraph/create_attr.test @@ -27,7 +27,7 @@ CREATE TABLE backing ( # oqgraph v2 create table should fail (missing attributes) CREATE TABLE oqtable ( 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; ---echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' +--echo # Expect: 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' --error 1296 DESCRIBE oqtable; @@ -37,7 +37,7 @@ DESCRIBE oqtable; DROP TABLE IF EXISTS oqtable; --enable_warnings CREATE TABLE oqtable ( 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, ORIGID='id', DESTID='id2'; ---echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' +--echo # Expect: 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' --error 1296 DESCRIBE oqtable; @@ -46,7 +46,7 @@ DESCRIBE oqtable; DROP TABLE IF EXISTS oqtable; --enable_warnings CREATE TABLE oqtable ( 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='', ORIGID='id', DESTID='id2'; ---echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' +--echo # Expect: 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' --error 1296 DESCRIBE oqtable; @@ -55,7 +55,7 @@ DESCRIBE oqtable; DROP TABLE IF EXISTS oqtable; --enable_warnings CREATE TABLE oqtable ( 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='', ORIGID='id'; ---echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' +--echo # Expect: 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' --error 1296 DESCRIBE oqtable; @@ -65,7 +65,7 @@ DESCRIBE oqtable; DROP TABLE IF EXISTS oqtable; --enable_warnings CREATE TABLE oqtable ( 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='', DESTID='id2'; ---echo # Expect: 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' +--echo # Expect: 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' --error 1296 DESCRIBE oqtable; @@ -85,7 +85,7 @@ DESCRIBE oqtable; DROP TABLE IF EXISTS oqtable; --enable_warnings CREATE TABLE oqtable ( 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='not_backing'; ---echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)' +--echo # Expect 'Invalid OQGRAPH backing store description (unspecified or empty origid attribute)' --error 1296 DESCRIBE oqtable; @@ -94,7 +94,7 @@ DESCRIBE oqtable; DROP TABLE IF EXISTS oqtable; --enable_warnings CREATE TABLE oqtable ( 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='backing', DESTID='id2'; ---echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)' +--echo # Expect 'Invalid OQGRAPH backing store description (unspecified or empty origid attribute)' --error 1296 DESCRIBE oqtable; @@ -103,7 +103,7 @@ DESCRIBE oqtable; DROP TABLE IF EXISTS oqtable; --enable_warnings CREATE TABLE oqtable ( 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='backing',ORIGID='', DESTID='id2'; ---echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)' +--echo # Expect 'Invalid OQGRAPH backing store description (unspecified or empty origid attribute)' --error 1296 DESCRIBE oqtable; @@ -130,7 +130,7 @@ DESCRIBE oqtable; DROP TABLE IF EXISTS oqtable; --enable_warnings CREATE TABLE oqtable ( 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='backing',ORIGID='id'; ---echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' +--echo # Expect 'Invalid OQGRAPH backing store description (unspecified or empty destid attribute)' --error 1296 DESCRIBE oqtable; @@ -139,7 +139,7 @@ DESCRIBE oqtable; DROP TABLE IF EXISTS oqtable; --enable_warnings CREATE TABLE oqtable ( 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='backing',ORIGID='id',DESTID=''; ---echo # Expect 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' +--echo # Expect 'Invalid OQGRAPH backing store description (unspecified or empty destid attribute)' --error 1296 DESCRIBE oqtable; diff --git a/storage/oqgraph/mysql-test/oqgraph/create_attr_legacy.result b/storage/oqgraph/mysql-test/oqgraph/create_attr_legacy.result index 47777b0f0a7eb..d3e22b4f668a3 100644 --- a/storage/oqgraph/mysql-test/oqgraph/create_attr_legacy.result +++ b/storage/oqgraph/mysql-test/oqgraph/create_attr_legacy.result @@ -23,61 +23,61 @@ CREATE TABLE oqtable ( latch SMALLINT UNSIGNED NULL, origid BIGINT UNSIGNED NULL Warnings: Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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=''; Warnings: Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty data_table attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty data_table attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='bogus'; Warnings: Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty origid attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='Ω Ohms Tennis Ball 〄'; Warnings: Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty origid attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='not_backing', ORIGID='id'; Warnings: Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty destid attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='backing',ORIGID=''; Warnings: Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty origid attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty origid attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='backing',ORIGID='bogus'; Warnings: Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty destid attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='backing',ORIGID='not_id_type'; Warnings: Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty destid attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='backing',ORIGID='id'; Warnings: Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty destid attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='backing',ORIGID='id',DESTID=''; Warnings: Warning 1287 'latch SMALLINT UNSIGNED NULL' is deprecated and will be removed in a future release. Please use 'latch VARCHAR(32) NULL' instead DESCRIBE oqtable; -ERROR HY000: Got error -1 'Invalid OQGRAPH backing store (unspecified or empty destid attribute)' from OQGRAPH +ERROR HY000: Got error -1 'Invalid OQGRAPH backing store description (unspecified or empty destid attribute)' from OQGRAPH DROP TABLE IF EXISTS oqtable; CREATE TABLE oqtable ( latch SMALLINT UNSIGNED 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='backing',ORIGID='id',DESTID='bogus'; Warnings: From e32dafe77870ae8d4da2aae2321f3e03fa1d1f98 Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Thu, 30 Oct 2014 22:47:48 +1030 Subject: [PATCH 11/14] Hopefully finally fixes MDEV-6282, MDEV-5748 and MDEV-6345 --- storage/oqgraph/graphcore-types.h | 2 ++ storage/oqgraph/graphcore.cc | 3 +++ storage/oqgraph/graphcore.h | 3 +++ storage/oqgraph/ha_oqgraph.cc | 10 ++++++++++ storage/oqgraph/oqgraph_thunk.cc | 3 +++ storage/oqgraph/oqgraph_thunk.h | 3 +++ 6 files changed, 24 insertions(+) diff --git a/storage/oqgraph/graphcore-types.h b/storage/oqgraph/graphcore-types.h index 3ff32d0e2335a..2f182341b39fd 100644 --- a/storage/oqgraph/graphcore-types.h +++ b/storage/oqgraph/graphcore-types.h @@ -34,7 +34,9 @@ namespace open_query } +// Forward defs from mariadb itself! class Field; typedef struct TABLE TABLE; +class THD; #endif diff --git a/storage/oqgraph/graphcore.cc b/storage/oqgraph/graphcore.cc index de575c9da6554..73433fc821967 100644 --- a/storage/oqgraph/graphcore.cc +++ b/storage/oqgraph/graphcore.cc @@ -443,6 +443,9 @@ namespace open_query return num_vertices(share->g); } + THD* oqgraph::get_thd() { return share->g.get_table_thd(); } + void oqgraph::set_thd(THD* thd) { share->g.set_table_thd(thd); } + oqgraph* oqgraph::create(oqgraph_share *share) throw() { assert(share != NULL); diff --git a/storage/oqgraph/graphcore.h b/storage/oqgraph/graphcore.h index f7eff77d8b10b..b1560552fcfc0 100644 --- a/storage/oqgraph/graphcore.h +++ b/storage/oqgraph/graphcore.h @@ -126,6 +126,9 @@ namespace open_query static oqgraph* create(oqgraph_share*) throw(); static oqgraph_share *create(TABLE*,Field*,Field*,Field*) throw(); + THD* get_thd(); + void set_thd(THD*); + static void free(oqgraph*) throw(); static void free(oqgraph_share*) throw(); diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index 833143dd57c2a..7ff9e6a41d479 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -842,6 +842,11 @@ static int parse_latch_string_to_legacy_int(const String& value, int &latch) int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key, uint key_len, enum ha_rkey_function find_flag) { + if (graph->get_thd() != current_thd) { + DBUG_PRINT( "oq-debug", ("g->table->in_use: 0x%lx <-- current_thd 0x%lx", (long) graph->get_thd(), (long) current_thd)); + graph->set_thd(current_thd); + } + Field **field= table->field; KEY *key_info= table->key_info + index; int res; @@ -1129,6 +1134,11 @@ int ha_oqgraph::rename_table(const char *, const char *) ha_rows ha_oqgraph::records_in_range(uint inx, key_range *min_key, key_range *max_key) { + if (graph->get_thd() != current_thd) { + DBUG_PRINT( "oq-debug", ("g->table->in_use: 0x%lx <-- current_thd 0x%lx", (long) graph->get_thd(), (long) current_thd)); + graph->set_thd(current_thd); + } + KEY *key=table->key_info+inx; #ifdef VERBOSE_DEBUG { diff --git a/storage/oqgraph/oqgraph_thunk.cc b/storage/oqgraph/oqgraph_thunk.cc index 0e7b1f2b8ed3a..0ffd5cca41486 100644 --- a/storage/oqgraph/oqgraph_thunk.cc +++ b/storage/oqgraph/oqgraph_thunk.cc @@ -547,6 +547,9 @@ bool oqgraph3::cursor::operator!=(const cursor& x) const return record_position() != x._position; } +::THD* oqgraph3::graph::get_table_thd() { return _table->in_use; } +void oqgraph3::graph::set_table_thd(::THD* thd) { _table->in_use = thd; } + oqgraph3::graph::graph( ::TABLE* table, ::Field* source, diff --git a/storage/oqgraph/oqgraph_thunk.h b/storage/oqgraph/oqgraph_thunk.h index 11e2723af145a..7930e2d6c694f 100644 --- a/storage/oqgraph/oqgraph_thunk.h +++ b/storage/oqgraph/oqgraph_thunk.h @@ -146,6 +146,9 @@ namespace oqgraph3 ::Field* _target; ::Field* _weight; + ::THD* get_table_thd(); + void set_table_thd(::THD* thd); + graph( ::TABLE* table, ::Field* source, From c65f3238360767e1f88fb79a3af1f8fc77ae7d71 Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Wed, 5 Nov 2014 20:11:32 +1030 Subject: [PATCH 12/14] Fixed more cases for MDEV-6282 --- storage/oqgraph/ha_oqgraph.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index 7ff9e6a41d479..72fc477ddcd5a 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -780,6 +780,10 @@ int ha_oqgraph::index_read(byte * buf, const byte * key, uint key_len, enum ha_r int ha_oqgraph::index_next_same(byte *buf, const byte *key, uint key_len) { + if (graph->get_thd() != current_thd) { + DBUG_PRINT( "oq-debug", ("index_next_same g->table->in_use: 0x%lx <-- current_thd 0x%lx", (long) graph->get_thd(), (long) current_thd)); + graph->set_thd(current_thd); + } int res; open_query::row row; DBUG_ASSERT(inited==INDEX); @@ -843,7 +847,7 @@ int ha_oqgraph::index_read_idx(byte * buf, uint index, const byte * key, uint key_len, enum ha_rkey_function find_flag) { if (graph->get_thd() != current_thd) { - DBUG_PRINT( "oq-debug", ("g->table->in_use: 0x%lx <-- current_thd 0x%lx", (long) graph->get_thd(), (long) current_thd)); + DBUG_PRINT( "oq-debug", ("index_read_idx g->table->in_use: 0x%lx <-- current_thd 0x%lx", (long) graph->get_thd(), (long) current_thd)); graph->set_thd(current_thd); } @@ -1040,6 +1044,10 @@ int ha_oqgraph::rnd_init(bool scan) int ha_oqgraph::rnd_next(byte *buf) { + if (graph->get_thd() != current_thd) { + DBUG_PRINT( "oq-debug", ("rnd_next g->table->in_use: 0x%lx <-- current_thd 0x%lx", (long) graph->get_thd(), (long) current_thd)); + graph->set_thd(current_thd); + } int res; open_query::row row = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -1051,6 +1059,10 @@ int ha_oqgraph::rnd_next(byte *buf) int ha_oqgraph::rnd_pos(byte * buf, byte *pos) { + if (graph->get_thd() != current_thd) { + DBUG_PRINT( "oq-debug", ("rnd_pos g->table->in_use: 0x%lx <-- current_thd 0x%lx", (long) graph->get_thd(), (long) current_thd)); + graph->set_thd(current_thd); + } int res; open_query::row row; if (!(res= graph->fetch_row(row, pos))) From 2b9aba3b553ed13fe62d0b697ad8d2af94f8b585 Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Sat, 28 Feb 2015 22:43:04 +1030 Subject: [PATCH 13/14] Updated (C) message to 2015, and changelog --- storage/oqgraph/ha_oqgraph.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index 72fc477ddcd5a..67d052c25cda1 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -1,5 +1,5 @@ -/* Copyright (C) 2007-2014 Arjen G Lentz & Antony T Curtis for Open Query - Copyright (C) 2013-2014 Andrew McDonnell +/* Copyright (C) 2007-2015 Arjen G Lentz & Antony T Curtis for Open Query + Copyright (C) 2013-2015 Andrew McDonnell Portions of this file copyright (C) 2000-2006 MySQL AB This program is free software; you can redistribute it and/or modify @@ -29,6 +29,8 @@ * Removed compatibility hacks for 5.5.32 and 10.0.4. I expect no issues building oqgraph into Mariadb 5.5.40 but I think the better approach is maintain a separate fork / patches. * Added status variable to report if verbose debug is on + * Fixed handling of connection thread changed, the apparent root cause of + MDEV-6282, MDEV-6345 and MDEV-6784 */ From a235504b7585f863da4a86459ea1d059f72b7f7c Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Sat, 28 Feb 2015 22:43:18 +1030 Subject: [PATCH 14/14] Ensure VERBOSE_DEBUG is off by default --- storage/oqgraph/ha_oqgraph.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc index 67d052c25cda1..89bc9128c2925 100644 --- a/storage/oqgraph/ha_oqgraph.cc +++ b/storage/oqgraph/ha_oqgraph.cc @@ -58,7 +58,7 @@ #include // Uncomment this for extra debug, but expect a performance hit in large queries -#define VERBOSE_DEBUG +//#define VERBOSE_DEBUG #ifdef VERBOSE_DEBUG #else #undef DBUG_PRINT