summaryrefslogtreecommitdiff
path: root/storage/test_sql_discovery
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2013-07-23 18:03:23 +0400
committerSergey Vojtovich <svoj@mariadb.org>2013-07-23 18:03:23 +0400
commit84d073848a76e15bdd02c54f5c0965156eb6f095 (patch)
treee99005d449524539c7af075c870eefc9a94a7d0a /storage/test_sql_discovery
parent6069e780dcc4848ae795267ea26300ff8c1bb65b (diff)
downloadmariadb-git-84d073848a76e15bdd02c54f5c0965156eb6f095.tar.gz
MDEV-4786 - merge 10.0-monty → 10.0
Fixed test_sql_discovery compilation failure. storage/test_sql_discovery/mysql-test/archive/discover.rdiff: archive.discover result has changed during merge. Adjusted discover.rdiff accordingly. storage/test_sql_discovery/test_sql_discovery.cc: Adjusted test_sql_discovery according to: WL#4305 - storage-engine private data area per physical table.
Diffstat (limited to 'storage/test_sql_discovery')
-rw-r--r--storage/test_sql_discovery/mysql-test/archive/discover.rdiff4
-rw-r--r--storage/test_sql_discovery/test_sql_discovery.cc56
2 files changed, 31 insertions, 29 deletions
diff --git a/storage/test_sql_discovery/mysql-test/archive/discover.rdiff b/storage/test_sql_discovery/mysql-test/archive/discover.rdiff
index 3148999079f..c8be9fde63e 100644
--- a/storage/test_sql_discovery/mysql-test/archive/discover.rdiff
+++ b/storage/test_sql_discovery/mysql-test/archive/discover.rdiff
@@ -28,8 +28,8 @@
drop table t0;
show status like 'Handler_discover';
Variable_name Value
--Handler_discover 7
-+Handler_discover 8
+-Handler_discover 6
++Handler_discover 7
#
# Bug#45377: ARCHIVE tables aren't discoverable after OPTIMIZE
#
diff --git a/storage/test_sql_discovery/test_sql_discovery.cc b/storage/test_sql_discovery/test_sql_discovery.cc
index 33438035b8d..5c4294dc49b 100644
--- a/storage/test_sql_discovery/test_sql_discovery.cc
+++ b/storage/test_sql_discovery/test_sql_discovery.cc
@@ -40,18 +40,25 @@ static struct st_mysql_sys_var *sysvars[] = {
NULL
};
-typedef struct st_share {
- const char *name;
+class SHARE : public Handler_share {
+public:
THR_LOCK lock;
- uint use_count;
- struct st_share *next;
-} SHARE;
+ SHARE()
+ {
+ thr_lock_init(&lock);
+ }
+ ~SHARE()
+ {
+ thr_lock_delete(&lock);
+ }
+};
class ha_tsd: public handler
{
private:
THR_LOCK_DATA lock;
SHARE *share;
+ SHARE *get_share();
public:
ha_tsd(handlerton *hton, TABLE_SHARE *table_arg)
@@ -87,39 +94,34 @@ public:
int close(void);
};
-static SHARE *find_or_create_share(const char *table_name, TABLE *table)
+SHARE *ha_tsd::get_share()
{
- SHARE *share;
- for (share = (SHARE*)table->s->ha_data; share; share = share->next)
- if (my_strcasecmp(table_alias_charset, table_name, share->name) == 0)
- return share;
-
- share = (SHARE*)alloc_root(&table->s->mem_root, sizeof(*share));
- bzero(share, sizeof(*share));
- share->name = strdup_root(&table->s->mem_root, table_name);
- share->next = (SHARE*)table->s->ha_data;
- table->s->ha_data = share;
- return share;
+ SHARE *tmp_share;
+ lock_shared_ha_data();
+ if (!(tmp_share= static_cast<SHARE*>(get_ha_share_ptr())))
+ {
+ tmp_share= new SHARE;
+ if (!tmp_share)
+ goto err;
+
+ set_ha_share_ptr(static_cast<Handler_share*>(tmp_share));
+ }
+err:
+ unlock_shared_ha_data();
+ return tmp_share;
}
int ha_tsd::open(const char *name, int mode, uint test_if_locked)
{
- mysql_mutex_lock(&table->s->LOCK_ha_data);
- share = find_or_create_share(name, table);
- if (share->use_count++ == 0)
- thr_lock_init(&share->lock);
- mysql_mutex_unlock(&table->s->LOCK_ha_data);
- thr_lock_data_init(&share->lock,&lock,NULL);
+ if (!(share= get_share()))
+ return HA_ERR_OUT_OF_MEM;
+ thr_lock_data_init(&share->lock,&lock,NULL);
return 0;
}
int ha_tsd::close(void)
{
- mysql_mutex_lock(&table->s->LOCK_ha_data);
- if (--share->use_count == 0)
- thr_lock_delete(&share->lock);
- mysql_mutex_unlock(&table->s->LOCK_ha_data);
return 0;
}