156
156
memset(share, 0, sizeof(*share));
157
157
share->set_table_cache_key(key_buff, old_share->table_cache_key.str,
158
158
old_share->table_cache_key.length);
159
share->tmp_table= message::Table::INTERNAL; // for intern_close_table()
159
share->tmp_table= INTERNAL_TMP_TABLE; // for intern_close_table()
162
162
table->cursor->close();
492
492
for (; table; table= table->*link )
494
if ((table->table == 0 || table->table->s->tmp_table == message::Table::STANDARD) &&
495
strcasecmp(table->db, db_name) == 0 &&
496
strcasecmp(table->table_name, table_name) == 0)
494
if ((table->table == 0 || table->table->s->tmp_table == STANDARD_TABLE) &&
495
strcmp(table->db, db_name) == 0 &&
496
strcmp(table->table_name, table_name) == 0)
555
555
if (table->table)
557
557
/* temporary table is always unique */
558
if (table->table && table->table->s->tmp_table != message::Table::STANDARD)
558
if (table->table && table->table->s->tmp_table != STANDARD_TABLE)
560
560
table= table->find_underlying_table(table->table);
589
void Session::doGetTableNames(SchemaIdentifier &schema_identifier,
589
void Session::doGetTableNames(CachedDirectory &,
590
const std::string& db_name,
590
591
std::set<std::string>& set_of_names)
592
593
for (Table *table= temporary_tables ; table ; table= table->next)
594
if (schema_identifier.compare(table->s->getSchemaName()))
595
if (not db_name.compare(table->s->getSchemaName()))
596
597
set_of_names.insert(table->s->table_name.str);
601
void Session::doGetTableNames(CachedDirectory &,
602
SchemaIdentifier &schema_identifier,
603
std::set<std::string> &set_of_names)
605
doGetTableNames(schema_identifier, set_of_names);
608
void Session::doGetTableIdentifiers(SchemaIdentifier &schema_identifier,
609
TableIdentifiers &set_of_identifiers)
611
for (Table *table= temporary_tables ; table ; table= table->next)
613
if (schema_identifier.compare(table->s->getSchemaName()))
615
set_of_identifiers.push_back(TableIdentifier(table->getShare()->getSchemaName(),
616
table->getShare()->getTableName(),
617
table->getShare()->getPath()));
622
void Session::doGetTableIdentifiers(CachedDirectory &,
623
SchemaIdentifier &schema_identifier,
624
TableIdentifiers &set_of_identifiers)
626
doGetTableIdentifiers(schema_identifier, set_of_identifiers);
629
602
bool Session::doDoesTableExist(TableIdentifier &identifier)
631
604
for (Table *table= temporary_tables ; table ; table= table->next)
633
if (table->s->tmp_table == message::Table::TEMPORARY)
606
if (table->s->tmp_table == TEMP_TABLE)
635
if (identifier.compare(table->s->getSchemaName(), table->s->table_name.str))
608
if (not identifier.getSchemaName().compare(table->s->getSchemaName()))
610
if (not identifier.getTableName().compare(table->s->table_name.str))
648
624
for (Table *table= temporary_tables ; table ; table= table->next)
650
if (table->s->tmp_table == message::Table::TEMPORARY)
626
if (table->s->tmp_table == TEMP_TABLE)
652
if (identifier.compare(table->s->getSchemaName(), table->s->table_name.str))
628
if (not identifier.getSchemaName().compare(table->s->getSchemaName()))
654
table_proto.CopyFrom(*(table->s->getTableProto()));
630
if (not identifier.getTableName().compare(table->s->table_name.str))
632
table_proto.CopyFrom(*(table->s->getTableProto()));
1347
1326
if (table_list->create)
1349
TableIdentifier lock_table_identifier(table_list->db, table_list->table_name, message::Table::STANDARD);
1328
TableIdentifier lock_table_identifier(table_list->db, table_list->table_name, STANDARD_TABLE);
1351
1330
if (not plugin::StorageEngine::doesTableExist(*this, lock_table_identifier))
1400
1379
table->reginfo.lock_type= TL_READ; /* Assume read */
1403
assert(table->s->ref_count > 0 || table->s->tmp_table != message::Table::STANDARD);
1382
assert(table->s->ref_count > 0 || table->s->tmp_table != STANDARD_TABLE);
1405
1384
if (lex->need_correct_ident())
1406
1385
table->alias_name_used= my_strcasecmp(table_alias_charset,
1541
1520
the strings are used in a loop even after the share may be freed.
1544
void Session::close_data_files_and_morph_locks(TableIdentifier &identifier)
1546
close_data_files_and_morph_locks(identifier.getSchemaName().c_str(), identifier.getTableName().c_str());
1549
1523
void Session::close_data_files_and_morph_locks(const char *new_db, const char *new_table_name)
1570
1544
for (table= open_tables; table ; table=table->next)
1572
1546
if (!strcmp(table->s->table_name.str, new_table_name) &&
1573
!strcasecmp(table->s->getSchemaName(), new_db))
1547
!strcmp(table->s->getSchemaName(), new_db))
1575
1549
table->open_placeholder= true;
1576
1550
close_handle_and_leave_table_as_lock(table);
1887
1861
next=table->next;
1888
1862
if (!strcmp(table->s->table_name.str, table_name) &&
1889
!strcasecmp(table->s->getSchemaName(), db))
1863
!strcmp(table->s->getSchemaName(), db))
1891
1865
mysql_lock_remove(session, table);
2151
2125
if (tables->lock_type == TL_WRITE_DEFAULT)
2152
2126
tables->table->reginfo.lock_type= update_lock_default;
2153
else if (tables->table->s->tmp_table == message::Table::STANDARD)
2127
else if (tables->table->s->tmp_table == STANDARD_TABLE)
2154
2128
tables->table->reginfo.lock_type= tables->lock_type;
2314
2288
uint32_t key_length, path_length;
2315
2289
TableList table_list;
2317
table_list.db= const_cast<char*>(identifier.getSchemaName().c_str());
2318
table_list.table_name= const_cast<char*>(identifier.getTableName().c_str());
2291
table_list.db= (char*) identifier.getDBName().c_str();
2292
table_list.table_name= (char*) identifier.getTableName().c_str();
2319
2293
/* Create the cache_key for temporary tables */
2320
2294
key_length= table_list.create_table_def_key(cache_key);
2321
2295
path_length= identifier.getPath().length();
4105
4079
assert(tables->is_leaf_for_name_resolution());
4107
4081
if ((table_name && my_strcasecmp(table_alias_charset, table_name, tables->alias)) ||
4108
(db_name && strcasecmp(tables->db,db_name)))
4082
(db_name && strcmp(tables->db,db_name)))
4458
4432
and afterwards delete those marked unused.
4461
void remove_db_from_cache(SchemaIdentifier &schema_identifier)
4435
void remove_db_from_cache(const std::string schema_name)
4463
4437
safe_mutex_assert_owner(&LOCK_open);
4465
4439
for (uint32_t idx=0 ; idx < open_cache.records ; idx++)
4467
4441
Table *table=(Table*) hash_element(&open_cache,idx);
4468
if (not schema_identifier.getPath().compare(table->s->getSchemaName()))
4442
if (not schema_name.compare(table->s->getSchemaName()))
4470
4444
table->s->version= 0L; /* Free when thread is ready */
4471
4445
if (not table->in_use)