~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

  • Committer: Brian Aker
  • Date: 2010-10-22 22:02:32 UTC
  • mfrom: (1864.3.17 catalogs)
  • Revision ID: brian@tangent.org-20101022220232-p4l1i9a3ud5asw0d
Merge in Brian. key creation should be improved after this (ie for share)

Show diffs side-by-side

added added

removed removed

Lines of Context:
760
760
  return ENOENT;
761
761
}
762
762
 
763
 
Table *Session::find_temporary_table(const char *new_db, const char *table_name)
764
 
{
765
 
  char  key[MAX_DBKEY_LENGTH];
766
 
  uint  key_length;
767
 
 
768
 
  key_length= TableIdentifier::createKey(key, new_db, table_name);
769
 
 
770
 
  for (Table *table= temporary_tables ; table ; table= table->getNext())
771
 
  {
772
 
    const TableIdentifier::Key &share_key(table->getShare()->getCacheKey());
773
 
    if (share_key.size() == key_length &&
774
 
        not memcmp(&share_key[0], key, key_length))
775
 
    {
776
 
      return table;
777
 
    }
778
 
  }
779
 
  return NULL;                               // Not a temporary table
780
 
}
781
 
 
782
 
Table *Session::find_temporary_table(TableList *table_list)
783
 
{
784
 
  return find_temporary_table(table_list->db, table_list->table_name);
785
 
}
786
 
 
787
 
Table *Session::find_temporary_table(TableIdentifier &identifier)
 
763
Table *Session::find_temporary_table(const TableIdentifier &identifier)
788
764
{
789
765
  for (Table *table= temporary_tables ; table ; table= table->getNext())
790
766
  {
822
798
  @retval -1  the table is in use by a outer query
823
799
*/
824
800
 
825
 
int Session::drop_temporary_table(TableList *table_list)
 
801
int Session::drop_temporary_table(const drizzled::TableIdentifier &identifier)
826
802
{
827
803
  Table *table;
828
804
 
829
 
  if (not (table= find_temporary_table(table_list)))
 
805
  if (not (table= find_temporary_table(identifier)))
830
806
    return 1;
831
807
 
832
808
  /* Table might be in use by some outer statement. */
1046
1022
  case of failure.
1047
1023
*/
1048
1024
 
1049
 
Table *Session::table_cache_insert_placeholder(const char *db_name, const char *table_name)
 
1025
Table *Session::table_cache_insert_placeholder(const drizzled::TableIdentifier &arg)
1050
1026
{
1051
1027
  safe_mutex_assert_owner(LOCK_open.native_handle());
1052
1028
 
1053
1029
  /*
1054
1030
    Create a table entry with the right key and with an old refresh version
1055
1031
  */
1056
 
  TableIdentifier identifier(db_name, table_name, message::Table::INTERNAL);
 
1032
  TableIdentifier identifier(arg.getSchemaName(), arg.getTableName(), message::Table::INTERNAL);
1057
1033
  table::Placeholder *table= new table::Placeholder(this, identifier);
1058
1034
 
1059
1035
  if (not add_table(table))
1104
1080
    return false;
1105
1081
  }
1106
1082
 
1107
 
  if (not (*table= table_cache_insert_placeholder(identifier.getSchemaName().c_str(), identifier.getTableName().c_str())))
 
1083
  if (not (*table= table_cache_insert_placeholder(identifier)))
1108
1084
  {
1109
1085
    return true;
1110
1086
  }
1377
1353
            /*
1378
1354
              Table to be created, so we need to create placeholder in table-cache.
1379
1355
            */
1380
 
            if (!(table= table_cache_insert_placeholder(table_list->db, table_list->table_name)))
 
1356
            if (!(table= table_cache_insert_placeholder(lock_table_identifier)))
1381
1357
            {
1382
1358
              LOCK_open.unlock();
1383
1359
              return NULL;