Commit 84d07384 authored by Sergey Vojtovich's avatar Sergey Vojtovich

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.
parent 6069e780
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
drop table t0; drop table t0;
show status like 'Handler_discover'; show status like 'Handler_discover';
Variable_name Value Variable_name Value
-Handler_discover 7 -Handler_discover 6
+Handler_discover 8 +Handler_discover 7
# #
# Bug#45377: ARCHIVE tables aren't discoverable after OPTIMIZE # Bug#45377: ARCHIVE tables aren't discoverable after OPTIMIZE
# #
...@@ -40,18 +40,25 @@ static struct st_mysql_sys_var *sysvars[] = { ...@@ -40,18 +40,25 @@ static struct st_mysql_sys_var *sysvars[] = {
NULL NULL
}; };
typedef struct st_share { class SHARE : public Handler_share {
const char *name; public:
THR_LOCK lock; THR_LOCK lock;
uint use_count; SHARE()
struct st_share *next; {
} SHARE; thr_lock_init(&lock);
}
~SHARE()
{
thr_lock_delete(&lock);
}
};
class ha_tsd: public handler class ha_tsd: public handler
{ {
private: private:
THR_LOCK_DATA lock; THR_LOCK_DATA lock;
SHARE *share; SHARE *share;
SHARE *get_share();
public: public:
ha_tsd(handlerton *hton, TABLE_SHARE *table_arg) ha_tsd(handlerton *hton, TABLE_SHARE *table_arg)
...@@ -87,39 +94,34 @@ class ha_tsd: public handler ...@@ -87,39 +94,34 @@ class ha_tsd: public handler
int close(void); int close(void);
}; };
static SHARE *find_or_create_share(const char *table_name, TABLE *table) SHARE *ha_tsd::get_share()
{ {
SHARE *share; SHARE *tmp_share;
for (share = (SHARE*)table->s->ha_data; share; share = share->next) lock_shared_ha_data();
if (my_strcasecmp(table_alias_charset, table_name, share->name) == 0) if (!(tmp_share= static_cast<SHARE*>(get_ha_share_ptr())))
return share; {
tmp_share= new SHARE;
share = (SHARE*)alloc_root(&table->s->mem_root, sizeof(*share)); if (!tmp_share)
bzero(share, sizeof(*share)); goto err;
share->name = strdup_root(&table->s->mem_root, table_name);
share->next = (SHARE*)table->s->ha_data; set_ha_share_ptr(static_cast<Handler_share*>(tmp_share));
table->s->ha_data = share; }
return share; err:
unlock_shared_ha_data();
return tmp_share;
} }
int ha_tsd::open(const char *name, int mode, uint test_if_locked) int ha_tsd::open(const char *name, int mode, uint test_if_locked)
{ {
mysql_mutex_lock(&table->s->LOCK_ha_data); if (!(share= get_share()))
share = find_or_create_share(name, table); return HA_ERR_OUT_OF_MEM;
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);
thr_lock_data_init(&share->lock,&lock,NULL);
return 0; return 0;
} }
int ha_tsd::close(void) 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; return 0;
} }
......
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