3675 Magnus Blåudd 2011-11-01
ndb schema dist
- remove "have_lock" argument from ndb_schema_object functions
- remove lock of "ndbcluster_mutex" before getting the ndb_schema_object, that is handled in the ndb_schema_object functions
- no need to check if ndb_schema_object is NULL before releasing it, code would have crashed loong before if it was.
- add call to release the ndb_schema_object in the CLEAR_SLOCK handler
modified:
sql/ha_ndbcluster_binlog.cc
sql/ndb_schema_object.cc
sql/ndb_schema_object.h
3674 Magnus Blåudd 2011-10-31
ndbcluster
- fix faulty DBUG_PRINT, create_ordered_index -> create_index
modified:
sql/ha_ndbcluster.cc
3673 Magnus Blåudd 2011-10-31
ndbcluster
- mark a few member functions as const to prevent that they fiddel with ha_ndbcluster too much
modified:
sql/ha_ndbcluster.cc
sql/ha_ndbcluster.h
3672 Magnus Blåudd 2011-10-31
ndb index stat
- remove code duplication and use ndb_thd.h
modified:
sql/ha_ndb_index_stat.cc
3671 Magnus Blåudd 2011-10-31
ndb schema dist
- remove (more or less)unused NDB_SHARE::connect_count
modified:
sql/ha_ndbcluster.cc
sql/ha_ndbcluster_binlog.cc
sql/ndb_share.h
=== modified file 'sql/ha_ndb_index_stat.cc'
--- a/sql/ha_ndb_index_stat.cc 2011-10-20 19:41:56 +0000
+++ b/sql/ha_ndb_index_stat.cc 2011-10-31 16:04:30 +0000
@@ -27,14 +27,7 @@
// Do we have waiter...
static bool ndb_index_stat_waiter= false;
-// copied from ha_ndbcluster_binlog.h
-
-extern handlerton *ndbcluster_hton;
-
-inline
-void
-set_thd_ndb(THD *thd, Thd_ndb *thd_ndb)
-{ thd_set_ha_data(thd, ndbcluster_hton, thd_ndb); }
+#include "ndb_thd.h"
// Typedefs for long names
typedef NdbDictionary::Table NDBTAB;
@@ -1990,7 +1983,7 @@ ndb_index_stat_thread_func(void *arg __a
pthread_mutex_lock(&LOCK_ndb_index_stat_thread);
goto ndb_index_stat_thread_end;
}
- set_thd_ndb(thd, thd_ndb);
+ thd_set_thd_ndb(thd, thd_ndb);
thd_ndb->options|= TNO_NO_LOG_SCHEMA_OP;
if (thd_ndb->ndb->setDatabaseName(NDB_INDEX_STAT_DB) == -1)
{
@@ -2111,7 +2104,7 @@ ndb_index_stat_thread_fail:
if (thd_ndb)
{
Thd_ndb::release(thd_ndb);
- set_thd_ndb(thd, NULL);
+ thd_set_thd_ndb(thd, NULL);
}
thd->cleanup();
delete thd;
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2011-10-31 15:57:15 +0000
+++ b/sql/ha_ndbcluster.cc 2011-10-31 16:43:45 +0000
@@ -1254,9 +1254,9 @@ Thd_ndb::~Thd_ndb()
inline
-Ndb *ha_ndbcluster::get_ndb(THD *thd)
+Ndb *ha_ndbcluster::get_ndb(THD *thd) const
{
- return get_thd_ndb(thd)->ndb;
+ return thd_get_thd_ndb(thd)->ndb;
}
/*
@@ -2226,7 +2226,7 @@ static int fix_unique_index_attr_order(N
If any index should fail to be created,
the error is returned immediately
*/
-int ha_ndbcluster::create_indexes(THD *thd, Ndb *ndb, TABLE *tab)
+int ha_ndbcluster::create_indexes(THD *thd, Ndb *ndb, TABLE *tab) const
{
uint i;
int error= 0;
@@ -2760,7 +2760,7 @@ NDB_INDEX_TYPE ha_ndbcluster::get_index_
ORDERED_INDEX);
}
-bool ha_ndbcluster::check_index_fields_not_null(KEY* key_info)
+bool ha_ndbcluster::check_index_fields_not_null(KEY* key_info) const
{
KEY_PART_INFO* key_part= key_info->key_part;
KEY_PART_INFO* end= key_part+key_info->key_parts;
@@ -10582,12 +10582,12 @@ cleanup_failed:
int ha_ndbcluster::create_index(THD *thd, const char *name, KEY *key_info,
- NDB_INDEX_TYPE idx_type, uint idx_no)
+ NDB_INDEX_TYPE idx_type, uint idx_no) const
{
int error= 0;
char unique_name[FN_LEN + 1];
static const char* unique_suffix= "$unique";
- DBUG_ENTER("ha_ndbcluster::create_ordered_index");
+ DBUG_ENTER("ha_ndbcluster::create_index");
DBUG_PRINT("info", ("Creating index %u: %s", idx_no, name));
if (idx_type == UNIQUE_ORDERED_INDEX || idx_type == UNIQUE_INDEX)
@@ -10640,14 +10640,14 @@ int ha_ndbcluster::create_index(THD *thd
}
int ha_ndbcluster::create_ordered_index(THD *thd, const char *name,
- KEY *key_info)
+ KEY *key_info) const
{
DBUG_ENTER("ha_ndbcluster::create_ordered_index");
DBUG_RETURN(create_ndb_index(thd, name, key_info, FALSE));
}
int ha_ndbcluster::create_unique_index(THD *thd, const char *name,
- KEY *key_info)
+ KEY *key_info) const
{
DBUG_ENTER("ha_ndbcluster::create_unique_index");
@@ -10664,7 +10664,7 @@ int ha_ndbcluster::create_unique_index(T
int ha_ndbcluster::create_ndb_index(THD *thd, const char *name,
KEY *key_info,
- bool unique)
+ bool unique) const
{
char index_name[FN_LEN + 1];
Ndb *ndb= get_ndb(thd);
@@ -11837,7 +11837,7 @@ int ha_ndbcluster::close(void)
}
-int ha_ndbcluster::check_ndb_connection(THD* thd)
+int ha_ndbcluster::check_ndb_connection(THD* thd) const
{
Ndb *ndb;
DBUG_ENTER("check_ndb_connection");
@@ -14233,7 +14233,7 @@ retry:
that the table with this name is a ndb table.
*/
-int ha_ndbcluster::write_ndb_file(const char *name)
+int ha_ndbcluster::write_ndb_file(const char *name) const
{
File file;
bool error=1;
=== modified file 'sql/ha_ndbcluster.h'
--- a/sql/ha_ndbcluster.h 2011-10-28 07:14:45 +0000
+++ b/sql/ha_ndbcluster.h 2011-10-31 16:42:38 +0000
@@ -505,13 +505,14 @@ private:
int add_index_impl(THD *thd, TABLE *table_arg,
KEY *key_info, uint num_of_keys);
- int create_ndb_index(THD *thd, const char *name, KEY *key_info, bool unique);
- int create_ordered_index(THD *thd, const char *name, KEY *key_info);
- int create_unique_index(THD *thd, const char *name, KEY *key_info);
+ int create_ndb_index(THD *thd, const char *name, KEY *key_info,
+ bool unique) const;
+ int create_ordered_index(THD *thd, const char *name, KEY *key_info) const;
+ int create_unique_index(THD *thd, const char *name, KEY *key_info) const;
int create_index(THD *thd, const char *name, KEY *key_info,
- NDB_INDEX_TYPE idx_type, uint idx_no);
+ NDB_INDEX_TYPE idx_type, uint idx_no) const;
// Index list management
- int create_indexes(THD *thd, Ndb *ndb, TABLE *tab);
+ int create_indexes(THD *thd, Ndb *ndb, TABLE *tab) const;
int open_indexes(THD *thd, Ndb *ndb, TABLE *tab, bool ignore_error);
void renumber_indexes(Ndb *ndb, TABLE *tab);
int drop_indexes(Ndb *ndb, TABLE *tab);
@@ -529,7 +530,7 @@ private:
NDB_INDEX_TYPE get_index_type_from_key(uint index_no, KEY *key_info,
bool primary) const;
bool has_null_in_unique_index(uint idx_no) const;
- bool check_index_fields_not_null(KEY *key_info);
+ bool check_index_fields_not_null(KEY *key_info) const;
bool check_if_pushable(int type, //NdbQueryOperationDef::Type,
uint idx= MAX_KEY,
@@ -642,9 +643,9 @@ private:
char *update_table_comment(const char * comment);
- int write_ndb_file(const char *name);
+ int write_ndb_file(const char *name) const;
- int check_ndb_connection(THD* thd);
+ int check_ndb_connection(THD* thd) const;
void set_rec_per_key();
int records_update();
@@ -803,7 +804,7 @@ private:
*/
KEY_MULTI_RANGE *m_multi_range_defined_end;
NdbIndexScanOperation *m_multi_cursor;
- Ndb *get_ndb(THD *thd);
+ Ndb *get_ndb(THD *thd) const;
int update_stats(THD *thd, bool do_read_stat, bool have_lock= FALSE,
uint part_id= ~(uint)0);
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc 2011-10-31 15:57:15 +0000
+++ b/sql/ha_ndbcluster_binlog.cc 2011-11-01 09:24:29 +0000
@@ -1670,7 +1670,7 @@ int ndbcluster_log_schema_op(THD *thd,
{
char key[FN_REFLEN + 1];
build_table_filename(key, sizeof(key) - 1, db, table_name, "", 0);
- ndb_schema_object= ndb_get_schema_object(key, TRUE, FALSE);
+ ndb_schema_object= ndb_get_schema_object(key, true);
ndb_schema_object->table_id= ndb_table_id;
ndb_schema_object->table_version= ndb_table_version;
}
@@ -1687,8 +1687,7 @@ int ndbcluster_log_schema_op(THD *thd,
if (ndb_schema_share == 0)
{
pthread_mutex_unlock(&ndb_schema_share_mutex);
- if (ndb_schema_object)
- ndb_free_schema_object(&ndb_schema_object, FALSE);
+ ndb_free_schema_object(&ndb_schema_object);
DBUG_RETURN(0);
}
pthread_mutex_lock(&ndb_schema_share->mutex);
@@ -1980,8 +1979,7 @@ end:
type_str, ndb_schema_object->key);
}
- if (ndb_schema_object)
- ndb_free_schema_object(&ndb_schema_object, FALSE);
+ ndb_free_schema_object(&ndb_schema_object);
if (opt_ndb_extra_logging > 19)
{
@@ -2847,9 +2845,8 @@ class Ndb_schema_event_handler {
if (schema_type == SOT_CLEAR_SLOCK)
{
/* Ack to any SQL thread waiting for schema op to complete */
- pthread_mutex_lock(&ndbcluster_mutex);
NDB_SCHEMA_OBJECT *ndb_schema_object=
- ndb_get_schema_object(key, false, true);
+ ndb_get_schema_object(key, false);
if (ndb_schema_object &&
(ndb_schema_object->table_id == schema->id &&
ndb_schema_object->table_version == schema->version))
@@ -2891,7 +2888,8 @@ class Ndb_schema_event_handler {
schema->version);
}
}
- pthread_mutex_unlock(&ndbcluster_mutex);
+ if (ndb_schema_object)
+ ndb_free_schema_object(&ndb_schema_object);
DBUG_VOID_RETURN;
}
=== modified file 'sql/ndb_schema_object.cc'
--- a/sql/ndb_schema_object.cc 2011-10-31 12:39:50 +0000
+++ b/sql/ndb_schema_object.cc 2011-11-01 09:24:29 +0000
@@ -51,16 +51,14 @@ public:
NDB_SCHEMA_OBJECT *ndb_get_schema_object(const char *key,
- bool create_if_not_exists,
- bool have_lock)
+ bool create_if_not_exists)
{
NDB_SCHEMA_OBJECT *ndb_schema_object;
uint length= (uint) strlen(key);
DBUG_ENTER("ndb_get_schema_object");
DBUG_PRINT("enter", ("key: '%s'", key));
- if (!have_lock)
- pthread_mutex_lock(&ndbcluster_mutex);
+ pthread_mutex_lock(&ndbcluster_mutex);
while (!(ndb_schema_object=
(NDB_SCHEMA_OBJECT*) my_hash_search(&ndb_schema_objects.m_hash,
(const uchar*) key,
@@ -97,20 +95,18 @@ NDB_SCHEMA_OBJECT *ndb_get_schema_object
ndb_schema_object->use_count++;
DBUG_PRINT("info", ("use_count: %d", ndb_schema_object->use_count));
}
- if (!have_lock)
- pthread_mutex_unlock(&ndbcluster_mutex);
+ pthread_mutex_unlock(&ndbcluster_mutex);
DBUG_RETURN(ndb_schema_object);
}
void
-ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object,
- bool have_lock)
+ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object)
{
DBUG_ENTER("ndb_free_schema_object");
DBUG_PRINT("enter", ("key: '%s'", (*ndb_schema_object)->key));
- if (!have_lock)
- pthread_mutex_lock(&ndbcluster_mutex);
+
+ pthread_mutex_lock(&ndbcluster_mutex);
if (!--(*ndb_schema_object)->use_count)
{
DBUG_PRINT("info", ("use_count: %d", (*ndb_schema_object)->use_count));
@@ -123,7 +119,6 @@ ndb_free_schema_object(NDB_SCHEMA_OBJECT
{
DBUG_PRINT("info", ("use_count: %d", (*ndb_schema_object)->use_count));
}
- if (!have_lock)
- pthread_mutex_unlock(&ndbcluster_mutex);
+ pthread_mutex_unlock(&ndbcluster_mutex);
DBUG_VOID_RETURN;
}
=== modified file 'sql/ndb_schema_object.h'
--- a/sql/ndb_schema_object.h 2011-10-31 12:39:50 +0000
+++ b/sql/ndb_schema_object.h 2011-11-01 09:24:29 +0000
@@ -46,10 +46,8 @@ struct NDB_SCHEMA_OBJECT {
};
NDB_SCHEMA_OBJECT *ndb_get_schema_object(const char *key,
- bool create_if_not_exists,
- bool have_lock);
+ bool create_if_not_exists);
-void ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object,
- bool have_lock);
+void ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object);
#endif
No bundle (reason: useless for push emails).| Thread |
|---|
| • bzr push into mysql-5.5-cluster branch (magnus.blaudd:3671 to 3675) | Magnus Blåudd | 1 Nov |