Commit c45ae5f0 authored by Will DeVries's avatar Will DeVries Committed by Sergei Petrunia

Simplify delete_table and fix a few little things.

parent f53c6535
...@@ -413,8 +413,9 @@ int clustrix_connection::discover_table_details(LEX_CSTRING *db, ...@@ -413,8 +413,9 @@ int clustrix_connection::discover_table_details(LEX_CSTRING *db,
get_oid.append("'"); get_oid.append("'");
if (mysql_real_query(&clustrix_net, get_oid.c_ptr(), get_oid.length())) { if (mysql_real_query(&clustrix_net, get_oid.c_ptr(), get_oid.length())) {
if ((error_code = mysql_errno(&clustrix_net))) { if ((error_code = mysql_errno(&clustrix_net))) {
error_code = HA_ERR_NO_SUCH_TABLE; DBUG_PRINT("mysql_real_query returns ", ("%d", error_code));
goto error; error_code = HA_ERR_NO_SUCH_TABLE;
goto error;
} }
} }
...@@ -450,7 +451,7 @@ int clustrix_connection::discover_table_details(LEX_CSTRING *db, ...@@ -450,7 +451,7 @@ int clustrix_connection::discover_table_details(LEX_CSTRING *db,
show.append(name); show.append(name);
if (mysql_real_query(&clustrix_net, show.c_ptr(), show.length())) { if (mysql_real_query(&clustrix_net, show.c_ptr(), show.length())) {
if ((error_code = mysql_errno(&clustrix_net))) { if ((error_code = mysql_errno(&clustrix_net))) {
DBUG_PRINT("mysql_real_query returns ",("%d", error_code)); DBUG_PRINT("mysql_real_query returns ", ("%d", error_code));
error_code = HA_ERR_NO_SUCH_TABLE; error_code = HA_ERR_NO_SUCH_TABLE;
goto error; goto error;
} }
......
...@@ -230,24 +230,15 @@ int ha_clustrixdb::delete_table(const char *name) ...@@ -230,24 +230,15 @@ int ha_clustrixdb::delete_table(const char *name)
// This block isn't UTF aware yet. // This block isn't UTF aware yet.
// The format contains './' in the beginning of a path. // The format contains './' in the beginning of a path.
char *ptr = (char*) name + 2; char *dbname_end = (char*) name + 2;
while (*ptr != '/') while (*dbname_end != '/')
{ dbname_end++;
ptr++;
}
*ptr = '\0';
String db_name;
db_name.append(name + 2);
*ptr = '/';
ptr++;
String tbl_name;
tbl_name.append(ptr);
String delete_cmd; String delete_cmd;
delete_cmd.append("DROP TABLE `"); delete_cmd.append("DROP TABLE `");
delete_cmd.append(db_name); delete_cmd.append(name + 2, dbname_end - name - 2);
delete_cmd.append("`.`"); delete_cmd.append("`.`");
delete_cmd.append(tbl_name); delete_cmd.append(dbname_end + 1);
delete_cmd.append("`"); delete_cmd.append("`");
return trx->clustrix_net->delete_table(delete_cmd); return trx->clustrix_net->delete_table(delete_cmd);
...@@ -307,11 +298,9 @@ int ha_clustrixdb::write_row(uchar *buf) ...@@ -307,11 +298,9 @@ int ha_clustrixdb::write_row(uchar *buf)
packed_new_row, packed_size))) packed_new_row, packed_size)))
goto err; goto err;
{ Field *auto_inc_field = table->next_number_field;
Field *auto_inc_field = table->next_number_field; if (auto_inc_field)
if (auto_inc_field) insert_id_for_cur_row = trx->clustrix_net->last_insert_id;
insert_id_for_cur_row = trx->clustrix_net->last_insert_id;
}
err: err:
if (packed_size) if (packed_size)
...@@ -505,7 +494,6 @@ int ha_clustrixdb::index_read(uchar * buf, const uchar * key, uint key_len, ...@@ -505,7 +494,6 @@ int ha_clustrixdb::index_read(uchar * buf, const uchar * key, uint key_len,
&master_reclength, rowdata + rowdata_length))) &master_reclength, rowdata + rowdata_length)))
goto err; goto err;
error_code = 0;
err: err:
if (packed_key) if (packed_key)
my_afree(packed_key); my_afree(packed_key);
...@@ -728,7 +716,6 @@ int ha_clustrixdb::rnd_pos(uchar * buf, uchar *pos) ...@@ -728,7 +716,6 @@ int ha_clustrixdb::rnd_pos(uchar * buf, uchar *pos)
&master_reclength, rowdata + rowdata_length))) &master_reclength, rowdata + rowdata_length)))
goto err; goto err;
error_code = 0;
err: err:
if (packed_key) if (packed_key)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment