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.
This commit is contained in:
parent
6069e780dc
commit
84d073848a
@ -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
|
||||
#
|
||||
|
@ -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 *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;
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user