166
Create a list for all open tables matching SQL expression
170
wild SQL like expression
173
One gets only a list of tables for which one has any kind of privilege.
174
db and table names are allocated in result struct, so one doesn't need
175
a lock on LOCK_open when traversing the return list.
181
bool list_open_tables(const char *db,
183
bool(*func)(Table *table,
184
open_table_list_st& open_list,
185
plugin::InfoSchemaTable *schema_table),
187
plugin::InfoSchemaTable *schema_table)
189
vector<open_table_list_st> open_list;
190
vector<open_table_list_st>::iterator it;
191
open_table_list_st table;
193
/* What we really need is an optimization for knowing unique tables */
195
open_list.reserve(sizeof(open_table_list_st) * (open_cache.records % 2));
197
open_list.reserve(sizeof(open_table_list_st) * open_cache.records);
199
pthread_mutex_lock(&LOCK_open); /* List all open tables */
201
for (uint32_t idx= 0; idx < open_cache.records; idx++)
204
Table *entry=(Table*) hash_element(&open_cache,idx);
206
if (db && my_strcasecmp(system_charset_info, db, entry->s->db.str))
208
if (wild && internal::wild_compare(entry->s->table_name.str, wild, 0))
211
for (it= open_list.begin(); it < open_list.end(); it++)
213
if (!(*it).table.compare(entry->s->table_name.str) &&
214
!(*it).db.compare(entry->s->db.str))
218
if (entry->locked_by_name)
230
table.db= entry->s->db.str;
231
table.table= entry->s->table_name.str;
232
open_list.push_back(table);
234
pthread_mutex_unlock(&LOCK_open);
236
for (it= open_list.begin(); it < open_list.end(); it++)
238
if (func(display, *it, schema_table))
245
164
/*****************************************************************************
246
165
* Functions to free open table cache
247
166
****************************************************************************/