~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/statement/rename_table.cc

  • Committer: Brian Aker
  • Date: 2010-11-08 18:54:26 UTC
  • mto: (1921.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 1916.
  • Revision ID: brian@tangent.org-20101108185426-fymkf2xnelupf11x
Rename lock methods to be style + well make sense.

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
    return true;
69
69
  }
70
70
 
71
 
  if (wait_if_global_read_lock(session, 0, 1))
 
71
  if (session->wait_if_global_read_lock(false, true))
72
72
    return true;
73
73
 
74
 
  pthread_mutex_lock(&LOCK_open); /* Rename table lock for exclusive access */
75
 
  if (lock_table_names_exclusively(session, table_list))
 
74
  LOCK_open.lock(); /* Rename table lock for exclusive access */
 
75
  if (session->lock_table_names_exclusively(table_list))
76
76
  {
77
 
    pthread_mutex_unlock(&LOCK_open);
 
77
    LOCK_open.unlock();
78
78
    goto err;
79
79
  }
80
80
 
105
105
    higher concurrency - query_cache_invalidate can take minutes to
106
106
    complete.
107
107
  */
108
 
  pthread_mutex_unlock(&LOCK_open);
 
108
  LOCK_open.unlock();
109
109
 
110
110
  /* Lets hope this doesn't fail as the result will be messy */
111
111
  if (! error)
114
114
    session->my_ok();
115
115
  }
116
116
 
117
 
  pthread_mutex_lock(&LOCK_open); /* unlock all tables held */
118
 
  unlock_table_names(table_list, NULL);
119
 
  pthread_mutex_unlock(&LOCK_open);
 
117
  LOCK_open.lock(); /* unlock all tables held */
 
118
  table_list->unlock_table_names();
 
119
  LOCK_open.unlock();
120
120
 
121
121
err:
122
 
  start_waiting_global_read_lock(session);
 
122
  session->startWaitingGlobalReadLock();
123
123
 
124
124
  return error;
125
125
}
147
147
  const char *new_alias, *old_alias;
148
148
 
149
149
  {
150
 
    old_alias= ren_table->table_name;
 
150
    old_alias= ren_table->getTableName();
151
151
    new_alias= new_table_name;
152
152
  }
153
153
 
154
154
  plugin::StorageEngine *engine= NULL;
155
155
  message::Table table_proto;
156
156
 
157
 
  TableIdentifier old_identifier(ren_table->db, old_alias, message::Table::STANDARD);
 
157
  TableIdentifier old_identifier(ren_table->getSchemaName(), old_alias, message::Table::STANDARD);
158
158
 
159
159
  if (plugin::StorageEngine::getTableDefinition(*session, old_identifier, table_proto) != EEXIST)
160
160
  {
161
 
    my_error(ER_NO_SUCH_TABLE, MYF(0), ren_table->db, old_alias);
 
161
    my_error(ER_NO_SUCH_TABLE, MYF(0), ren_table->getSchemaName(), old_alias);
162
162
    return true;
163
163
  }
164
164
 
171
171
    return 1; // This can't be skipped
172
172
  }
173
173
 
174
 
  rc= mysql_rename_table(engine, old_identifier, new_identifier, 0);
 
174
  rc= mysql_rename_table(*session, engine, old_identifier, new_identifier);
175
175
  if (rc && ! skip_error)
176
176
    return true;
177
177
 
186
186
  for (ren_table= table_list; ren_table; ren_table= new_table->next_local)
187
187
  {
188
188
    new_table= ren_table->next_local;
189
 
    if (rename(ren_table, new_table->db, new_table->table_name, skip_error))
 
189
    if (rename(ren_table, new_table->getSchemaName(), new_table->getTableName(), skip_error))
190
190
      return ren_table;
191
191
  }
192
192
  return 0;