summaryrefslogtreecommitdiff
path: root/storage/oqgraph
diff options
context:
space:
mode:
authorandrew <andrew@atlantis4.andrewmcdonnell.net>2014-04-07 22:16:02 +0930
committerandrew <andrew@atlantis4.andrewmcdonnell.net>2014-04-07 22:16:02 +0930
commit97954225aeb6f4a35d2eb97cdc9061d3ea147459 (patch)
tree36a9d283b0c3b4fe8891e68d129a965f80f0d3a5 /storage/oqgraph
parent965bebcdaf4dcc368d5b9ccce62a39defc5ba9a9 (diff)
downloadmariadb-git-97954225aeb6f4a35d2eb97cdc9061d3ea147459.tar.gz
MDEV-5996 - fix odd behaviour of some combinations of table and database names
Diffstat (limited to 'storage/oqgraph')
-rw-r--r--storage/oqgraph/ha_oqgraph.cc4
-rw-r--r--storage/oqgraph/mysql-test/oqgraph/regression_mdev5996.inc53
-rw-r--r--storage/oqgraph/mysql-test/oqgraph/regression_mdev5996.test33
3 files changed, 89 insertions, 1 deletions
diff --git a/storage/oqgraph/ha_oqgraph.cc b/storage/oqgraph/ha_oqgraph.cc
index 650be75ceda..aa7e5c5a322 100644
--- a/storage/oqgraph/ha_oqgraph.cc
+++ b/storage/oqgraph/ha_oqgraph.cc
@@ -557,9 +557,11 @@ int ha_oqgraph::open(const char *name, int mode, uint test_if_locked)
size_t tlen= strlen(options->table_name);
size_t plen= (int)(p - name) + tlen + 1;
- share->path.str= (char*)alloc_root(&share->mem_root, plen);
+ share->path.str= (char*)alloc_root(&share->mem_root, plen + 1); // MDEV-5996 space for trailing zero
+ // it seems there was a misunderstanding of why there is a separate length field in the String object
strmov(strnmov(share->path.str, name, (int)(p - name) + 1), options->table_name);
+ share->path.str[plen] = 0; // MDEV-5996 Make sure the pointer is zero terminated. I really think this needs refactoring, soon...
share->normalized_path.str= share->path.str;
share->path.length= share->normalized_path.length= plen;
diff --git a/storage/oqgraph/mysql-test/oqgraph/regression_mdev5996.inc b/storage/oqgraph/mysql-test/oqgraph/regression_mdev5996.inc
new file mode 100644
index 00000000000..c0e4aa752fb
--- /dev/null
+++ b/storage/oqgraph/mysql-test/oqgraph/regression_mdev5996.inc
@@ -0,0 +1,53 @@
+# Regression test for https://mariadb.atlassian.net/browse/MDEV-5996
+--echo Performing OQGraph regression test mdev5996 - using db=`$oqgraph_database_name`, table=`$oqgraph_table_name`
+
+--disable_warnings
+use test;
+if ($oqgraph_database_name) {
+ eval drop database if exists `$oqgraph_database_name` ;
+ eval create database `$oqgraph_database_name` ;
+ eval use `$oqgraph_database_name` ;
+}
+eval drop table if exists `$oqgraph_table_name` ;
+drop table if exists vvvvvvv_hhhhhhh;
+--enable_warnings
+
+eval CREATE TABLE `$oqgraph_table_name` (
+ `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 `prevVersion` (`prevVersion`) USING BTREE,
+ KEY `version` (`version`) USING BTREE,
+ KEY `nodeID` (`nodeID`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+eval insert into `$oqgraph_table_name` values ( 'x', 'y', 'z', 0, 0);
+
+eval select * from `$oqgraph_table_name`;
+
+eval CREATE TABLE IF NOT EXISTS vvvvvvv_hhhhhhh (
+ 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='$oqgraph_table_name'
+ origid='prevNodeID'
+ destid='nodeID';
+
+select * from vvvvvvv_hhhhhhh;
+
+eval drop table if exists `$oqgraph_table_name`;
+drop table if exists vvvvvvv_hhhhhhh;
+
+if ($oqgraph_database_name) {
+ eval drop database if exists `$oqgraph_database_name`;
+}
+
diff --git a/storage/oqgraph/mysql-test/oqgraph/regression_mdev5996.test b/storage/oqgraph/mysql-test/oqgraph/regression_mdev5996.test
new file mode 100644
index 00000000000..e5d04ef357d
--- /dev/null
+++ b/storage/oqgraph/mysql-test/oqgraph/regression_mdev5996.test
@@ -0,0 +1,33 @@
+# Regression test for https://mariadb.atlassian.net/browse/MDEV-5996
+# MidSchipDB_unstable
+--let $oqgraph_table_name= 999999999
+
+--let $oqgraph_database_name=
+--source regression_mdev5996.inc
+
+--let $oqgraph_database_name= 1
+--source regression_mdev5996.inc
+
+# Various cases - although actual bug was a broken zero termination
+# name of backing store shorter, same and longer than table
+
+--let $oqgraph_database_name= 1112222233_4444444
+--source regression_mdev5996.inc
+
+--let $oqgraph_database_name= 1112222233_44444444
+--source regression_mdev5996.inc
+
+--let $oqgraph_database_name= 1112222233_444444444
+--source regression_mdev5996.inc
+
+--let $oqgraph_table_name= 99999999
+--source regression_mdev5996.inc
+
+--let $oqgraph_table_name= 9999999999
+--source regression_mdev5996.inc
+
+# Fails:
+
+# 1/9999
+# test/99999999
+# 1112222233_444444444/999999999