diff options
Diffstat (limited to 'sql/ha_ndbcluster.cc')
-rw-r--r-- | sql/ha_ndbcluster.cc | 63 |
1 files changed, 38 insertions, 25 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index f838bfcd8c3..7320665dc49 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -32,6 +32,10 @@ #include <ndbapi/NdbApi.hpp> #include <ndbapi/NdbScanFilter.hpp> +// options from from mysqld.cc +extern my_bool opt_ndb_optimized_node_selection; +extern const char *opt_ndbcluster_connectstring; + // Default value for parallelism static const int parallelism= 240; @@ -39,9 +43,6 @@ static const int parallelism= 240; // createable against NDB from this handler static const int max_transactions= 256; -// connectstring to cluster if given by mysqld -const char *ndbcluster_connectstring= 0; - static const char *ha_ndb_ext=".ndb"; #define NDB_HIDDEN_PRIMARY_KEY_LENGTH 8 @@ -192,7 +193,7 @@ int execute_no_commit_ie(ha_ndbcluster *h, NdbConnection *trans) if (m_batch_execute) return 0; #endif - return trans->execute(NoCommit,IgnoreError,h->m_force_send); + return trans->execute(NoCommit, AO_IgnoreError,h->m_force_send); } /* @@ -3638,9 +3639,13 @@ int ha_ndbcluster::create_index(const char *name, int ha_ndbcluster::rename_table(const char *from, const char *to) { + NDBDICT *dict; char new_tabname[FN_HEADLEN]; + const NDBTAB *orig_tab; + int result; DBUG_ENTER("ha_ndbcluster::rename_table"); + DBUG_PRINT("info", ("Renaming %s to %s", from, to)); set_dbname(from); set_tabname(from); set_tabname(to, new_tabname); @@ -3648,14 +3653,20 @@ int ha_ndbcluster::rename_table(const char *from, const char *to) if (check_ndb_connection()) DBUG_RETURN(my_errno= HA_ERR_NO_CONNECTION); + dict= m_ndb->getDictionary(); + if (!(orig_tab= dict->getTable(m_tabname))) + ERR_RETURN(dict->getNdbError()); - int result= alter_table_name(m_tabname, new_tabname); - if (result == 0) + m_table= (void *)orig_tab; + // Change current database to that of target table + set_dbname(to); + m_ndb->setDatabaseName(m_dbname); + if (!(result= alter_table_name(new_tabname))) { - set_tabname(to); - handler::rename_table(from, to); + // Rename .ndb file + result= handler::rename_table(from, to); } - + DBUG_RETURN(result); } @@ -3664,19 +3675,16 @@ int ha_ndbcluster::rename_table(const char *from, const char *to) Rename a table in NDB Cluster using alter table */ -int ha_ndbcluster::alter_table_name(const char *from, const char *to) +int ha_ndbcluster::alter_table_name(const char *to) { - NDBDICT *dict= m_ndb->getDictionary(); - const NDBTAB *orig_tab; + NDBDICT * dict= m_ndb->getDictionary(); + const NDBTAB *orig_tab= (const NDBTAB *) m_table; + int ret; DBUG_ENTER("alter_table_name_table"); - DBUG_PRINT("enter", ("Renaming %s to %s", from, to)); - if (!(orig_tab= dict->getTable(from))) - ERR_RETURN(dict->getNdbError()); - - NdbDictionary::Table copy_tab= dict->getTableForAlteration(from); - copy_tab.setName(to); - if (dict->alterTable(copy_tab) != 0) + NdbDictionary::Table new_tab= *orig_tab; + new_tab.setName(to); + if (dict->alterTable(new_tab) != 0) ERR_RETURN(dict->getNdbError()); m_table= NULL; @@ -3699,7 +3707,7 @@ int ha_ndbcluster::delete_table(const char *name) if (check_ndb_connection()) DBUG_RETURN(HA_ERR_NO_CONNECTION); - + // Remove .ndb file handler::delete_table(name); DBUG_RETURN(drop_table()); } @@ -3958,6 +3966,7 @@ Ndb* check_ndb_in_thd(THD* thd) } + int ha_ndbcluster::check_ndb_connection() { THD* thd= current_thd; @@ -4240,15 +4249,19 @@ bool ndbcluster_init() int res; DBUG_ENTER("ndbcluster_init"); // Set connectstring if specified - if (ndbcluster_connectstring != 0) - DBUG_PRINT("connectstring", ("%s", ndbcluster_connectstring)); + if (opt_ndbcluster_connectstring != 0) + DBUG_PRINT("connectstring", ("%s", opt_ndbcluster_connectstring)); if ((g_ndb_cluster_connection= - new Ndb_cluster_connection(ndbcluster_connectstring)) == 0) + new Ndb_cluster_connection(opt_ndbcluster_connectstring)) == 0) { - DBUG_PRINT("error",("Ndb_cluster_connection(%s)",ndbcluster_connectstring)); + DBUG_PRINT("error",("Ndb_cluster_connection(%s)", + opt_ndbcluster_connectstring)); goto ndbcluster_init_error; } + g_ndb_cluster_connection->set_optimized_node_selection + (opt_ndb_optimized_node_selection); + // Create a Ndb object to open the connection to NDB g_ndb= new Ndb(g_ndb_cluster_connection, "sys"); g_ndb->getDictionary()->set_local_table_data_size(sizeof(Ndb_table_local_info)); @@ -4263,7 +4276,7 @@ bool ndbcluster_init() DBUG_PRINT("info",("NDBCLUSTER storage engine at %s on port %d", g_ndb_cluster_connection->get_connected_host(), g_ndb_cluster_connection->get_connected_port())); - g_ndb->waitUntilReady(10); + g_ndb_cluster_connection->wait_until_ready(10,0); } else if(res == 1) { |