40
43
TYPELIB *intervals; /* pointer to interval info */
41
44
pthread_mutex_t mutex; /* For locking the share */
42
45
pthread_cond_t cond; /* To signal that share is ready */
43
TABLE_SHARE *next, /* Link to unused shares */
46
TableShare *next, /* Link to unused shares */
46
49
/* The following is copied to each Table on OPEN */
132
134
bool name_lock, replace_with_name_lock;
133
135
bool waiting_on_cond; /* Protection against free */
134
uint32_t table_map_id; /* for row-based replication */
135
uint64_t table_map_version;
138
Cache for row-based replication table share checks that does not
139
need to be repeated. Possible values are: -1 when cache value is
140
not calculated yet, 0 when table *shall not* be replicated, 1 when
141
table *may* be replicated.
143
int cached_row_logging_check;
146
138
Set share's table cache key and update its db and table name appropriately.
199
191
return (table_category == TABLE_CATEGORY_USER);
202
inline uint32_t get_table_def_version()
196
Initialize share for temporary tables
201
key Table_cache_key, as generated from create_table_def_key.
202
must start with db name.
203
key_length Length of key
204
table_name Table name
205
path Path to file (possible in lower case) without .frm
208
This is different from alloc_table_share() because temporary tables
209
don't have to be shared between threads or put into the table def
210
cache, so we can do some things notable simpler and faster
212
If table is not put in session->temporary_tables (happens only when
213
one uses OPEN TEMPORARY) then one can specify 'db' as key and
214
use key_length= 0 as neither table_cache_key or key_length will be used).
222
void init(const char *new_table_name,
223
const char *new_path)
225
init("", 0, new_table_name, new_path);
228
void init(const char *key,
229
uint32_t key_length, const char *new_table_name,
230
const char *new_path)
232
memset(this, 0, sizeof(TableShare));
233
init_sql_alloc(&mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
234
table_category= TABLE_CATEGORY_TEMPORARY;
235
tmp_table= INTERNAL_TMP_TABLE;
237
db.length= strlen(key);
238
table_cache_key.str= (char*) key;
239
table_cache_key.length= key_length;
240
table_name.str= (char*) new_table_name;
241
table_name.length= strlen(new_table_name);
242
path.str= (char*) new_path;
243
normalized_path.str= (char*) new_path;
244
path.length= normalized_path.length= strlen(new_path);
250
Free table share and memory used by it
257
share->mutex must be locked when we come here if it's not a temp table
260
void free_table_share()
262
MEM_ROOT new_mem_root;
263
assert(ref_count == 0);
266
If someone is waiting for this to be deleted, inform it about this.
267
Don't do a delete until we know that no one is refering to this anymore.
269
if (tmp_table == NO_TMP_TABLE)
271
/* share->mutex is locked in release_table_share() */
272
while (waiting_on_cond)
274
pthread_cond_broadcast(&cond);
275
pthread_cond_wait(&cond, &mutex);
277
/* No thread refers to this anymore */
278
pthread_mutex_unlock(&mutex);
279
pthread_mutex_destroy(&mutex);
280
pthread_cond_destroy(&cond);
282
hash_free(&name_hash);
284
storage_engine= NULL;
286
/* We must copy mem_root from share because share is allocated through it */
287
memcpy(&new_mem_root, &mem_root, sizeof(new_mem_root));
288
free_root(&new_mem_root, MYF(0)); // Free's share