summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--storage/oqgraph/ha_oqgraph.cc4
-rw-r--r--storage/oqgraph/mysql-test/oqgraph/connections_mdev5748.result32
-rw-r--r--storage/oqgraph/mysql-test/oqgraph/connections_mdev5748.test37
3 files changed, 73 insertions, 0 deletions
diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc
index 12a39e0f230..650be75ceda 100644
--- a/storage/oqgraph/ha_oqgraph.cc
+++ b/storage/oqgraph/ha_oqgraph.cc
@@ -538,7 +538,11 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked)
origid= destid= weight= 0;
+ // Here we're abusing init_tmp_table_share() which is normally only works for thread-local shares.
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
+ init_sql_alloc(&share->mem_root, TABLE_ALLOC_BLOCK_SIZE, 0, MYF(0));
// What I think this code is doing:
// * Our OQGRAPH table is `database_blah/name`
diff --git a/storage/oqgraph/mysql-test/oqgraph/connections_mdev5748.result b/storage/oqgraph/mysql-test/oqgraph/connections_mdev5748.result
new file mode 100644
index 00000000000..3d9c13bd733
--- /dev/null
+++ b/storage/oqgraph/mysql-test/oqgraph/connections_mdev5748.result
@@ -0,0 +1,32 @@
+CREATE TABLE oq_backing (
+origid INT UNSIGNED NOT NULL,
+destid INT UNSIGNED NOT NULL,
+weight DOUBLE NOT NULL,
+PRIMARY KEY (origid, destid),
+KEY (destid)
+);
+CREATE TABLE oq_table (
+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' weight='weight';
+flush tables;
+show fields in oq_table;
+Field Type Null Key Default Extra
+latch varchar(32) YES MUL NULL
+origid bigint(20) unsigned YES NULL
+destid bigint(20) unsigned YES NULL
+weight double YES NULL
+seq bigint(20) unsigned YES NULL
+linkid bigint(20) unsigned YES NULL
+show tables;
+Tables_in_test
+oq_backing
+oq_table
+drop table oq_table, oq_backing;
diff --git a/storage/oqgraph/mysql-test/oqgraph/connections_mdev5748.test b/storage/oqgraph/mysql-test/oqgraph/connections_mdev5748.test
new file mode 100644
index 00000000000..9d7fab722c0
--- /dev/null
+++ b/storage/oqgraph/mysql-test/oqgraph/connections_mdev5748.test
@@ -0,0 +1,37 @@
+#
+# MDEV-5748 Assertion `status_var.memory_used == 0' fails on disconnect after opening an OQGRAPH table
+#
+
+# try to open oqgraph table in one connection and use in another:
+
+--connect (con1,localhost,root,,)
+
+CREATE TABLE oq_backing (
+ origid INT UNSIGNED NOT NULL,
+ destid INT UNSIGNED NOT NULL,
+ weight DOUBLE NOT NULL,
+ PRIMARY KEY (origid, destid),
+ KEY (destid)
+);
+
+CREATE TABLE oq_table (
+ 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' weight='weight';
+
+flush tables;
+show fields in oq_table;
+--disconnect con1
+
+--connection default
+show tables;
+
+drop table oq_table, oq_backing;
+