593
593
for (Table *table= temporary_tables ; table ; table= table->next)
595
if (not db_name.compare(table->s->db.str))
595
if (not db_name.compare(table->s->getSchemaName()))
597
597
set_of_names.insert(table->s->table_name.str);
602
int Session::doGetTableDefinition(const char *,
604
const char *table_name_arg,
606
message::Table *table_proto)
608
for (Table *table= temporary_tables ; table ; table= table->next)
610
if (table->s->tmp_table == TEMP_TABLE)
612
if (not strcmp(db_arg, table->s->db.str))
614
if (not strcmp(table_name_arg, table->s->table_name.str))
617
table_proto->CopyFrom(*(table->s->getTableProto()));
602
bool Session::doDoesTableExist(TableIdentifier &identifier)
604
for (Table *table= temporary_tables ; table ; table= table->next)
606
if (table->s->tmp_table == TEMP_TABLE)
608
if (not strcmp(identifier.getSchemaName().c_str(), table->s->getSchemaName()))
610
if (not strcmp(identifier.getTableName().c_str(), table->s->table_name.str))
621
int Session::doGetTableDefinition(TableIdentifier &identifier,
622
message::Table &table_proto)
624
for (Table *table= temporary_tables ; table ; table= table->next)
626
if (table->s->tmp_table == TEMP_TABLE)
628
if (not strcmp(identifier.getSchemaName().c_str(), table->s->getSchemaName()))
630
if (not strcmp(identifier.getTableName().c_str(), table->s->table_name.str))
632
table_proto.CopyFrom(*(table->s->getTableProto()));
1002
1017
@retval true Error occured (OOM)
1003
1018
@retval false Success. 'table' parameter set according to above rules.
1020
bool Session::lock_table_name_if_not_cached(TableIdentifier &identifier, Table **table)
1022
return lock_table_name_if_not_cached(identifier.getSchemaName().c_str(), identifier.getTableName().c_str(), table);
1006
1025
bool Session::lock_table_name_if_not_cached(const char *new_db,
1007
1026
const char *table_name, Table **table)
1411
1430
errmsg_printf(ERRMSG_LVL_ERROR, _("Table %s had a open data Cursor in reopen_table"),
1414
table_list.db= table->s->db.str;
1433
table_list.db= const_cast<char *>(table->s->getSchemaName());
1415
1434
table_list.table_name= table->s->table_name.str;
1416
1435
table_list.table= table;
1508
1527
for (table= open_tables; table ; table=table->next)
1510
1529
if (!strcmp(table->s->table_name.str, new_table_name) &&
1511
!strcmp(table->s->db.str, new_db))
1530
!strcmp(table->s->getSchemaName(), new_db))
1513
1532
table->open_placeholder= true;
1514
1533
close_handle_and_leave_table_as_lock(table);
1825
1844
next=table->next;
1826
1845
if (!strcmp(table->s->table_name.str, table_name) &&
1827
!strcmp(table->s->db.str, db))
1846
!strcmp(table->s->getSchemaName(), db))
1829
1848
mysql_lock_remove(session, table);
1870
1889
for (table= session->open_tables; table ; table= table->next)
1872
1891
if (!strcmp(table->s->table_name.str, table_name) &&
1873
!strcmp(table->s->db.str, db))
1892
!strcmp(table->s->getSchemaName(), db))
1875
1894
/* If MERGE child, forward lock handling to parent. */
1876
1895
mysql_lock_abort(session, table);
2252
2271
uint32_t key_length, path_length;
2253
2272
TableList table_list;
2255
table_list.db= (char*) identifier.getDBName();
2256
table_list.table_name= (char*) identifier.getTableName();
2274
table_list.db= (char*) identifier.getDBName().c_str();
2275
table_list.table_name= (char*) identifier.getTableName().c_str();
2257
2276
/* Create the cache_key for temporary tables */
2258
2277
key_length= table_list.create_table_def_key(cache_key);
2259
path_length= strlen(identifier.getPath());
2278
path_length= identifier.getPath().length();
2261
2280
if (!(new_tmp_table= (Table*) malloc(sizeof(*new_tmp_table) + sizeof(*share) +
2262
2281
path_length + 1 + key_length)))
2265
2284
share= (TableShare*) (new_tmp_table+1);
2266
2285
tmp_path= (char*) (share+1);
2267
saved_cache_key= strcpy(tmp_path, identifier.getPath())+path_length+1;
2286
saved_cache_key= strcpy(tmp_path, identifier.getPath().c_str())+path_length+1;
2268
2287
memcpy(saved_cache_key, cache_key, key_length);
2270
2289
share->init(saved_cache_key, key_length, strchr(saved_cache_key, '\0')+1, tmp_path);
2273
2292
First open the share, and then open the table from the share we just opened.
2275
2294
if (open_table_def(*this, share) ||
2276
open_table_from_share(this, share, identifier.getTableName(),
2295
open_table_from_share(this, share, identifier.getTableName().c_str(),
2277
2296
(uint32_t) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
2279
2298
ha_open_options,
4403
4422
for (uint32_t idx=0 ; idx < open_cache.records ; idx++)
4405
4424
Table *table=(Table*) hash_element(&open_cache,idx);
4406
if (not strcmp(table->s->db.str, schema_name.c_str()))
4425
if (not strcmp(table->s->getSchemaName(), schema_name.c_str()))
4408
4427
table->s->version= 0L; /* Free when thread is ready */
4409
4428
if (not table->in_use)