3658 Magnus Blåudd 2011-10-28
ndb schema dist - indent
modified:
sql/ha_ndbcluster_binlog.cc
3657 Magnus Blåudd 2011-10-28
ndb schema dist
- change to use generic printout for type(as string), db and name instead of one
specialized print in each case
modified:
sql/ha_ndbcluster_binlog.cc
3656 Magnus Blåudd 2011-10-28
ndb schema dist
- remoe "magic flag" log_query and call the function directly instead
modified:
sql/ha_ndbcluster_binlog.cc
3655 Magnus Blåudd 2011-10-28
ndb schema dist
- add comment
- add new line
- remove useless use of "enum"
modified:
sql/ha_ndbcluster_binlog.cc
3654 Magnus Blåudd 2011-10-28
ndb schema dist
- add new lines between each case in the switch
modified:
sql/ha_ndbcluster_binlog.cc
3653 Magnus Blåudd 2011-10-28
ndb schema dist
- split 'handle_schema_log_post_epoch' into two functions, one which is looping and one which
handles the Ndb_schema_op processing
modified:
sql/ha_ndbcluster_binlog.cc
3652 Magnus Blåudd 2011-10-28
ndb schema dist
- pass own nodeid to constructor of Ndb_schema_event_handler and use it as "own_nodeid" to
avoid hardcoded dependency on g_ndbcluster_connection
modified:
sql/ha_ndbcluster_binlog.cc
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc 2011-10-28 12:30:53 +0000
+++ b/sql/ha_ndbcluster_binlog.cc 2011-10-28 13:18:42 +0000
@@ -2878,37 +2878,28 @@ class Ndb_schema_event_handler {
DBUG_RETURN(0);
}
-
-/*
- process any operations that should be done after
- the epoch is complete
-*/
-static void
-handle_schema_log_post_epoch(THD *thd,
- List<Cluster_schema> *log_list)
-{
- DBUG_ENTER("handle_schema_log_post_epoch");
-
- Thd_ndb *thd_ndb= get_thd_ndb(thd);
- Ndb *ndb= thd_ndb->ndb;
- NDBDICT *dict= ndb->getDictionary();
-
- Cluster_schema *schema;
- while ((schema= log_list->pop()))
+ void
+ handle_schema_op_post_epoch(Ndb_schema_op* schema)
{
+ DBUG_ENTER("handle_schema_op_post_epoch");
+ THD* thd = m_thd; // Code compatibility
+ Thd_ndb *thd_ndb= get_thd_ndb(thd);
+ Ndb *ndb= thd_ndb->ndb;
+ NDBDICT *dict= ndb->getDictionary();
Thd_ndb_options_guard thd_ndb_options(thd_ndb);
DBUG_PRINT("info",
("%s.%s: log query_length: %d query: '%s' type: %d",
schema->db, schema->name,
schema->query_length, schema->query,
schema->type));
- int log_query= 0;
+
{
- enum SCHEMA_OP_TYPE schema_type= (enum SCHEMA_OP_TYPE)schema->type;
+ const SCHEMA_OP_TYPE schema_type= (SCHEMA_OP_TYPE)schema->type;
char key[FN_REFLEN + 1];
build_table_filename(key, sizeof(key) - 1, schema->db, schema->name, "", 0);
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_SCHEMA_OBJECT*) my_hash_search(&ndb_schema_objects,
@@ -2955,8 +2946,15 @@ handle_schema_log_post_epoch(THD *thd,
}
}
pthread_mutex_unlock(&ndbcluster_mutex);
- continue;
+ DBUG_VOID_RETURN;
}
+
+ if (opt_ndb_extra_logging > 9)
+ sql_print_information("%s - %s.%s",
+ get_schema_type_name(schema_type),
+ schema->db ? schema->db : "(null)",
+ schema->name ? schema->name : "(null)");
+
/* ndb_share reference temporary, free below */
NDB_SHARE *share= get_share(key, 0, FALSE, FALSE);
if (share)
@@ -2967,12 +2965,11 @@ handle_schema_log_post_epoch(THD *thd,
switch (schema_type)
{
case SOT_DROP_DB:
- log_query= 1;
+ write_schema_op_to_binlog(thd, schema);
break;
+
case SOT_DROP_TABLE:
- if (opt_ndb_extra_logging > 9)
- sql_print_information("SOT_DROP_TABLE %s.%s", schema->db, schema->name);
- log_query= 1;
+ write_schema_op_to_binlog(thd, schema);
{
ndb->setDatabaseName(schema->db);
Ndb_table_guard ndbtab_g(dict, schema->name);
@@ -2986,29 +2983,25 @@ handle_schema_log_post_epoch(THD *thd,
close_cached_tables(thd, &table_list, FALSE, FALSE, FALSE);
}
break;
+
case SOT_RENAME_TABLE:
- if (opt_ndb_extra_logging > 9)
- sql_print_information("SOT_RENAME_TABLE %s.%s", schema->db, schema->name);
- log_query= 1;
+ write_schema_op_to_binlog(thd, schema);
if (share)
{
ndbcluster_rename_share(thd, share);
}
break;
+
case SOT_RENAME_TABLE_PREPARE:
- if (opt_ndb_extra_logging > 9)
- sql_print_information("SOT_RENAME_TABLE_PREPARE %s.%s -> %s",
- schema->db, schema->name, schema->query);
if (share &&
schema->node_id != g_ndb_cluster_connection->node_id())
ndbcluster_prepare_rename_share(share, schema->query);
break;
+
case SOT_ALTER_TABLE_COMMIT:
- if (opt_ndb_extra_logging > 9)
- sql_print_information("SOT_ALTER_TABLE_COMMIT %s.%s", schema->db, schema->name);
if (schema->node_id == g_ndb_cluster_connection->node_id())
break;
- log_query= 1;
+ write_schema_op_to_binlog(thd, schema);
{
ndb->setDatabaseName(schema->db);
Ndb_table_guard ndbtab_g(dict, schema->name);
@@ -3069,8 +3062,6 @@ handle_schema_log_post_epoch(THD *thd,
case SOT_ONLINE_ALTER_TABLE_PREPARE:
{
- if (opt_ndb_extra_logging > 9)
- sql_print_information("SOT_ONLINE_ALTER_TABLE_PREPARE %s.%s", schema->db, schema->name);
int error= 0;
ndb->setDatabaseName(schema->db);
{
@@ -3098,7 +3089,7 @@ handle_schema_log_post_epoch(THD *thd,
DBUG_PRINT("info", ("Detected frm change of table %s.%s",
schema->db, schema->name));
- log_query= 1;
+ write_schema_op_to_binlog(thd, schema);
build_table_filename(key, FN_LEN-1, schema->db, schema->name, NullS, 0);
/*
If the there is no local table shadowing the altered table and
@@ -3177,10 +3168,9 @@ handle_schema_log_post_epoch(THD *thd,
}
break;
}
+
case SOT_ONLINE_ALTER_TABLE_COMMIT:
{
- if (opt_ndb_extra_logging > 9)
- sql_print_information("SOT_ONLINE_ALTER_TABLE_COMMIT %s.%s", schema->db, schema->name);
if (share)
{
pthread_mutex_lock(&share->mutex);
@@ -3202,10 +3192,9 @@ handle_schema_log_post_epoch(THD *thd,
}
break;
}
+
case SOT_RENAME_TABLE_NEW:
- if (opt_ndb_extra_logging > 9)
- sql_print_information("SOT_RENAME_TABLE_NEW %s.%s", schema->db, schema->name);
- log_query= 1;
+ write_schema_op_to_binlog(thd, schema);
if (ndb_binlog_running && (!share || !share->op))
{
/*
@@ -3236,9 +3225,11 @@ handle_schema_log_post_epoch(THD *thd,
}
}
break;
+
default:
DBUG_ASSERT(FALSE);
}
+
if (share)
{
/* ndb_share reference temporary free */
@@ -3248,27 +3239,43 @@ handle_schema_log_post_epoch(THD *thd,
share= 0;
}
}
- if (log_query)
- write_schema_op_to_binlog(thd, schema);
+
+ DBUG_VOID_RETURN;
}
- DBUG_VOID_RETURN;
-}
+ /*
+ process any operations that should be done after
+ the epoch is complete
+ */
+ void
+ handle_schema_log_post_epoch(THD *thd,
+ List<Cluster_schema> *log_list)
+ {
+ DBUG_ENTER("handle_schema_log_post_epoch");
+
+ Ndb_schema_op* schema;
+ while ((schema= log_list->pop()))
+ {
+ handle_schema_op_post_epoch(schema);
+ }
+ DBUG_VOID_RETURN;
+ }
-static void
-handle_schema_unlock_post_epoch(THD *thd,
- List<Cluster_schema> *unlock_list)
-{
- DBUG_ENTER("handle_schema_unlock_post_epoch");
- Cluster_schema *schema;
- while ((schema= unlock_list->pop()))
+ static void
+ handle_schema_unlock_post_epoch(THD *thd,
+ List<Cluster_schema> *unlock_list)
{
- ndbcluster_update_slock(thd, schema->db, schema->name,
- schema->id, schema->version);
+ DBUG_ENTER("handle_schema_unlock_post_epoch");
+
+ Cluster_schema *schema;
+ while ((schema= unlock_list->pop()))
+ {
+ ndbcluster_update_slock(thd, schema->db, schema->name,
+ schema->id, schema->version);
+ }
+ DBUG_VOID_RETURN;
}
- DBUG_VOID_RETURN;
-}
THD* m_thd;
MEM_ROOT* m_mem_root;
No bundle (reason: useless for push emails).| Thread |
|---|
| • bzr push into mysql-5.5-cluster branch (magnus.blaudd:3652 to 3658) | Magnus Blåudd | 1 Nov |