summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2018-09-06 22:35:45 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2018-09-06 22:35:45 +0300
commit2f4c391958b70ab4be622eb7010d7029363e9529 (patch)
tree1aada0415af36291bce1e47ec0a092c9f27b5a37 /sql
parent3bfafd133f9cb9de143ac051de9ed72a67bbc2d9 (diff)
parenta0631e72210931182e950734b73c7a090c637261 (diff)
downloadmariadb-git-2f4c391958b70ab4be622eb7010d7029363e9529.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'sql')
-rw-r--r--sql/field.h47
-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, 218 deletions
diff --git a/sql/field.h b/sql/field.h
index 0046bc11be2..2037802df9a 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1494,17 +1494,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.
@@ -2126,11 +2115,6 @@ public:
*to= *from;
return from + 1;
}
-
- virtual ulonglong get_max_int_value() const
- {
- return unsigned_flag ? 0xFFULL : 0x7FULL;
- }
};
@@ -2175,10 +2159,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_int
@@ -2214,10 +2194,6 @@ public:
{
return Field::pack(to, from, max_length);
}
- virtual ulonglong get_max_int_value() const
- {
- return unsigned_flag ? 0xFFFFFFULL : 0x7FFFFFULL;
- }
};
@@ -2267,10 +2243,6 @@ public:
{
return unpack_int32(to, from, from_end);
}
- virtual ulonglong get_max_int_value() const
- {
- return unsigned_flag ? 0xFFFFFFFFULL : 0x7FFFFFFFULL;
- }
};
@@ -2323,11 +2295,6 @@ public:
{
return unpack_int64(to, from, from_end);
}
- virtual ulonglong get_max_int_value() const
- {
- return unsigned_flag ? 0xFFFFFFFFFFFFFFFFULL : 0x7FFFFFFFFFFFFFFFULL;
- }
-
void set_max();
bool is_max();
};
@@ -2412,13 +2379,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 save_field_metadata(uchar *first_byte);
};
@@ -2472,13 +2432,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 save_field_metadata(uchar *first_byte);
};
diff --git a/sql/handler.cc b/sql/handler.cc
index ad9adc34a7e..306b0868d15 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -3047,15 +3047,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);
}
@@ -3111,14 +3105,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);
}
@@ -3360,23 +3348,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 d2084a8d073..f2b00831d6f 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4389,20 +4389,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 e2aed01ef3b..00a5c41f708 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -581,17 +581,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 column_compression_zlib_strategy;
ulong lock_wait_timeout;
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 4cf62d457df..6d4c135683a 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -349,56 +349,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",
@@ -407,12 +364,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",
@@ -5383,54 +5335,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 d7b490d879e..6aa8a68f222 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 8816a31330e..0a1d95f30b8 100644
--- a/sql/wsrep_sst.cc
+++ b/sql/wsrep_sst.cc
@@ -58,6 +58,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()
{
@@ -595,6 +602,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,
@@ -656,6 +686,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);
@@ -1347,6 +1387,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 a83ea4ce1c6..ce6d9688cb3 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -676,25 +676,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;
- }
-}