From e32dafe77870ae8d4da2aae2321f3e03fa1d1f98 Mon Sep 17 00:00:00 2001 From: Andrew McDonnell Date: Thu, 30 Oct 2014 22:47:48 +1030 Subject: [PATCH] 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 3ff32d0e233..2f182341b39 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 de575c9da65..73433fc8219 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 f7eff77d8b1..b1560552fcf 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 833143dd57c..7ff9e6a41d4 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 0e7b1f2b8ed..0ffd5cca414 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 11e2723af14..7930e2d6c69 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,