Commit 360ff3b0 authored by Nirbhay Choubey's avatar Nirbhay Choubey

Fix for build failures on Power8

parent 69e5f0f4
...@@ -1132,7 +1132,7 @@ Events::load_events_from_db(THD *thd) ...@@ -1132,7 +1132,7 @@ Events::load_events_from_db(THD *thd)
#ifdef WITH_WSREP #ifdef WITH_WSREP
// when SST from master node who initials event, the event status is ENABLED // 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. // this is problematic because there are two nodes with same events and both enabled.
if (et->originator != thd->variables.server_id) if (et->originator != (longlong) thd->variables.server_id)
{ {
store_record(table, record[1]); store_record(table, record[1]);
table->field[ET_FIELD_STATUS]-> table->field[ET_FIELD_STATUS]->
......
...@@ -440,8 +440,7 @@ static ssize_t sst_prepare_other (const char* method, ...@@ -440,8 +440,7 @@ static ssize_t sst_prepare_other (const char* method,
const char* addr_in, const char* addr_in,
const char** addr_out) const char** addr_out)
{ {
ssize_t cmd_len= 1024; char cmd_str[1024];
char cmd_str[cmd_len];
const char* sst_dir= mysql_real_data_home; const char* sst_dir= mysql_real_data_home;
const char* binlog_opt= ""; const char* binlog_opt= "";
char* binlog_opt_val= NULL; char* binlog_opt_val= NULL;
...@@ -456,7 +455,7 @@ static ssize_t sst_prepare_other (const char* method, ...@@ -456,7 +455,7 @@ static ssize_t sst_prepare_other (const char* method,
if (strlen(binlog_opt_val)) binlog_opt= WSREP_SST_OPT_BINLOG; if (strlen(binlog_opt_val)) binlog_opt= WSREP_SST_OPT_BINLOG;
ret= snprintf (cmd_str, cmd_len, ret= snprintf (cmd_str, sizeof(cmd_str),
"wsrep_sst_%s " "wsrep_sst_%s "
WSREP_SST_OPT_ROLE" 'joiner' " WSREP_SST_OPT_ROLE" 'joiner' "
WSREP_SST_OPT_ADDR" '%s' " WSREP_SST_OPT_ADDR" '%s' "
...@@ -470,7 +469,7 @@ static ssize_t sst_prepare_other (const char* method, ...@@ -470,7 +469,7 @@ static ssize_t sst_prepare_other (const char* method,
binlog_opt, binlog_opt_val); binlog_opt, binlog_opt_val);
my_free(binlog_opt_val); my_free(binlog_opt_val);
if (ret < 0 || ret >= cmd_len) if (ret < 0 || ret >= (int)sizeof(cmd_str))
{ {
WSREP_ERROR("sst_prepare_other(): snprintf() failed: %d", ret); WSREP_ERROR("sst_prepare_other(): snprintf() failed: %d", ret);
return (ret < 0 ? ret : -EMSGSIZE); return (ret < 0 ? ret : -EMSGSIZE);
...@@ -721,7 +720,7 @@ static int sst_donate_mysqldump (const char* addr, ...@@ -721,7 +720,7 @@ static int sst_donate_mysqldump (const char* addr,
host_len = strlen (addr) + 1; host_len = strlen (addr) + 1;
} }
char host[host_len]; char *host= (char *) alloca(host_len);
strncpy (host, addr, host_len - 1); strncpy (host, addr, host_len - 1);
host[host_len - 1] = '\0'; host[host_len - 1] = '\0';
...@@ -741,7 +740,7 @@ static int sst_donate_mysqldump (const char* addr, ...@@ -741,7 +740,7 @@ static int sst_donate_mysqldump (const char* addr,
user_len = (auth) ? strlen (auth) + 1 : 1; user_len = (auth) ? strlen (auth) + 1 : 1;
} }
char user[user_len]; char *user= (char *) alloca(user_len);
strncpy (user, (auth) ? auth : "", user_len - 1); strncpy (user, (auth) ? auth : "", user_len - 1);
user[user_len - 1] = '\0'; user[user_len - 1] = '\0';
...@@ -749,12 +748,11 @@ static int sst_donate_mysqldump (const char* addr, ...@@ -749,12 +748,11 @@ static int sst_donate_mysqldump (const char* addr,
int ret = sst_mysqldump_check_addr (user, pswd, host, port); int ret = sst_mysqldump_check_addr (user, pswd, host, port);
if (!ret) if (!ret)
{ {
size_t cmd_len= 1024; char cmd_str[1024];
char cmd_str[cmd_len];
if (!bypass && wsrep_sst_donor_rejects_queries) sst_reject_queries(TRUE); if (!bypass && wsrep_sst_donor_rejects_queries) sst_reject_queries(TRUE);
snprintf (cmd_str, cmd_len, snprintf (cmd_str, sizeof(cmd_str),
"wsrep_sst_mysqldump " "wsrep_sst_mysqldump "
WSREP_SST_OPT_USER" '%s' " WSREP_SST_OPT_USER" '%s' "
WSREP_SST_OPT_PSWD" '%s' " WSREP_SST_OPT_PSWD" '%s' "
...@@ -850,11 +848,13 @@ static int sst_flush_tables(THD* thd) ...@@ -850,11 +848,13 @@ static int sst_flush_tables(THD* thd)
{ {
WSREP_INFO("Tables flushed."); WSREP_INFO("Tables flushed.");
const char base_name[]= "tables_flushed"; const char base_name[]= "tables_flushed";
ssize_t const full_len= strlen(mysql_real_data_home) + strlen(base_name)+2; ssize_t const full_len= strlen(mysql_real_data_home) + strlen(base_name)+2;
char real_name[full_len]; char *real_name= (char *) alloca(full_len);
sprintf(real_name, "%s/%s", mysql_real_data_home, base_name); snprintf(real_name, (size_t) full_len, "%s/%s", mysql_real_data_home,
char tmp_name[full_len + 4]; base_name);
sprintf(tmp_name, "%s.tmp", real_name); char *tmp_name= (char *) alloca(full_len + 4);
snprintf(tmp_name, (size_t) full_len + 4, "%s.tmp", real_name);
FILE* file= fopen(tmp_name, "w+"); FILE* file= fopen(tmp_name, "w+");
if (0 == file) if (0 == file)
...@@ -1014,8 +1014,7 @@ static int sst_donate_other (const char* method, ...@@ -1014,8 +1014,7 @@ static int sst_donate_other (const char* method,
wsrep_seqno_t seqno, wsrep_seqno_t seqno,
bool bypass) bool bypass)
{ {
ssize_t cmd_len = 4096; char cmd_str[4096];
char cmd_str[cmd_len];
const char* binlog_opt= ""; const char* binlog_opt= "";
char* binlog_opt_val= NULL; char* binlog_opt_val= NULL;
...@@ -1027,7 +1026,7 @@ static int sst_donate_other (const char* method, ...@@ -1027,7 +1026,7 @@ static int sst_donate_other (const char* method,
} }
if (strlen(binlog_opt_val)) binlog_opt= WSREP_SST_OPT_BINLOG; if (strlen(binlog_opt_val)) binlog_opt= WSREP_SST_OPT_BINLOG;
ret= snprintf (cmd_str, cmd_len, ret= snprintf (cmd_str, sizeof(cmd_str),
"wsrep_sst_%s " "wsrep_sst_%s "
WSREP_SST_OPT_ROLE" 'donor' " WSREP_SST_OPT_ROLE" 'donor' "
WSREP_SST_OPT_ADDR" '%s' " WSREP_SST_OPT_ADDR" '%s' "
...@@ -1045,7 +1044,7 @@ static int sst_donate_other (const char* method, ...@@ -1045,7 +1044,7 @@ static int sst_donate_other (const char* method,
bypass ? " "WSREP_SST_OPT_BYPASS : ""); bypass ? " "WSREP_SST_OPT_BYPASS : "");
my_free(binlog_opt_val); my_free(binlog_opt_val);
if (ret < 0 || ret >= cmd_len) if (ret < 0 || ret >= (int) sizeof(cmd_str))
{ {
WSREP_ERROR("sst_donate_other(): snprintf() failed: %d", ret); WSREP_ERROR("sst_donate_other(): snprintf() failed: %d", ret);
return (ret < 0 ? ret : -EMSGSIZE); return (ret < 0 ? ret : -EMSGSIZE);
......
...@@ -9782,7 +9782,6 @@ ha_innobase::wsrep_append_keys( ...@@ -9782,7 +9782,6 @@ ha_innobase::wsrep_append_keys(
uint len; uint len;
char keyval[WSREP_MAX_SUPPORTED_KEY_LENGTH+1] = {'\0'}; char keyval[WSREP_MAX_SUPPORTED_KEY_LENGTH+1] = {'\0'};
char *key = &keyval[0]; char *key = &keyval[0];
KEY *key_info = table->key_info;
ibool is_null; ibool is_null;
len = wsrep_store_key_val_for_row( len = wsrep_store_key_val_for_row(
...@@ -17251,18 +17250,18 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr, ...@@ -17251,18 +17250,18 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
if (!thd) { if (!thd) {
DBUG_PRINT("wsrep", ("no thd for conflicting lock")); DBUG_PRINT("wsrep", ("no thd for conflicting lock"));
WSREP_WARN("no THD for trx: %llu", victim_trx->id); WSREP_WARN("no THD for trx: %lu", victim_trx->id);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
if (!bf_thd) { if (!bf_thd) {
DBUG_PRINT("wsrep", ("no BF thd for conflicting lock")); DBUG_PRINT("wsrep", ("no BF thd for conflicting lock"));
WSREP_WARN("no BF THD for trx: %llu", (bf_trx) ? bf_trx->id : 0); WSREP_WARN("no BF THD for trx: %lu", (bf_trx) ? bf_trx->id : 0);
DBUG_RETURN(1); DBUG_RETURN(1);
} }
WSREP_LOG_CONFLICT(bf_thd, thd, TRUE); WSREP_LOG_CONFLICT(bf_thd, thd, TRUE);
WSREP_DEBUG("BF kill (%lu, seqno: %lld), victim: (%lu) trx: %llu", WSREP_DEBUG("BF kill (%lu, seqno: %lld), victim: (%lu) trx: %lu",
signal, (long long)bf_seqno, signal, (long long)bf_seqno,
wsrep_thd_thread_id(thd), wsrep_thd_thread_id(thd),
victim_trx->id); victim_trx->id);
...@@ -17273,12 +17272,12 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr, ...@@ -17273,12 +17272,12 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
wsrep_thd_LOCK(thd); wsrep_thd_LOCK(thd);
if (wsrep_thd_query_state(thd) == QUERY_EXITING) { if (wsrep_thd_query_state(thd) == QUERY_EXITING) {
WSREP_DEBUG("kill trx EXITING for %llu", victim_trx->id); WSREP_DEBUG("kill trx EXITING for %lu", victim_trx->id);
wsrep_thd_UNLOCK(thd); wsrep_thd_UNLOCK(thd);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if(wsrep_thd_exec_mode(thd) != LOCAL_STATE) { if(wsrep_thd_exec_mode(thd) != LOCAL_STATE) {
WSREP_DEBUG("withdraw for BF trx: %llu, state: %d", WSREP_DEBUG("withdraw for BF trx: %lu, state: %d",
victim_trx->id, victim_trx->id,
wsrep_thd_conflict_state(thd)); wsrep_thd_conflict_state(thd));
} }
...@@ -17288,7 +17287,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr, ...@@ -17288,7 +17287,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
wsrep_thd_set_conflict_state(thd, MUST_ABORT); wsrep_thd_set_conflict_state(thd, MUST_ABORT);
break; break;
case MUST_ABORT: case MUST_ABORT:
WSREP_DEBUG("victim %llu in MUST ABORT state", WSREP_DEBUG("victim %lu in MUST ABORT state",
victim_trx->id); victim_trx->id);
wsrep_thd_UNLOCK(thd); wsrep_thd_UNLOCK(thd);
wsrep_thd_awake(thd, signal); wsrep_thd_awake(thd, signal);
...@@ -17297,7 +17296,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr, ...@@ -17297,7 +17296,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
case ABORTED: case ABORTED:
case ABORTING: // fall through case ABORTING: // fall through
default: default:
WSREP_DEBUG("victim %llu in state %d", WSREP_DEBUG("victim %lu in state %d",
victim_trx->id, wsrep_thd_conflict_state(thd)); victim_trx->id, wsrep_thd_conflict_state(thd));
wsrep_thd_UNLOCK(thd); wsrep_thd_UNLOCK(thd);
DBUG_RETURN(0); DBUG_RETURN(0);
...@@ -17310,7 +17309,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr, ...@@ -17310,7 +17309,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
WSREP_DEBUG("kill query for: %ld", WSREP_DEBUG("kill query for: %ld",
wsrep_thd_thread_id(thd)); wsrep_thd_thread_id(thd));
WSREP_DEBUG("kill trx QUERY_COMMITTING for %llu", WSREP_DEBUG("kill trx QUERY_COMMITTING for %lu",
victim_trx->id); victim_trx->id);
if (wsrep_thd_exec_mode(thd) == REPL_RECV) { if (wsrep_thd_exec_mode(thd) == REPL_RECV) {
...@@ -17324,7 +17323,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr, ...@@ -17324,7 +17323,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
switch (rcode) { switch (rcode) {
case WSREP_WARNING: case WSREP_WARNING:
WSREP_DEBUG("cancel commit warning: %llu", WSREP_DEBUG("cancel commit warning: %lu",
victim_trx->id); victim_trx->id);
wsrep_thd_UNLOCK(thd); wsrep_thd_UNLOCK(thd);
wsrep_thd_awake(thd, signal); wsrep_thd_awake(thd, signal);
...@@ -17334,8 +17333,8 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr, ...@@ -17334,8 +17333,8 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
break; break;
default: default:
WSREP_ERROR( WSREP_ERROR(
"cancel commit bad exit: %d %llu", "cancel commit bad exit: %d %lu",
rcode, rcode,
victim_trx->id); victim_trx->id);
/* unable to interrupt, must abort */ /* unable to interrupt, must abort */
/* note: kill_mysql() will block, if we cannot. /* note: kill_mysql() will block, if we cannot.
...@@ -17352,7 +17351,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr, ...@@ -17352,7 +17351,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
/* it is possible that victim trx is itself waiting for some /* it is possible that victim trx is itself waiting for some
* other lock. We need to cancel this waiting * other lock. We need to cancel this waiting
*/ */
WSREP_DEBUG("kill trx QUERY_EXEC for %llu", victim_trx->id); WSREP_DEBUG("kill trx QUERY_EXEC for %lu", victim_trx->id);
victim_trx->lock.was_chosen_as_deadlock_victim= TRUE; victim_trx->lock.was_chosen_as_deadlock_victim= TRUE;
if (victim_trx->lock.wait_lock) { if (victim_trx->lock.wait_lock) {
...@@ -17390,7 +17389,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr, ...@@ -17390,7 +17389,7 @@ wsrep_innobase_kill_one_trx(void * const bf_thd_ptr,
bool skip_abort= false; bool skip_abort= false;
wsrep_aborting_thd_t abortees; wsrep_aborting_thd_t abortees;
WSREP_DEBUG("kill IDLE for %llu", victim_trx->id); WSREP_DEBUG("kill IDLE for %lu", victim_trx->id);
if (wsrep_thd_exec_mode(thd) == REPL_RECV) { if (wsrep_thd_exec_mode(thd) == REPL_RECV) {
WSREP_DEBUG("kill BF IDLE, seqno: %lld", WSREP_DEBUG("kill BF IDLE, seqno: %lld",
......
...@@ -39,11 +39,10 @@ static wsrep_log_cb_t logger = default_logger; ...@@ -39,11 +39,10 @@ static wsrep_log_cb_t logger = default_logger;
static int verify(const wsrep_t *wh, const char *iface_ver) static int verify(const wsrep_t *wh, const char *iface_ver)
{ {
const size_t msg_len = 128; char msg[128];
char msg[msg_len];
#define VERIFY(_p) if (!(_p)) { \ #define VERIFY(_p) if (!(_p)) { \
snprintf(msg, msg_len, "wsrep_load(): verify(): %s\n", # _p); \ snprintf(msg, sizeof(msg), "wsrep_load(): verify(): %s\n", # _p); \
logger (WSREP_LOG_ERROR, msg); \ logger (WSREP_LOG_ERROR, msg); \
return EINVAL; \ return EINVAL; \
} }
...@@ -52,7 +51,7 @@ static int verify(const wsrep_t *wh, const char *iface_ver) ...@@ -52,7 +51,7 @@ static int verify(const wsrep_t *wh, const char *iface_ver)
VERIFY(wh->version); VERIFY(wh->version);
if (strcmp(wh->version, iface_ver)) { if (strcmp(wh->version, iface_ver)) {
snprintf (msg, msg_len, snprintf (msg, sizeof(msg),
"provider interface version mismatch: need '%s', found '%s'", "provider interface version mismatch: need '%s', found '%s'",
iface_ver, wh->version); iface_ver, wh->version);
logger (WSREP_LOG_ERROR, msg); logger (WSREP_LOG_ERROR, msg);
...@@ -115,9 +114,7 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) ...@@ -115,9 +114,7 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb)
int ret = 0; int ret = 0;
void *dlh = NULL; void *dlh = NULL;
wsrep_loader_fun dlfun; wsrep_loader_fun dlfun;
const size_t msg_len = 1024; char msg[1024];
char msg[msg_len + 1];
msg[msg_len] = 0;
if (NULL != log_cb) if (NULL != log_cb)
logger = log_cb; logger = log_cb;
...@@ -125,7 +122,7 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) ...@@ -125,7 +122,7 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb)
if (!(spec && hptr)) if (!(spec && hptr))
return EINVAL; return EINVAL;
snprintf (msg, msg_len, snprintf (msg, sizeof(msg),
"wsrep_load(): loading provider library '%s'", spec); "wsrep_load(): loading provider library '%s'", spec);
logger (WSREP_LOG_INFO, msg); logger (WSREP_LOG_INFO, msg);
...@@ -143,7 +140,7 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) ...@@ -143,7 +140,7 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb)
} }
if (!(dlh = dlopen(spec, RTLD_NOW | RTLD_LOCAL))) { if (!(dlh = dlopen(spec, RTLD_NOW | RTLD_LOCAL))) {
snprintf(msg, msg_len, "wsrep_load(): dlopen(): %s", dlerror()); snprintf(msg, sizeof(msg), "wsrep_load(): dlopen(): %s", dlerror());
logger (WSREP_LOG_ERROR, msg); logger (WSREP_LOG_ERROR, msg);
ret = EINVAL; ret = EINVAL;
goto out; goto out;
...@@ -155,14 +152,14 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) ...@@ -155,14 +152,14 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb)
} }
if ((ret = (*dlfun)(*hptr)) != 0) { if ((ret = (*dlfun)(*hptr)) != 0) {
snprintf(msg, msg_len, "wsrep_load(): loader failed: %s", snprintf(msg, sizeof(msg), "wsrep_load(): loader failed: %s",
strerror(ret)); strerror(ret));
logger (WSREP_LOG_ERROR, msg); logger (WSREP_LOG_ERROR, msg);
goto out; goto out;
} }
if ((ret = verify(*hptr, WSREP_INTERFACE_VERSION)) != 0) { if ((ret = verify(*hptr, WSREP_INTERFACE_VERSION)) != 0) {
snprintf (msg, msg_len, snprintf (msg, sizeof(msg),
"wsrep_load(): interface version mismatch: my version %s, " "wsrep_load(): interface version mismatch: my version %s, "
"provider version %s", WSREP_INTERFACE_VERSION, "provider version %s", WSREP_INTERFACE_VERSION,
(*hptr)->version); (*hptr)->version);
...@@ -178,7 +175,7 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) ...@@ -178,7 +175,7 @@ int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb)
free(*hptr); free(*hptr);
*hptr = NULL; *hptr = NULL;
} else { } else {
snprintf (msg, msg_len, snprintf (msg, sizeof(msg),
"wsrep_load(): %s %s by %s loaded successfully.", "wsrep_load(): %s %s by %s loaded successfully.",
(*hptr)->provider_name, (*hptr)->provider_version, (*hptr)->provider_name, (*hptr)->provider_version,
(*hptr)->provider_vendor); (*hptr)->provider_vendor);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment