3630 Magnus Blåudd 2011-10-27
ndbcluster
- move' ndbcluster_find_all_files' to the only place where it's used in ha_ndbcluster_binlog.cc and make it static
modified:
sql/ha_ndbcluster.cc
sql/ha_ndbcluster_binlog.cc
sql/ha_ndbcluster_binlog.h
3629 Magnus Blåudd 2011-10-27
ndbcluster
- move prototypes for functions operating on NDB_SHARE to ndb_share.h
- implementation of the above mentioned functions are still in ha_ndbcluster.cc(wonder why...)
modified:
sql/ha_ndbcluster_binlog.h
sql/ndb_share.h
3628 Magnus Blåudd 2011-10-27
ndbcluster
- remove unused function 'set_binlog_flags'
- NOTE, there is static function set_binlog_flags in ha_ndbcluster_binlog.cc with different args
modified:
sql/ha_ndbcluster_binlog.h
=== modified file 'sql/ha_ndbcluster.cc'
--- a/sql/ha_ndbcluster.cc 2011-10-27 08:27:44 +0000
+++ b/sql/ha_ndbcluster.cc 2011-10-27 09:17:34 +0000
@@ -12102,137 +12102,6 @@ int ndb_create_table_from_engine(THD *th
return res;
}
-/*
- find all tables in ndb and discover those needed
-*/
-int ndbcluster_find_all_files(THD *thd)
-{
- Ndb* ndb;
- char key[FN_REFLEN + 1];
- NDBDICT *dict;
- int unhandled, retries= 5, skipped;
- DBUG_ENTER("ndbcluster_find_all_files");
-
- if (!(ndb= check_ndb_in_thd(thd)))
- DBUG_RETURN(HA_ERR_NO_CONNECTION);
-
- dict= ndb->getDictionary();
-
- LINT_INIT(unhandled);
- LINT_INIT(skipped);
- do
- {
- NdbDictionary::Dictionary::List list;
- if (dict->listObjects(list, NdbDictionary::Object::UserTable) != 0)
- ERR_RETURN(dict->getNdbError());
- unhandled= 0;
- skipped= 0;
- retries--;
- for (uint i= 0 ; i < list.count ; i++)
- {
- NDBDICT::List::Element& elmt= list.elements[i];
- if (IS_TMP_PREFIX(elmt.name) || IS_NDB_BLOB_PREFIX(elmt.name))
- {
- DBUG_PRINT("info", ("Skipping %s.%s in NDB", elmt.database, elmt.name));
- continue;
- }
- DBUG_PRINT("info", ("Found %s.%s in NDB", elmt.database, elmt.name));
- if (elmt.state != NDBOBJ::StateOnline &&
- elmt.state != NDBOBJ::StateBackup &&
- elmt.state != NDBOBJ::StateBuilding)
- {
- sql_print_information("NDB: skipping setup table %s.%s, in state %d",
- elmt.database, elmt.name, elmt.state);
- skipped++;
- continue;
- }
-
- ndb->setDatabaseName(elmt.database);
- Ndb_table_guard ndbtab_g(dict, elmt.name);
- const NDBTAB *ndbtab= ndbtab_g.get_table();
- if (!ndbtab)
- {
- if (retries == 0)
- sql_print_error("NDB: failed to setup table %s.%s, error: %d, %s",
- elmt.database, elmt.name,
- dict->getNdbError().code,
- dict->getNdbError().message);
- unhandled++;
- continue;
- }
-
- if (ndbtab->getFrmLength() == 0)
- continue;
-
- /* check if database exists */
- char *end= key +
- build_table_filename(key, sizeof(key) - 1, elmt.database, "", "", 0);
- if (my_access(key, F_OK))
- {
- /* no such database defined, skip table */
- continue;
- }
- /* finalize construction of path */
- end+= tablename_to_filename(elmt.name, end,
- (uint)(sizeof(key)-(end-key)));
- uchar *data= 0, *pack_data= 0;
- size_t length, pack_length;
- int discover= 0;
- if (readfrm(key, &data, &length) ||
- packfrm(data, length, &pack_data, &pack_length))
- {
- discover= 1;
- sql_print_information("NDB: missing frm for %s.%s, discovering...",
- elmt.database, elmt.name);
- }
- else if (cmp_frm(ndbtab, pack_data, pack_length))
- {
- /* ndb_share reference temporary */
- NDB_SHARE *share= get_share(key, 0, FALSE);
- if (share)
- {
- DBUG_PRINT("NDB_SHARE", ("%s temporary use_count: %u",
- share->key, share->use_count));
- }
- if (!share || get_ndb_share_state(share) != NSS_ALTERED)
- {
- discover= 1;
- sql_print_information("NDB: mismatch in frm for %s.%s, discovering...",
- elmt.database, elmt.name);
- }
- if (share)
- {
- /* ndb_share reference temporary free */
- DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
- share->key, share->use_count));
- free_share(&share);
- }
- }
- my_free((char*) data, MYF(MY_ALLOW_ZERO_PTR));
- my_free((char*) pack_data, MYF(MY_ALLOW_ZERO_PTR));
-
- if (discover)
- {
- /* ToDo 4.1 database needs to be created if missing */
- if (ndb_create_table_from_engine(thd, elmt.database, elmt.name))
- {
- /* ToDo 4.1 handle error */
- }
- }
- else
- {
- /* set up replication for this table */
- ndbcluster_create_binlog_setup(thd, ndb, key, (uint)(end-key),
- elmt.database, elmt.name,
- 0);
- }
- }
- }
- while (unhandled && retries);
-
- DBUG_RETURN(-(skipped + unhandled));
-}
-
static int
ndbcluster_find_files(handlerton *hton, THD *thd,
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc 2011-10-27 08:27:44 +0000
+++ b/sql/ha_ndbcluster_binlog.cc 2011-10-27 09:17:34 +0000
@@ -1311,6 +1311,141 @@ static int ndbcluster_find_all_databases
}
}
+
+/*
+ find all tables in ndb and discover those needed
+*/
+static
+int ndbcluster_find_all_files(THD *thd)
+{
+ Ndb* ndb;
+ char key[FN_REFLEN + 1];
+ NDBDICT *dict;
+ int unhandled, retries= 5, skipped;
+ DBUG_ENTER("ndbcluster_find_all_files");
+
+ if (!(ndb= check_ndb_in_thd(thd)))
+ DBUG_RETURN(HA_ERR_NO_CONNECTION);
+
+ dict= ndb->getDictionary();
+
+ LINT_INIT(unhandled);
+ LINT_INIT(skipped);
+ do
+ {
+ NdbDictionary::Dictionary::List list;
+ if (dict->listObjects(list, NdbDictionary::Object::UserTable) != 0)
+ DBUG_RETURN(1);
+ unhandled= 0;
+ skipped= 0;
+ retries--;
+ for (uint i= 0 ; i < list.count ; i++)
+ {
+ NDBDICT::List::Element& elmt= list.elements[i];
+ if (IS_TMP_PREFIX(elmt.name) || IS_NDB_BLOB_PREFIX(elmt.name))
+ {
+ DBUG_PRINT("info", ("Skipping %s.%s in NDB", elmt.database, elmt.name));
+ continue;
+ }
+ DBUG_PRINT("info", ("Found %s.%s in NDB", elmt.database, elmt.name));
+ if (elmt.state != NDBOBJ::StateOnline &&
+ elmt.state != NDBOBJ::StateBackup &&
+ elmt.state != NDBOBJ::StateBuilding)
+ {
+ sql_print_information("NDB: skipping setup table %s.%s, in state %d",
+ elmt.database, elmt.name, elmt.state);
+ skipped++;
+ continue;
+ }
+
+ ndb->setDatabaseName(elmt.database);
+ Ndb_table_guard ndbtab_g(dict, elmt.name);
+ const NDBTAB *ndbtab= ndbtab_g.get_table();
+ if (!ndbtab)
+ {
+ if (retries == 0)
+ sql_print_error("NDB: failed to setup table %s.%s, error: %d, %s",
+ elmt.database, elmt.name,
+ dict->getNdbError().code,
+ dict->getNdbError().message);
+ unhandled++;
+ continue;
+ }
+
+ if (ndbtab->getFrmLength() == 0)
+ continue;
+
+ /* check if database exists */
+ char *end= key +
+ build_table_filename(key, sizeof(key) - 1, elmt.database, "", "", 0);
+ if (my_access(key, F_OK))
+ {
+ /* no such database defined, skip table */
+ continue;
+ }
+ /* finalize construction of path */
+ end+= tablename_to_filename(elmt.name, end,
+ (uint)(sizeof(key)-(end-key)));
+ uchar *data= 0, *pack_data= 0;
+ size_t length, pack_length;
+ int discover= 0;
+ if (readfrm(key, &data, &length) ||
+ packfrm(data, length, &pack_data, &pack_length))
+ {
+ discover= 1;
+ sql_print_information("NDB: missing frm for %s.%s, discovering...",
+ elmt.database, elmt.name);
+ }
+ else if (cmp_frm(ndbtab, pack_data, pack_length))
+ {
+ /* ndb_share reference temporary */
+ NDB_SHARE *share= get_share(key, 0, FALSE);
+ if (share)
+ {
+ DBUG_PRINT("NDB_SHARE", ("%s temporary use_count: %u",
+ share->key, share->use_count));
+ }
+ if (!share || get_ndb_share_state(share) != NSS_ALTERED)
+ {
+ discover= 1;
+ sql_print_information("NDB: mismatch in frm for %s.%s,"
+ " discovering...",
+ elmt.database, elmt.name);
+ }
+ if (share)
+ {
+ /* ndb_share reference temporary free */
+ DBUG_PRINT("NDB_SHARE", ("%s temporary free use_count: %u",
+ share->key, share->use_count));
+ free_share(&share);
+ }
+ }
+ my_free((char*) data, MYF(MY_ALLOW_ZERO_PTR));
+ my_free((char*) pack_data, MYF(MY_ALLOW_ZERO_PTR));
+
+ if (discover)
+ {
+ /* ToDo 4.1 database needs to be created if missing */
+ if (ndb_create_table_from_engine(thd, elmt.database, elmt.name))
+ {
+ /* ToDo 4.1 handle error */
+ }
+ }
+ else
+ {
+ /* set up replication for this table */
+ ndbcluster_create_binlog_setup(thd, ndb, key, (uint)(end-key),
+ elmt.database, elmt.name,
+ 0);
+ }
+ }
+ }
+ while (unhandled && retries);
+
+ DBUG_RETURN(-(skipped + unhandled));
+}
+
+
bool
ndb_binlog_setup(THD *thd)
{
=== modified file 'sql/ha_ndbcluster_binlog.h'
--- a/sql/ha_ndbcluster_binlog.h 2011-10-27 08:53:55 +0000
+++ b/sql/ha_ndbcluster_binlog.h 2011-10-27 09:17:34 +0000
@@ -212,37 +212,6 @@ ndbcluster_show_status_binlog(THD* thd,
*/
int cmp_frm(const NDBTAB *ndbtab, const void *pack_data,
size_t pack_length);
-int ndbcluster_find_all_files(THD *thd);
-
-NDB_SHARE *ndbcluster_get_share(const char *key,
- TABLE *table,
- bool create_if_not_exists,
- bool have_lock);
-NDB_SHARE *ndbcluster_get_share(NDB_SHARE *share);
-void ndbcluster_free_share(NDB_SHARE **share, bool have_lock);
-void ndbcluster_real_free_share(NDB_SHARE **share);
-int handle_trailing_share(THD *thd, NDB_SHARE *share);
-int ndbcluster_prepare_rename_share(NDB_SHARE *share, const char *new_key);
-int ndbcluster_rename_share(THD *thd, NDB_SHARE *share);
-int ndbcluster_undo_rename_share(THD *thd, NDB_SHARE *share);
-void ndbcluster_mark_share_dropped(NDB_SHARE*);
-inline NDB_SHARE *get_share(const char *key,
- TABLE *table,
- bool create_if_not_exists= TRUE,
- bool have_lock= FALSE)
-{
- return ndbcluster_get_share(key, table, create_if_not_exists, have_lock);
-}
-
-inline NDB_SHARE *get_share(NDB_SHARE *share)
-{
- return ndbcluster_get_share(share);
-}
-
-inline void free_share(NDB_SHARE **share, bool have_lock= FALSE)
-{
- ndbcluster_free_share(share, have_lock);
-}
/*
Helper functions
=== modified file 'sql/ndb_share.h'
--- a/sql/ndb_share.h 2011-10-27 08:50:09 +0000
+++ b/sql/ndb_share.h 2011-10-27 09:10:08 +0000
@@ -257,4 +257,35 @@ inline void set_binlog_use_update(NDB_SH
inline my_bool get_binlog_use_update(NDB_SHARE *share)
{ return (share->flags & NSF_BINLOG_USE_UPDATE) != 0; }
+
+NDB_SHARE *ndbcluster_get_share(const char *key,
+ struct TABLE *table,
+ bool create_if_not_exists,
+ bool have_lock);
+NDB_SHARE *ndbcluster_get_share(NDB_SHARE *share);
+void ndbcluster_free_share(NDB_SHARE **share, bool have_lock);
+void ndbcluster_real_free_share(NDB_SHARE **share);
+int handle_trailing_share(THD *thd, NDB_SHARE *share);
+int ndbcluster_prepare_rename_share(NDB_SHARE *share, const char *new_key);
+int ndbcluster_rename_share(THD *thd, NDB_SHARE *share);
+int ndbcluster_undo_rename_share(THD *thd, NDB_SHARE *share);
+void ndbcluster_mark_share_dropped(NDB_SHARE*);
+inline NDB_SHARE *get_share(const char *key,
+ struct TABLE *table,
+ bool create_if_not_exists= TRUE,
+ bool have_lock= FALSE)
+{
+ return ndbcluster_get_share(key, table, create_if_not_exists, have_lock);
+}
+
+inline NDB_SHARE *get_share(NDB_SHARE *share)
+{
+ return ndbcluster_get_share(share);
+}
+
+inline void free_share(NDB_SHARE **share, bool have_lock= FALSE)
+{
+ ndbcluster_free_share(share, have_lock);
+}
+
#endif
No bundle (reason: useless for push emails).| Thread |
|---|
| • bzr push into mysql-5.5-cluster branch (magnus.blaudd:3628 to 3630) | Magnus Blåudd | 27 Oct |