52
52
/* Functions defined in this file */
54
void open_table_error(TABLE_SHARE *share, int error, int db_errno,
54
void open_table_error(TableShare *share, int error, int db_errno,
55
55
myf errortype, int errarg);
56
56
static void fix_type_pointers(const char ***array, TYPELIB *point_to_type,
57
57
uint32_t types, char **names);
159
159
share->version= refresh_version;
162
This constant is used to mark that no table map version has been
163
assigned. No arithmetic is done on the value: it will be
164
overwritten with a value taken from DRIZZLE_BIN_LOG.
166
share->table_map_version= UINT64_MAX;
169
Since alloc_table_share() can be called without any locking (for
170
example, ha_create_table... functions), we do not assign a table
171
map id here. Instead we assign a value that is not used
172
elsewhere, and then assign a table map id inside open_table()
173
under the protection of the LOCK_open mutex.
175
share->table_map_id= UINT32_MAX;
176
share->cached_row_logging_check= -1;
178
161
memcpy(&share->mem_root, &mem_root, sizeof(mem_root));
179
162
pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST);
180
163
pthread_cond_init(&share->cond, NULL);
187
Initialize share for temporary tables
190
init_tmp_table_share()
191
session thread handle
193
key Table_cache_key, as generated from create_table_def_key.
194
must start with db name.
195
key_length Length of key
196
table_name Table name
197
path Path to file (possible in lower case) without .frm
200
This is different from alloc_table_share() because temporary tables
201
don't have to be shared between threads or put into the table def
202
cache, so we can do some things notable simpler and faster
204
If table is not put in session->temporary_tables (happens only when
205
one uses OPEN TEMPORARY) then one can specify 'db' as key and
206
use key_length= 0 as neither table_cache_key or key_length will be used).
209
void init_tmp_table_share(Session *session, TABLE_SHARE *share, const char *key,
210
uint32_t key_length, const char *table_name,
214
memset(share, 0, sizeof(*share));
215
init_sql_alloc(&share->mem_root, TABLE_ALLOC_BLOCK_SIZE, 0);
216
share->table_category= TABLE_CATEGORY_TEMPORARY;
217
share->tmp_table= INTERNAL_TMP_TABLE;
218
share->db.str= (char*) key;
219
share->db.length= strlen(key);
220
share->table_cache_key.str= (char*) key;
221
share->table_cache_key.length= key_length;
222
share->table_name.str= (char*) table_name;
223
share->table_name.length= strlen(table_name);
224
share->path.str= (char*) path;
225
share->normalized_path.str= (char*) path;
226
share->path.length= share->normalized_path.length= strlen(path);
229
Temporary tables are not replicated, but we set up these fields
230
anyway to be able to catch errors.
232
share->table_map_version= ~(uint64_t)0;
233
share->cached_row_logging_check= -1;
236
table_map_id is also used for MERGE tables to suppress repeated
237
compatibility checks.
239
share->table_map_id= (ulong) session->query_id;
246
Free table share and memory used by it
253
share->mutex must be locked when we come here if it's not a temp table
256
void free_table_share(TABLE_SHARE *share)
259
assert(share->ref_count == 0);
262
If someone is waiting for this to be deleted, inform it about this.
263
Don't do a delete until we know that no one is refering to this anymore.
265
if (share->tmp_table == NO_TMP_TABLE)
267
/* share->mutex is locked in release_table_share() */
268
while (share->waiting_on_cond)
270
pthread_cond_broadcast(&share->cond);
271
pthread_cond_wait(&share->cond, &share->mutex);
273
/* No thread refers to this anymore */
274
pthread_mutex_unlock(&share->mutex);
275
pthread_mutex_destroy(&share->mutex);
276
pthread_cond_destroy(&share->cond);
278
hash_free(&share->name_hash);
280
share->storage_engine= NULL;
282
/* We must copy mem_root from share because share is allocated through it */
283
memcpy(&mem_root, &share->mem_root, sizeof(mem_root));
284
free_root(&mem_root, MYF(0)); // Free's share
288
169
enum_field_types proto_field_type_to_drizzle_type(uint32_t proto_field_type)
290
171
enum_field_types field_type;
1454
1334
7 Table definition has changed in engine
1457
int open_table_from_share(Session *session, TABLE_SHARE *share, const char *alias,
1337
int open_table_from_share(Session *session, TableShare *share, const char *alias,
1458
1338
uint32_t db_stat, uint32_t prgflag, uint32_t ha_open_flags,
1459
1339
Table *outparam, open_table_mode open_mode)