summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@skysql.com>2014-06-10 17:00:32 -0400
committerNirbhay Choubey <nirbhay@skysql.com>2014-06-10 17:00:32 -0400
commitc29cbac2eb06ab4a2bf1aeda65c15fce40a84345 (patch)
tree9d5b5dab4dfd0fe78084b0654cd06d6f3fc1171b /sql
parent90ead99572c8168583cb0943792d964cc2a6abd2 (diff)
downloadmariadb-git-c29cbac2eb06ab4a2bf1aeda65c15fce40a84345.tar.gz
bzr merge -r3985..3997 codership/5.5
Diffstat (limited to 'sql')
-rw-r--r--sql/event_data_objects.cc13
-rw-r--r--sql/events.cc41
-rw-r--r--sql/mysqld.cc3
-rw-r--r--sql/sql_yacc.yy12
-rw-r--r--sql/wsrep_mysqld.cc18
-rw-r--r--sql/wsrep_mysqld.h1
-rw-r--r--sql/wsrep_thd.cc15
7 files changed, 95 insertions, 8 deletions
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index dfd35583581..dbf35bd94b7 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -1467,8 +1467,21 @@ end:
saved_master_access= thd->security_ctx->master_access;
thd->security_ctx->master_access |= SUPER_ACL;
+#ifdef WITH_WSREP
+ // sql_print_information("sizeof(LEX) = %d", sizeof(struct LEX));
+ // sizeof(LEX) = 4512, so it's relatively safe to allocate it on stack.
+ LEX lex;
+ lex.sql_command = SQLCOM_DROP_EVENT;
+ thd->lex = &lex;
+ WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL);
+#endif
+
ret= Events::drop_event(thd, dbname, name, FALSE);
+#ifdef WITH_WSREP
+ WSREP_TO_ISOLATION_END;
+ error:
+#endif
thd->security_ctx->master_access= saved_master_access;
}
}
diff --git a/sql/events.cc b/sql/events.cc
index e016ccd2b84..9e15a5f47bd 100644
--- a/sql/events.cc
+++ b/sql/events.cc
@@ -1104,6 +1104,20 @@ Events::load_events_from_db(THD *thd)
delete et;
goto end;
}
+#ifdef WITH_WSREP
+ // when SST from master node who initials event, the event status is ENABLED
+ // this is problematic because there are two nodes with same events and both enabled.
+ if (et->originator != thd->server_id)
+ {
+ store_record(table, record[1]);
+ table->field[ET_FIELD_STATUS]->
+ store((longlong) Event_parse_data::SLAVESIDE_DISABLED,
+ TRUE);
+ (void) table->file->ha_update_row(table->record[1], table->record[0]);
+ delete et;
+ continue;
+ }
+#endif
drop_on_completion= (et->on_completion ==
Event_parse_data::ON_COMPLETION_DROP);
@@ -1158,6 +1172,33 @@ int wsrep_create_event_query(THD *thd, uchar** buf, size_t* buf_len)
}
return wsrep_to_buf_helper(thd, log_query.ptr(), log_query.length(), buf, buf_len);
}
+static int
+wsrep_alter_query_string(THD *thd, String *buf)
+{
+ /* Append the "ALTER" part of the query */
+ if (buf->append(STRING_WITH_LEN("ALTER ")))
+ return 1;
+ /* Append definer */
+ append_definer(thd, buf, &(thd->lex->definer->user), &(thd->lex->definer->host));
+ /* Append the left part of thd->query after event name part */
+ if (buf->append(thd->lex->stmt_definition_begin,
+ thd->lex->stmt_definition_end -
+ thd->lex->stmt_definition_begin))
+ return 1;
+
+ return 0;
+}
+int wsrep_alter_event_query(THD *thd, uchar** buf, size_t* buf_len)
+{
+ String log_query;
+
+ if (wsrep_alter_query_string(thd, &log_query))
+ {
+ WSREP_WARN("events alter string failed: %s", thd->query());
+ return 1;
+ }
+ return wsrep_to_buf_helper(thd, log_query.ptr(), log_query.length(), buf, buf_len);
+}
#endif /* WITH_WSREP */
/**
@} (End of group Event_Scheduler)
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 33e5e47bff1..6d9c9eb0b7a 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2761,7 +2761,8 @@ bool one_thread_per_connection_end(THD *thd, bool put_in_cache)
/* Mark that current_thd is not valid anymore */
my_pthread_setspecific_ptr(THR_THD, 0);
#ifdef WITH_WSREP
- if (put_in_cache && !thd->wsrep_applier)
+ const bool wsrep_applier(thd->wsrep_applier);
+ if (put_in_cache && !wsrep_applier)
#else
if (put_in_cache)
#endif /* WITH_WSREP */
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 0a116b41308..5a9c71acc52 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -6550,7 +6550,7 @@ alter:
}
view_tail
{}
- | ALTER definer_opt EVENT_SYM sp_name
+ | ALTER definer_opt remember_name EVENT_SYM sp_name
{
/*
It is safe to use Lex->spname because
@@ -6562,9 +6562,12 @@ alter:
if (!(Lex->event_parse_data= Event_parse_data::new_instance(thd)))
MYSQL_YYABORT;
- Lex->event_parse_data->identifier= $4;
+ Lex->event_parse_data->identifier= $5;
Lex->sql_command= SQLCOM_ALTER_EVENT;
+#ifdef WITH_WSREP
+ Lex->stmt_definition_begin= $3;
+#endif
}
ev_alter_on_schedule_completion
opt_ev_rename_to
@@ -6572,7 +6575,7 @@ alter:
opt_ev_comment
opt_ev_sql_stmt
{
- if (!($6 || $7 || $8 || $9 || $10))
+ if (!($7 || $8 || $9 || $10 || $11))
{
my_parse_error(ER(ER_SYNTAX_ERROR));
MYSQL_YYABORT;
@@ -6582,6 +6585,9 @@ alter:
can overwrite it
*/
Lex->sql_command= SQLCOM_ALTER_EVENT;
+#ifdef WITH_WSREP
+ Lex->stmt_definition_end= (char*)YYLIP->get_cpp_ptr();
+#endif
}
| ALTER TABLESPACE alter_tablespace_info
{
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index 4fd07a9945c..1d869ab84c5 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -509,7 +509,20 @@ int wsrep_init()
wsrep_ready_set(TRUE);
wsrep_inited= 1;
global_system_variables.wsrep_on = 0;
- return 0;
+ wsrep_init_args args;
+ args.logger_cb = wsrep_log_cb;
+ args.options = (wsrep_provider_options) ?
+ wsrep_provider_options : "";
+ rcode = wsrep->init(wsrep, &args);
+ if (rcode)
+ {
+ DBUG_PRINT("wsrep",("wsrep::init() failed: %d", rcode));
+ WSREP_ERROR("wsrep::init() failed: %d, must shutdown", rcode);
+ wsrep->free(wsrep);
+ free(wsrep);
+ wsrep = NULL;
+ }
+ return rcode;
}
else
{
@@ -1216,6 +1229,9 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_,
case SQLCOM_CREATE_EVENT:
buf_err= wsrep_create_event_query(thd, &buf, &buf_len);
break;
+ case SQLCOM_ALTER_EVENT:
+ buf_err= wsrep_alter_event_query(thd, &buf, &buf_len);
+ break;
default:
buf_err= wsrep_to_buf_helper(thd, thd->query(), thd->query_length(), &buf,
&buf_len);
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index ec2a38278ab..7939bf55684 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -298,6 +298,7 @@ int wsrep_to_buf_helper(
int wsrep_create_sp(THD *thd, uchar** buf, size_t* buf_len);
int wsrep_create_trigger_query(THD *thd, uchar** buf, size_t* buf_len);
int wsrep_create_event_query(THD *thd, uchar** buf, size_t* buf_len);
+int wsrep_alter_event_query(THD *thd, uchar** buf, size_t* buf_len);
const wsrep_uuid_t* wsrep_cluster_uuid();
struct xid_t;
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index 3fed6db6d0d..132cfc7c5d2 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -23,11 +23,20 @@
#include "sql_base.h" // close_thread_tables()
#include "mysqld.h" // start_wsrep_THD();
-static long long wsrep_bf_aborts_counter = 0;
+
+#if (__LP64__)
+static volatile int64 wsrep_bf_aborts_counter(0);
+#define WSREP_ATOMIC_LOAD_LONG my_atomic_load64
+#define WSREP_ATOMIC_ADD_LONG my_atomic_add64
+#else
+static volatile int32 wsrep_bf_aborts_counter(0);
+#define WSREP_ATOMIC_LOAD_LONG my_atomic_load32
+#define WSREP_ATOMIC_ADD_LONG my_atomic_add32
+#endif
int wsrep_show_bf_aborts (THD *thd, SHOW_VAR *var, char *buff)
{
- wsrep_local_bf_aborts = my_atomic_load64(&wsrep_bf_aborts_counter);
+ wsrep_local_bf_aborts = WSREP_ATOMIC_LOAD_LONG(&wsrep_bf_aborts_counter);
var->type = SHOW_LONGLONG;
var->value = (char*)&wsrep_local_bf_aborts;
return 0;
@@ -39,7 +48,7 @@ void wsrep_client_rollback(THD *thd)
WSREP_DEBUG("client rollback due to BF abort for (%ld), query: %s",
thd->thread_id, thd->query());
- my_atomic_add64(&wsrep_bf_aborts_counter, 1);
+ WSREP_ATOMIC_ADD_LONG(&wsrep_bf_aborts_counter, 1);
thd->wsrep_conflict_state= ABORTING;
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);