~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

  • Committer: Brian Aker
  • Date: 2010-03-31 05:53:34 UTC
  • Revision ID: brian@gaz-20100331055334-yqqmzlgqb2xq1p5b
Mass overhaul to use schema_identifier.

Show diffs side-by-side

added added

removed removed

Lines of Context:
492
492
  for (; table; table= table->*link )
493
493
  {
494
494
    if ((table->table == 0 || table->table->s->tmp_table == message::Table::STANDARD) &&
495
 
        strcmp(table->db, db_name) == 0 &&
496
 
        strcmp(table->table_name, table_name) == 0)
 
495
        strcasecmp(table->db, db_name) == 0 &&
 
496
        strcasecmp(table->table_name, table_name) == 0)
497
497
      break;
498
498
  }
499
499
  return table;
586
586
}
587
587
 
588
588
 
589
 
void Session::doGetTableNames(const std::string& db_name,
 
589
void Session::doGetTableNames(SchemaIdentifier &schema_identifier,
590
590
                              std::set<std::string>& set_of_names)
591
591
{
592
592
  for (Table *table= temporary_tables ; table ; table= table->next)
593
593
  {
594
 
    if (not db_name.compare(table->s->getSchemaName()))
 
594
    if (schema_identifier.compare(table->s->getSchemaName()))
595
595
    {
596
596
      set_of_names.insert(table->s->table_name.str);
597
597
    }
599
599
}
600
600
 
601
601
void Session::doGetTableNames(CachedDirectory &,
602
 
                              const std::string &db_name,
 
602
                              SchemaIdentifier &schema_identifier,
603
603
                              std::set<std::string> &set_of_names)
604
604
{
605
 
  doGetTableNames(db_name, set_of_names);
 
605
  doGetTableNames(schema_identifier, set_of_names);
606
606
}
607
607
 
608
608
bool Session::doDoesTableExist(TableIdentifier &identifier)
611
611
  {
612
612
    if (table->s->tmp_table == message::Table::TEMPORARY)
613
613
    {
614
 
      if (not identifier.getSchemaName().compare(table->s->getSchemaName()))
 
614
      if (identifier.compare(table->s->getSchemaName(), table->s->table_name.str))
615
615
      {
616
 
        if (not identifier.getTableName().compare(table->s->table_name.str))
617
 
        {
618
 
          return true;
619
 
        }
 
616
        return true;
620
617
      }
621
618
    }
622
619
  }
631
628
  {
632
629
    if (table->s->tmp_table == message::Table::TEMPORARY)
633
630
    {
634
 
      if (not identifier.getSchemaName().compare(table->s->getSchemaName()))
 
631
      if (identifier.compare(table->s->getSchemaName(), table->s->table_name.str))
635
632
      {
636
 
        if (not identifier.getTableName().compare(table->s->table_name.str))
637
 
        {
638
 
          table_proto.CopyFrom(*(table->s->getTableProto()));
 
633
        table_proto.CopyFrom(*(table->s->getTableProto()));
639
634
 
640
 
          return EEXIST;
641
 
        }
 
635
        return EEXIST;
642
636
      }
643
637
    }
644
638
  }
1555
1549
  for (table= open_tables; table ; table=table->next)
1556
1550
  {
1557
1551
    if (!strcmp(table->s->table_name.str, new_table_name) &&
1558
 
        !strcmp(table->s->getSchemaName(), new_db))
 
1552
        !strcasecmp(table->s->getSchemaName(), new_db))
1559
1553
    {
1560
1554
      table->open_placeholder= true;
1561
1555
      close_handle_and_leave_table_as_lock(table);
1871
1865
  {
1872
1866
    next=table->next;
1873
1867
    if (!strcmp(table->s->table_name.str, table_name) &&
1874
 
        !strcmp(table->s->getSchemaName(), db))
 
1868
        !strcasecmp(table->s->getSchemaName(), db))
1875
1869
    {
1876
1870
      mysql_lock_remove(session, table);
1877
1871
 
2299
2293
  uint32_t key_length, path_length;
2300
2294
  TableList table_list;
2301
2295
 
2302
 
  table_list.db=         (char*) identifier.getDBName().c_str();
 
2296
  table_list.db=         (char*) identifier.getSchemaName().c_str();
2303
2297
  table_list.table_name= (char*) identifier.getTableName().c_str();
2304
2298
  /* Create the cache_key for temporary tables */
2305
2299
  key_length= table_list.create_table_def_key(cache_key);
4090
4084
    assert(tables->is_leaf_for_name_resolution());
4091
4085
 
4092
4086
    if ((table_name && my_strcasecmp(table_alias_charset, table_name, tables->alias)) ||
4093
 
        (db_name && strcmp(tables->db,db_name)))
 
4087
        (db_name && strcasecmp(tables->db,db_name)))
4094
4088
      continue;
4095
4089
 
4096
4090
    /*
4443
4437
and afterwards delete those marked unused.
4444
4438
*/
4445
4439
 
4446
 
void remove_db_from_cache(const std::string schema_name)
 
4440
void remove_db_from_cache(SchemaIdentifier &schema_identifier)
4447
4441
{
4448
4442
  safe_mutex_assert_owner(&LOCK_open);
4449
4443
 
4450
4444
  for (uint32_t idx=0 ; idx < open_cache.records ; idx++)
4451
4445
  {
4452
4446
    Table *table=(Table*) hash_element(&open_cache,idx);
4453
 
    if (not schema_name.compare(table->s->getSchemaName()))
 
4447
    if (not schema_identifier.getPath().compare(table->s->getSchemaName()))
4454
4448
    {
4455
4449
      table->s->version= 0L;                    /* Free when thread is ready */
4456
4450
      if (not table->in_use)