~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

Table error update.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1001
1001
    */
1002
1002
 
1003
1003
    {
1004
 
      table::Cache::singleton().mutex().lock(); /* Lock for FLUSH TABLES for open table */
 
1004
      boost::mutex::scoped_lock scopedLock(table::Cache::singleton().mutex());
1005
1005
 
1006
1006
      /*
1007
1007
        Actually try to find the table in the open_cache.
1053
1053
          /* Avoid self-deadlocks by detecting self-dependencies. */
1054
1054
          if (table->open_placeholder && table->in_use == this)
1055
1055
          {
1056
 
            table::Cache::singleton().mutex().unlock();
1057
1056
            my_error(ER_UPDATE_TABLE_USED, MYF(0), table->getShare()->getTableName());
1058
1057
            return NULL;
1059
1058
          }
1088
1087
          {
1089
1088
            /* wait_for_conditionwill unlock table::Cache::singleton().mutex() for us */
1090
1089
            wait_for_condition(table::Cache::singleton().mutex(), COND_refresh);
 
1090
            scopedLock.release();
1091
1091
          }
1092
1092
          else
1093
1093
          {
1094
 
            table::Cache::singleton().mutex().unlock();
 
1094
            scopedLock.unlock();
1095
1095
          }
 
1096
 
1096
1097
          /*
1097
1098
            There is a refresh in progress for this table.
1098
1099
            Signal the caller that it has to try again.
1099
1100
          */
1100
1101
          if (refresh)
1101
1102
            *refresh= true;
 
1103
 
1102
1104
          return NULL;
1103
1105
        }
1104
1106
      }
 
1107
 
1105
1108
      if (table)
1106
1109
      {
1107
1110
        table::getUnused().unlink(static_cast<table::Concurrent *>(table));
1125
1128
            */
1126
1129
            if (!(table= table_cache_insert_placeholder(lock_table_identifier)))
1127
1130
            {
1128
 
              table::Cache::singleton().mutex().unlock();
1129
1131
              return NULL;
1130
1132
            }
1131
1133
            /*
1136
1138
            table->open_placeholder= true;
1137
1139
            table->setNext(open_tables);
1138
1140
            open_tables= table;
1139
 
            table::Cache::singleton().mutex().unlock();
1140
1141
 
1141
1142
            return table ;
1142
1143
          }
1149
1150
          table= new_table;
1150
1151
          if (new_table == NULL)
1151
1152
          {
1152
 
            table::Cache::singleton().mutex().unlock();
1153
1153
            return NULL;
1154
1154
          }
1155
1155
 
1157
1157
          if (error != 0)
1158
1158
          {
1159
1159
            delete new_table;
1160
 
            table::Cache::singleton().mutex().unlock();
1161
1160
            return NULL;
1162
1161
          }
1163
1162
          (void)table::Cache::singleton().insert(new_table);
1164
1163
        }
1165
1164
      }
 
1165
    }
1166
1166
 
1167
 
      table::Cache::singleton().mutex().unlock();
1168
 
    }
1169
1167
    if (refresh)
1170
1168
    {
1171
1169
      table->setNext(open_tables); /* Link into simple list */