Commit 97954225 authored by andrew's avatar andrew

MDEV-5996 - fix odd behaviour of some combinations of table and database names

parent 965bebcd
......@@ -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;
......
# 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`;
}
# 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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment