3655 magnus.blaudd@stripped 2011-11-10
ndb schem dist
- finally remopve the duplicate switch in handle_schema_op and handle each op only once
modified:
sql/ha_ndbcluster_binlog.cc
3654 magnus.blaudd@stripped 2011-11-10
ndb schema dist
- factor out handlers for create table, truncate table, grant operations, alter db and create db
modified:
sql/ha_ndbcluster_binlog.cc
3653 magnus.blaudd@stripped 2011-11-10
ndb schema dist
- remove now unused 'post_epoch_unlock' flag and logic
modified:
sql/ha_ndbcluster_binlog.cc
=== modified file 'sql/ha_ndbcluster_binlog.cc'
--- a/sql/ha_ndbcluster_binlog.cc 2011-11-10 09:47:05 +0000
+++ b/sql/ha_ndbcluster_binlog.cc 2011-11-10 10:33:33 +0000
@@ -3043,6 +3043,155 @@ class Ndb_schema_event_handler {
}
+ void
+ handle_truncate_table(Ndb_schema_op* schema)
+ {
+ DBUG_ENTER("handle_truncate_table");
+
+ assert(!is_post_epoch()); // Always directly
+
+ if (schema->node_id == own_nodeid())
+ DBUG_VOID_RETURN;
+
+ write_schema_op_to_binlog(m_thd, schema);
+
+ NDB_SHARE *share= get_share(schema);
+ // invalidation already handled by binlog thread
+ if (!share || !share->op)
+ {
+ ndbapi_invalidate_table(schema->db, schema->name);
+ mysqld_close_cached_table(schema->db, schema->name);
+ }
+ if (share)
+ free_share(&share);
+
+ if (is_local_table(schema->db, schema->name))
+ {
+ sql_print_error("NDB Binlog: Skipping locally defined table "
+ "'%s.%s' from binlog schema event '%s' from "
+ "node %d. ",
+ schema->db, schema->name, schema->query,
+ schema->node_id);
+ DBUG_VOID_RETURN;
+ }
+
+ if (ndb_create_table_from_engine(m_thd, schema->db, schema->name))
+ {
+ print_could_not_discover_error(m_thd, schema);
+ }
+
+ DBUG_VOID_RETURN;
+ }
+
+
+ void
+ handle_create_table(Ndb_schema_op* schema)
+ {
+ DBUG_ENTER("handle_create_table");
+
+ assert(!is_post_epoch()); // Always directly
+
+ if (schema->node_id == own_nodeid())
+ DBUG_VOID_RETURN;
+
+ write_schema_op_to_binlog(m_thd, schema);
+
+ if (is_local_table(schema->db, schema->name))
+ {
+ sql_print_error("NDB Binlog: Skipping locally defined table '%s.%s' from "
+ "binlog schema event '%s' from node %d. ",
+ schema->db, schema->name, schema->query,
+ schema->node_id);
+ DBUG_VOID_RETURN;
+ }
+
+ if (ndb_create_table_from_engine(m_thd, schema->db, schema->name))
+ {
+ print_could_not_discover_error(m_thd, schema);
+ }
+
+ DBUG_VOID_RETURN;
+ }
+
+
+ void
+ handle_create_db(Ndb_schema_op* schema)
+ {
+ DBUG_ENTER("handle_create_db");
+
+ assert(!is_post_epoch()); // Always directly
+
+ if (schema->node_id == own_nodeid())
+ DBUG_VOID_RETURN;
+
+ write_schema_op_to_binlog(m_thd, schema);
+
+ Thd_ndb *thd_ndb= get_thd_ndb(m_thd);
+ Thd_ndb_options_guard thd_ndb_options(thd_ndb);
+ thd_ndb_options.set(TNO_NO_LOCK_SCHEMA_OP);
+ const int no_print_error[1]= {0};
+ run_query(m_thd, schema->query,
+ schema->query + schema->query_length,
+ no_print_error);
+
+ DBUG_VOID_RETURN;
+ }
+
+
+ void
+ handle_alter_db(Ndb_schema_op* schema)
+ {
+ DBUG_ENTER("handle_alter_db");
+
+ assert(!is_post_epoch()); // Always directly
+
+ if (schema->node_id == own_nodeid())
+ DBUG_VOID_RETURN;
+
+ write_schema_op_to_binlog(m_thd, schema);
+
+ Thd_ndb *thd_ndb= get_thd_ndb(m_thd);
+ Thd_ndb_options_guard thd_ndb_options(thd_ndb);
+ thd_ndb_options.set(TNO_NO_LOCK_SCHEMA_OP);
+ const int no_print_error[1]= {0};
+ run_query(m_thd, schema->query,
+ schema->query + schema->query_length,
+ no_print_error);
+
+ DBUG_VOID_RETURN;
+ }
+
+
+ void
+ handle_grant_op(Ndb_schema_op* schema)
+ {
+ DBUG_ENTER("handle_grant_op");
+
+ assert(!is_post_epoch()); // Always directly
+
+ if (schema->node_id == own_nodeid())
+ DBUG_VOID_RETURN;
+
+ write_schema_op_to_binlog(m_thd, schema);
+
+ if (opt_ndb_extra_logging > 9)
+ sql_print_information("Got dist_priv event: %s, "
+ "flushing privileges",
+ get_schema_type_name(schema->type));
+
+ Thd_ndb *thd_ndb= get_thd_ndb(m_thd);
+ Thd_ndb_options_guard thd_ndb_options(thd_ndb);
+ thd_ndb_options.set(TNO_NO_LOCK_SCHEMA_OP);
+ const int no_print_error[1]= {0};
+ char *cmd= (char *) "flush privileges";
+ run_query(m_thd, cmd,
+ cmd + strlen(cmd),
+ no_print_error);
+
+ DBUG_VOID_RETURN;
+ }
+
+
int
handle_schema_op(Ndb_schema_op* schema)
{
@@ -3095,124 +3244,43 @@ class Ndb_schema_event_handler {
unlock_after_epoch(schema);
DBUG_RETURN(0);
- default:
+ case SOT_TRUNCATE_TABLE:
+ handle_truncate_table(schema);
+ break;
+
+ case SOT_CREATE_TABLE:
+ handle_create_table(schema);
break;
+
+ case SOT_CREATE_DB:
+ handle_create_db(schema);
+ break;
+
+ case SOT_ALTER_DB:
+ handle_alter_db(schema);
+ break;
+
+ case SOT_CREATE_USER:
+ case SOT_DROP_USER:
+ case SOT_RENAME_USER:
+ case SOT_GRANT:
+ case SOT_REVOKE:
+ handle_grant_op(schema);
+ break;
+
+ case SOT_TABLESPACE:
+ case SOT_LOGFILE_GROUP:
+ write_schema_op_to_binlog(m_thd, schema);
+ break;
+
}
- if (schema->node_id != own_nodeid())
+ /* signal that schema operation has been handled */
+ DBUG_DUMP("slock", (uchar*) schema->slock_buf, schema->slock_length);
+ if (bitmap_is_set(&schema->slock, own_nodeid()))
{
- THD* thd= m_thd; // Code compatibility
- Thd_ndb *thd_ndb= get_thd_ndb(thd);
- Thd_ndb_options_guard thd_ndb_options(thd_ndb);
-
- switch (schema_type)
- {
-
- case SOT_TRUNCATE_TABLE:
- {
- NDB_SHARE *share= get_share(schema);
- // invalidation already handled by binlog thread
- if (!share || !share->op)
- {
- ndbapi_invalidate_table(schema->db, schema->name);
- mysqld_close_cached_table(schema->db, schema->name);
- }
- if (share)
- free_share(&share);
-
- if (is_local_table(schema->db, schema->name))
- {
- sql_print_error("NDB Binlog: Skipping locally defined table "
- "'%s.%s' from binlog schema event '%s' from "
- "node %d. ",
- schema->db, schema->name, schema->query,
- schema->node_id);
- }
- else if (ndb_create_table_from_engine(thd, schema->db, schema->name))
- {
- print_could_not_discover_error(thd, schema);
- }
- write_schema_op_to_binlog(thd, schema);
- break;
- }
-
- case SOT_CREATE_TABLE:
- if (is_local_table(schema->db, schema->name))
- {
- DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'",
- schema->db, schema->name));
- sql_print_error("NDB Binlog: Skipping locally defined table '%s.%s' from "
- "binlog schema event '%s' from node %d. ",
- schema->db, schema->name, schema->query,
- schema->node_id);
- }
- else if (ndb_create_table_from_engine(thd, schema->db, schema->name))
- {
- print_could_not_discover_error(thd, schema);
- }
- write_schema_op_to_binlog(thd, schema);
- break;
-
- case SOT_CREATE_DB:
- case SOT_ALTER_DB:
- {
- thd_ndb_options.set(TNO_NO_LOCK_SCHEMA_OP);
- const int no_print_error[1]= {0};
- run_query(thd, schema->query,
- schema->query + schema->query_length,
- no_print_error);
- write_schema_op_to_binlog(thd, schema);
- break;
- }
-
- case SOT_CREATE_USER:
- case SOT_DROP_USER:
- case SOT_RENAME_USER:
- case SOT_GRANT:
- case SOT_REVOKE:
- {
- if (opt_ndb_extra_logging > 9)
- sql_print_information("Got dist_priv event: %s, "
- "flushing privileges",
- get_schema_type_name(schema_type));
-
- thd_ndb_options.set(TNO_NO_LOCK_SCHEMA_OP);
- const int no_print_error[1]= {0};
- char *cmd= (char *) "flush privileges";
- run_query(thd, cmd,
- cmd + strlen(cmd),
- no_print_error);
- write_schema_op_to_binlog(thd, schema);
- break;
- }
-
- case SOT_TABLESPACE:
- case SOT_LOGFILE_GROUP:
- write_schema_op_to_binlog(thd, schema);
- break;
-
- case SOT_ALTER_TABLE_COMMIT:
- case SOT_RENAME_TABLE_PREPARE:
- case SOT_ONLINE_ALTER_TABLE_PREPARE:
- case SOT_ONLINE_ALTER_TABLE_COMMIT:
- case SOT_CLEAR_SLOCK:
- case SOT_RENAME_TABLE:
- case SOT_DROP_TABLE:
- case SOT_DROP_DB:
- // Impossible to come here, the above types has already
- // been handled and caused the function to return
- abort();
- break;
-
- }
-
- /* signal that schema operation has been handled */
- DBUG_DUMP("slock", (uchar*) schema->slock_buf, schema->slock_length);
- if (bitmap_is_set(&schema->slock, own_nodeid()))
- {
- ack_schema_op(schema->db, schema->name,
- schema->id, schema->version);
- }
+ ack_schema_op(schema->db, schema->name,
+ schema->id, schema->version);
}
}
DBUG_RETURN(0);
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-5.5-cluster branch (magnus.blaudd:3653 to 3655) | magnus.blaudd | 11 Nov |