summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-08-31 13:47:48 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-08-31 15:10:02 +0300
commit206528f722799b04708c60a71b59d75bd32bdeb3 (patch)
treed59cf6cdc943a797bc9ef901865da3566c27d93a /sql
parentb245023fe0bc6fa0bd6e2dfa9352b30b71d0d27d (diff)
parentf693170c75a1f39f3f06aca683fe4a1998785008 (diff)
downloadmariadb-git-206528f722799b04708c60a71b59d75bd32bdeb3.tar.gz
Merge 10.1 into 10.2
Diffstat (limited to 'sql')
-rw-r--r--sql/field.h46
-rw-r--r--sql/handler.cc31
-rw-r--r--sql/mysqld.cc14
-rw-r--r--sql/sql_class.h11
-rw-r--r--sql/sys_vars.cc93
-rw-r--r--sql/wsrep_mysqld.h5
-rw-r--r--sql/wsrep_sst.cc50
-rw-r--r--sql/wsrep_thd.cc22
8 files changed, 55 insertions, 217 deletions
diff --git a/sql/field.h b/sql/field.h
index ae6adec07e8..22c276478b6 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1448,17 +1448,6 @@ public:
/* Hash value */
virtual void hash(ulong *nr, ulong *nr2);
- /**
- Get the upper limit of the MySQL integral and floating-point type.
-
- @return maximum allowed value for the field
- */
- virtual ulonglong get_max_int_value() const
- {
- DBUG_ASSERT(false);
- return 0ULL;
- }
-
/**
Checks whether a string field is part of write_set.
@@ -2017,11 +2006,6 @@ public:
*to= *from;
return from + 1;
}
-
- virtual ulonglong get_max_int_value() const
- {
- return unsigned_flag ? 0xFFULL : 0x7FULL;
- }
};
@@ -2063,10 +2047,6 @@ public:
virtual const uchar *unpack(uchar* to, const uchar *from,
const uchar *from_end, uint param_data)
{ return unpack_int16(to, from, from_end); }
- virtual ulonglong get_max_int_value() const
- {
- return unsigned_flag ? 0xFFFFULL : 0x7FFFULL;
- }
};
class Field_medium :public Field_integer {
@@ -2100,10 +2080,6 @@ public:
{
return Field::pack(to, from, max_length);
}
- virtual ulonglong get_max_int_value() const
- {
- return unsigned_flag ? 0xFFFFFFULL : 0x7FFFFFULL;
- }
};
@@ -2149,10 +2125,6 @@ public:
{
return unpack_int32(to, from, from_end);
}
- virtual ulonglong get_max_int_value() const
- {
- return unsigned_flag ? 0xFFFFFFFFULL : 0x7FFFFFFFULL;
- }
};
@@ -2202,10 +2174,6 @@ public:
{
return unpack_int64(to, from, from_end);
}
- virtual ulonglong get_max_int_value() const
- {
- return unsigned_flag ? 0xFFFFFFFFFFFFFFFFULL : 0x7FFFFFFFFFFFFFFFULL;
- }
};
@@ -2245,13 +2213,6 @@ public:
uint32 pack_length() const { return sizeof(float); }
uint row_pack_length() const { return pack_length(); }
void sql_type(String &str) const;
- virtual ulonglong get_max_int_value() const
- {
- /*
- We use the maximum as per IEEE754-2008 standard, 2^24
- */
- return 0x1000000ULL;
- }
private:
int do_save_field_metadata(uchar *first_byte);
};
@@ -2304,13 +2265,6 @@ public:
uint32 pack_length() const { return sizeof(double); }
uint row_pack_length() const { return pack_length(); }
void sql_type(String &str) const;
- virtual ulonglong get_max_int_value() const
- {
- /*
- We use the maximum as per IEEE754-2008 standard, 2^53
- */
- return 0x20000000000000ULL;
- }
private:
int do_save_field_metadata(uchar *first_byte);
};
diff --git a/sql/handler.cc b/sql/handler.cc
index 2fadef3044f..36babb96415 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -2853,15 +2853,9 @@ compute_next_insert_id(ulonglong nr,struct system_variables *variables)
nr= nr + 1; // optimization of the formula below
else
{
- /*
- Calculating the number of complete auto_increment_increment extents:
- */
nr= (((nr+ variables->auto_increment_increment -
variables->auto_increment_offset)) /
(ulonglong) variables->auto_increment_increment);
- /*
- Adding an offset to the auto_increment_increment extent boundary:
- */
nr= (nr* (ulonglong) variables->auto_increment_increment +
variables->auto_increment_offset);
}
@@ -2917,14 +2911,8 @@ prev_insert_id(ulonglong nr, struct system_variables *variables)
}
if (variables->auto_increment_increment == 1)
return nr; // optimization of the formula below
- /*
- Calculating the number of complete auto_increment_increment extents:
- */
nr= (((nr - variables->auto_increment_offset)) /
(ulonglong) variables->auto_increment_increment);
- /*
- Adding an offset to the auto_increment_increment extent boundary:
- */
return (nr * (ulonglong) variables->auto_increment_increment +
variables->auto_increment_offset);
}
@@ -3147,23 +3135,10 @@ int handler::update_auto_increment()
if (unlikely(tmp)) // Out of range value in store
{
/*
- first test if the query was aborted due to strict mode constraints
- */
- if (thd->killed == KILL_BAD_DATA ||
- nr > table->next_number_field->get_max_int_value())
- DBUG_RETURN(HA_ERR_AUTOINC_ERANGE);
-
- /*
- field refused this value (overflow) and truncated it, use the result of
- the truncation (which is going to be inserted); however we try to
- decrease it to honour auto_increment_* variables.
- That will shift the left bound of the reserved interval, we don't
- bother shifting the right bound (anyway any other value from this
- interval will cause a duplicate key).
+ It's better to return an error here than getting a confusing
+ 'duplicate key error' later.
*/
- nr= prev_insert_id(table->next_number_field->val_int(), variables);
- if (unlikely(table->next_number_field->store((longlong) nr, TRUE)))
- nr= table->next_number_field->val_int();
+ result= HA_ERR_AUTOINC_ERANGE;
}
if (append)
{
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 1c45d07beed..dee7ac56833 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4319,20 +4319,6 @@ static int init_common_variables()
DBUG_PRINT("info",("%s Ver %s for %s on %s\n",my_progname,
server_version, SYSTEM_TYPE,MACHINE_TYPE));
-#ifdef WITH_WSREP
- /*
- We need to initialize auxiliary variables, that will be
- further keep the original values of auto-increment options
- as they set by the user. These variables used to restore
- user-defined values of the auto-increment options after
- setting of the wsrep_auto_increment_control to 'OFF'.
- */
- global_system_variables.saved_auto_increment_increment=
- global_system_variables.auto_increment_increment;
- global_system_variables.saved_auto_increment_offset=
- global_system_variables.auto_increment_offset;
-#endif /* WITH_WSREP */
-
#ifdef HAVE_LINUX_LARGE_PAGES
/* Initialize large page size */
if (opt_large_pages)
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 9a10083a998..4888b38bc30 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -569,17 +569,6 @@ typedef struct system_variables
ha_rows max_join_size;
ha_rows expensive_subquery_limit;
ulong auto_increment_increment, auto_increment_offset;
-#ifdef WITH_WSREP
- /*
- Variables with stored values of the auto_increment_increment
- and auto_increment_offset options that are will be needed when
- wsrep_auto_increment_control will be set to 'OFF', because the
- setting it to 'ON' leads to overwriting of the original values
- (which are set by the user) by calculated values (which are
- based on the cluster's size):
- */
- ulong saved_auto_increment_increment, saved_auto_increment_offset;
-#endif /* WITH_WSREP */
uint eq_range_index_dive_limit;
ulong lock_wait_timeout;
ulong join_cache_level;
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 5541efbcead..391772d1191 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -347,56 +347,13 @@ static Sys_var_long Sys_pfs_connect_attrs_size(
#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
-#ifdef WITH_WSREP
-
-/*
- We need to keep the original values set by the user, as they will
- be lost if wsrep_auto_increment_control set to 'ON':
-*/
-static bool update_auto_increment_increment (sys_var *self, THD *thd, enum_var_type type)
-{
- if (type == OPT_GLOBAL)
- global_system_variables.saved_auto_increment_increment=
- global_system_variables.auto_increment_increment;
- else
- thd->variables.saved_auto_increment_increment=
- thd->variables.auto_increment_increment;
- return false;
-}
-
-#endif /* WITH_WSREP */
-
static Sys_var_ulong Sys_auto_increment_increment(
"auto_increment_increment",
"Auto-increment columns are incremented by this",
SESSION_VAR(auto_increment_increment),
CMD_LINE(OPT_ARG),
VALID_RANGE(1, 65535), DEFAULT(1), BLOCK_SIZE(1),
-#ifdef WITH_WSREP
- NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0),
- ON_UPDATE(update_auto_increment_increment));
-#else
NO_MUTEX_GUARD, IN_BINLOG);
-#endif /* WITH_WSREP */
-
-#ifdef WITH_WSREP
-
-/*
- We need to keep the original values set by the user, as they will
- be lost if wsrep_auto_increment_control set to 'ON':
-*/
-static bool update_auto_increment_offset (sys_var *self, THD *thd, enum_var_type type)
-{
- if (type == OPT_GLOBAL)
- global_system_variables.saved_auto_increment_offset=
- global_system_variables.auto_increment_offset;
- else
- thd->variables.saved_auto_increment_offset=
- thd->variables.auto_increment_offset;
- return false;
-}
-
-#endif /* WITH_WSREP */
static Sys_var_ulong Sys_auto_increment_offset(
"auto_increment_offset",
@@ -405,12 +362,7 @@ static Sys_var_ulong Sys_auto_increment_offset(
SESSION_VAR(auto_increment_offset),
CMD_LINE(OPT_ARG),
VALID_RANGE(1, 65535), DEFAULT(1), BLOCK_SIZE(1),
-#ifdef WITH_WSREP
- NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(0),
- ON_UPDATE(update_auto_increment_offset));
-#else
NO_MUTEX_GUARD, IN_BINLOG);
-#endif /* WITH_WSREP */
static Sys_var_mybool Sys_automatic_sp_privileges(
"automatic_sp_privileges",
@@ -5024,54 +4976,11 @@ static Sys_var_ulong Sys_wsrep_retry_autocommit(
SESSION_VAR(wsrep_retry_autocommit), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, 10000), DEFAULT(1), BLOCK_SIZE(1));
-static bool update_wsrep_auto_increment_control (sys_var *self, THD *thd, enum_var_type type)
-{
- if (wsrep_auto_increment_control)
- {
- /*
- The variables that control auto increment shall be calculated
- automaticaly based on the size of the cluster. This usually done
- within the wsrep_view_handler_cb callback. However, if the user
- manually sets the value of wsrep_auto_increment_control to 'ON',
- then we should to re-calculate these variables again (because
- these values may be required before wsrep_view_handler_cb will
- be re-invoked, which is rarely invoked if the cluster stays in
- the stable state):
- */
- global_system_variables.auto_increment_increment=
- wsrep_cluster_size ? wsrep_cluster_size : 1;
- global_system_variables.auto_increment_offset=
- wsrep_local_index >= 0 ? wsrep_local_index + 1 : 1;
- thd->variables.auto_increment_increment=
- global_system_variables.auto_increment_increment;
- thd->variables.auto_increment_offset=
- global_system_variables.auto_increment_offset;
- }
- else
- {
- /*
- We must restore the last values of the variables that
- are explicitly specified by the user:
- */
- global_system_variables.auto_increment_increment=
- global_system_variables.saved_auto_increment_increment;
- global_system_variables.auto_increment_offset=
- global_system_variables.saved_auto_increment_offset;
- thd->variables.auto_increment_increment=
- thd->variables.saved_auto_increment_increment;
- thd->variables.auto_increment_offset=
- thd->variables.saved_auto_increment_offset;
- }
- return false;
-}
-
static Sys_var_mybool Sys_wsrep_auto_increment_control(
"wsrep_auto_increment_control", "To automatically control the "
"assignment of autoincrement variables",
GLOBAL_VAR(wsrep_auto_increment_control),
- CMD_LINE(OPT_ARG), DEFAULT(TRUE),
- NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
- ON_UPDATE(update_wsrep_auto_increment_control));
+ CMD_LINE(OPT_ARG), DEFAULT(TRUE));
static Sys_var_mybool Sys_wsrep_drupal_282555_workaround(
"wsrep_drupal_282555_workaround", "Enable a workaround to handle the "
diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h
index b8143e92ccb..c2169b56077 100644
--- a/sql/wsrep_mysqld.h
+++ b/sql/wsrep_mysqld.h
@@ -159,10 +159,7 @@ extern "C" time_t wsrep_thd_query_start(THD *thd);
extern "C" query_id_t wsrep_thd_query_id(THD *thd);
extern "C" query_id_t wsrep_thd_wsrep_last_query_id(THD *thd);
extern "C" void wsrep_thd_set_wsrep_last_query_id(THD *thd, query_id_t id);
-
-extern "C" void wsrep_thd_auto_increment_variables(THD*,
- unsigned long long *offset,
- unsigned long long *increment);
+extern "C" void wsrep_set_data_home_dir(const char *data_dir);
extern void wsrep_close_client_connections(my_bool wait_to_end);
extern int wsrep_wait_committing_connections_close(int wait_time);
diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc
index f4fe6af8d9f..908c0c56685 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -59,6 +59,13 @@ bool wsrep_sst_method_update (sys_var *self, THD* thd, enum_var_type type)
return 0;
}
+static const char* data_home_dir = NULL;
+
+extern "C"
+void wsrep_set_data_home_dir(const char *data_dir)
+{
+ data_home_dir= (data_dir && *data_dir) ? data_dir : NULL;
+}
static void make_wsrep_defaults_file()
{
@@ -596,6 +603,29 @@ static int sst_append_auth_env(wsp::env& env, const char* sst_auth)
return -env.error();
}
+#define DATA_HOME_DIR_ENV "INNODB_DATA_HOME_DIR"
+
+static int sst_append_data_dir(wsp::env& env, const char* data_dir)
+{
+ int const data_dir_size= strlen(DATA_HOME_DIR_ENV) + 1 /* = */
+ + (data_dir ? strlen(data_dir) : 0) + 1 /* \0 */;
+
+ wsp::string data_dir_str(data_dir_size); // for automatic cleanup on return
+ if (!data_dir_str()) return -ENOMEM;
+
+ int ret= snprintf(data_dir_str(), data_dir_size, "%s=%s",
+ DATA_HOME_DIR_ENV, data_dir ? data_dir : "");
+
+ if (ret < 0 || ret >= data_dir_size)
+ {
+ WSREP_ERROR("sst_append_data_dir(): snprintf() failed: %d", ret);
+ return (ret < 0 ? ret : -EMSGSIZE);
+ }
+
+ env.append(data_dir_str());
+ return -env.error();
+}
+
static ssize_t sst_prepare_other (const char* method,
const char* sst_auth,
const char* addr_in,
@@ -657,6 +687,16 @@ static ssize_t sst_prepare_other (const char* method,
return ret;
}
+ if (data_home_dir)
+ {
+ if ((ret= sst_append_data_dir(env, data_home_dir)))
+ {
+ WSREP_ERROR("sst_prepare_other(): appending data "
+ "directory failed: %d", ret);
+ return ret;
+ }
+ }
+
pthread_t tmp;
sst_thread_arg arg(cmd_str(), env());
mysql_mutex_lock (&arg.lock);
@@ -1348,6 +1388,16 @@ wsrep_cb_status_t wsrep_sst_donate_cb (void* app_ctx, void* recv_ctx,
return WSREP_CB_FAILURE;
}
+ if (data_home_dir)
+ {
+ if ((ret= sst_append_data_dir(env, data_home_dir)))
+ {
+ WSREP_ERROR("wsrep_sst_donate_cb(): appending data "
+ "directory failed: %d", ret);
+ return WSREP_CB_FAILURE;
+ }
+ }
+
if (!strcmp (WSREP_SST_MYSQLDUMP, method))
{
ret = sst_donate_mysqldump(data, &current_gtid->uuid, uuid_str,
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index 1621559bb8a..15eed2e10e6 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -677,25 +677,3 @@ bool wsrep_thd_has_explicit_locks(THD *thd)
assert(thd);
return thd->mdl_context.has_explicit_locks();
}
-
-/*
- Get auto increment variables for THD. Use global settings for
- applier threads.
- */
-extern "C"
-void wsrep_thd_auto_increment_variables(THD* thd,
- unsigned long long* offset,
- unsigned long long* increment)
-{
- if (thd->wsrep_exec_mode == REPL_RECV &&
- thd->wsrep_conflict_state != REPLAYING)
- {
- *offset= global_system_variables.auto_increment_offset;
- *increment= global_system_variables.auto_increment_increment;
- }
- else
- {
- *offset= thd->variables.auto_increment_offset;
- *increment= thd->variables.auto_increment_increment;
- }
-}