66
66
@defgroup Data_Dictionary Data Dictionary
69
Table *unused_tables; /* Used by mysql_test */
70
70
HASH open_cache; /* Used by mysql_test */
73
Table *tables; /* Used by mysql_test */
75
Table *getTable() const
80
Table *setTable(Table *arg)
89
/* Free cache if too big */
90
while (open_cache.records > table_cache_size && getTable())
91
hash_delete(&open_cache,(unsigned char*) getTable());
96
while (getTable() && not getTable()->getShare()->getVersion())
97
hash_delete(&open_cache,(unsigned char*) getTable());
100
void link(Table *table)
104
table->setNext(getTable()); /* Link in last */
105
table->setPrev(getTable()->getPrev());
106
getTable()->setPrev(table);
107
table->getPrev()->setNext(table);
111
table->setPrev(setTable(table));
112
table->setNext(table->getPrev());
113
assert(table->getNext() == table && table->getPrev() == table);
118
void unlink(Table *table)
122
/* Unlink the table from "unused_tables" list. */
123
if (table == getTable())
125
setTable(getTable()->getNext()); // Remove from link
126
if (table == getTable())
131
/* move table first in unused links */
133
void relink(Table *table)
135
if (table != getTable())
139
table->setNext(getTable()); /* Link in unused tables */
140
table->setPrev(getTable()->getPrev());
141
getTable()->getPrev()->setNext(table);
142
getTable()->setPrev(table);
151
hash_delete(&open_cache, (unsigned char*) getTable());
163
static UnusedTables unused_tables;
71
164
static int open_unireg_entry(Session *session,
73
166
const char *alias,
196
288
table->intern_close_table();
197
289
if (not table->in_use)
199
table->getNext()->setPrev(table->getPrev()); /* remove from used chain */
200
table->getPrev()->setNext(table->getNext());
201
if (table == unused_tables)
203
unused_tables= unused_tables->getNext();
204
if (table == unused_tables)
291
unused_tables.unlink(table);
209
294
if (table->isPlaceHolder())
435
518
table->cursor->ha_reset();
436
519
table->in_use= false;
440
table->setNext(unused_tables); /* Link in last */
441
table->setPrev(unused_tables->getPrev());
442
unused_tables->setPrev(table);
443
table->getPrev()->setNext(table);
447
table->setPrev(unused_tables= table);
448
table->setNext(table->getPrev());
521
unused_tables.link(table);
452
524
return found_old_table;
764
/* move table first in unused links */
766
static void relink_unused(Table *table)
768
if (table != unused_tables)
770
table->getPrev()->setNext(table->getNext()); /* Remove from unused list */
771
table->getNext()->setPrev(table->getPrev());
772
table->setNext(unused_tables); /* Link in unused tables */
773
table->setPrev(unused_tables->getPrev());
774
unused_tables->getPrev()->setNext(table);
775
unused_tables->setPrev(table);
776
unused_tables= table;
782
837
Remove all instances of table from thread's open list and
1327
/* Unlink the table from "unused_tables" list. */
1328
if (table == unused_tables)
1330
unused_tables= unused_tables->getNext(); // Remove from link
1331
if (table == unused_tables)
1332
unused_tables= NULL;
1334
table->getPrev()->setNext(table->getNext()); /* Remove from unused list */
1335
table->getNext()->setPrev(table->getPrev());
1382
unused_tables.unlink(table);
1336
1383
table->in_use= this;
1340
1387
/* Insert a new Table instance into the open cache */
1342
1389
/* Free cache if too big */
1343
while (open_cache.records > table_cache_size && unused_tables)
1344
hash_delete(&open_cache,(unsigned char*) unused_tables);
1390
unused_tables.cull();
1346
1392
if (table_list->create)
4454
4500
table->getMutableShare()->resetVersion(); /* Free when thread is ready */
4455
4501
if (not table->in_use)
4456
relink_unused(table);
4502
unused_tables.relink(table);
4459
while (unused_tables && !unused_tables->getShare()->getVersion())
4460
hash_delete(&open_cache,(unsigned char*) unused_tables);
4506
unused_tables.cullByVersion();
4537
4583
result= result || (flags & RTFC_OWNED_BY_Session_FLAG);
4539
while (unused_tables && !unused_tables->getShare()->getVersion())
4540
hash_delete(&open_cache,(unsigned char*) unused_tables);
4586
unused_tables.cullByVersion();
4542
4588
/* Remove table from table definition cache if it's not in use */
4543
4589
TableShare::release(identifier);