summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/mdl.cc2
-rw-r--r--sql/my_json_writer.h67
-rw-r--r--sql/opt_range.cc2
-rw-r--r--sql/sql_select.cc2
-rw-r--r--sql/sys_vars.cc4
5 files changed, 44 insertions, 33 deletions
diff --git a/sql/mdl.cc b/sql/mdl.cc
index 7f170a56d7a..c2475bb3b91 100644
--- a/sql/mdl.cc
+++ b/sql/mdl.cc
@@ -784,7 +784,7 @@ int mdl_iterate(mdl_iterator_callback callback, void *arg)
my_hash_value_type mdl_hash_function(CHARSET_INFO *cs,
const uchar *key, size_t length)
{
- MDL_key *mdl_key= (MDL_key*) (key - my_offsetof(MDL_key, m_ptr));
+ MDL_key *mdl_key= (MDL_key*) (key - offsetof(MDL_key, m_ptr));
return mdl_key->hash_value();
}
diff --git a/sql/my_json_writer.h b/sql/my_json_writer.h
index e2d60df4bf5..089abd0ad48 100644
--- a/sql/my_json_writer.h
+++ b/sql/my_json_writer.h
@@ -19,6 +19,9 @@
#include "my_base.h"
#if !defined(NDEBUG) || defined(JSON_WRITER_UNIT_TEST) || defined ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
+#include <set>
+#include <stack>
+#include <string>
#include <vector>
#endif
@@ -32,6 +35,8 @@ constexpr uint FAKE_SELECT_LEX_ID= UINT_MAX;
#define VALIDITY_ASSERT(x) DBUG_ASSERT(x)
#endif
+#include <type_traits>
+
class Opt_trace_stmt;
class Opt_trace_context;
class Json_writer;
@@ -372,16 +377,21 @@ protected:
*/
bool closed;
-public:
- explicit Json_writer_struct(THD *thd, bool expect_named_children)
+ explicit Json_writer_struct(Json_writer *writer)
+ : my_writer(writer)
{
- my_writer= thd->opt_trace.get_current_json();
context.init(my_writer);
closed= false;
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
named_items_expectation.push_back(expect_named_children);
#endif
}
+ explicit Json_writer_struct(THD *thd)
+ : Json_writer_struct(thd->opt_trace.get_current_json())
+ {
+ }
+
+public:
virtual ~Json_writer_struct()
{
@@ -421,8 +431,8 @@ private:
my_writer->add_member(name);
}
public:
- explicit Json_writer_object(THD* thd, const char *str= nullptr)
- : Json_writer_struct(thd, true)
+ explicit Json_writer_object(Json_writer* writer, const char *str= nullptr)
+ : Json_writer_struct(writer)
{
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
DBUG_ASSERT(named_item_expected());
@@ -435,6 +445,11 @@ public:
}
}
+ explicit Json_writer_object(THD* thd, const char *str= nullptr)
+ : Json_writer_object(thd->opt_trace.get_current_json(), str)
+ {
+ }
+
~Json_writer_object()
{
if (my_writer && !closed)
@@ -452,17 +467,22 @@ public:
}
return *this;
}
+
Json_writer_object& add(const char *name, ulonglong value)
{
DBUG_ASSERT(!closed);
if (my_writer)
{
add_member(name);
- context.add_ll(static_cast<longlong>(value));
+ my_writer->add_ull(value);
}
return *this;
}
- Json_writer_object& add(const char *name, longlong value)
+
+ template<class IntT,
+ typename= typename ::std::enable_if<std::is_integral<IntT>::value>::type
+ >
+ Json_writer_object& add(const char *name, IntT value)
{
DBUG_ASSERT(!closed);
if (my_writer)
@@ -472,6 +492,7 @@ public:
}
return *this;
}
+
Json_writer_object& add(const char *name, double value)
{
DBUG_ASSERT(!closed);
@@ -482,18 +503,7 @@ public:
}
return *this;
}
- #ifndef _WIN64
- Json_writer_object& add(const char *name, size_t value)
- {
- DBUG_ASSERT(!closed);
- if (my_writer)
- {
- add_member(name);
- context.add_ll(static_cast<longlong>(value));
- }
- return *this;
- }
- #endif
+
Json_writer_object& add(const char *name, const char *value)
{
DBUG_ASSERT(!closed);
@@ -594,25 +604,25 @@ public:
class Json_writer_array : public Json_writer_struct
{
public:
- Json_writer_array(THD *thd)
- : Json_writer_struct(thd, false)
+ explicit Json_writer_array(Json_writer *writer, const char *str= nullptr)
+ : Json_writer_struct(writer)
{
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
DBUG_ASSERT(!named_item_expected());
#endif
if (unlikely(my_writer))
+ {
+ if (str)
+ my_writer->add_member(str);
my_writer->start_array();
+ }
}
- Json_writer_array(THD *thd, const char *str)
- : Json_writer_struct(thd, false)
+ explicit Json_writer_array(THD *thd, const char *str= nullptr)
+ : Json_writer_array(thd->opt_trace.get_current_json(), str)
{
-#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
- DBUG_ASSERT(named_item_expected());
-#endif
- if (unlikely(my_writer))
- my_writer->add_member(str).start_array();
}
+
~Json_writer_array()
{
if (unlikely(my_writer && !closed))
@@ -621,6 +631,7 @@ public:
closed= TRUE;
}
}
+
void end()
{
DBUG_ASSERT(!closed);
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 9dc1bcf733f..06063cb9ae1 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -6937,7 +6937,7 @@ static bool ror_intersect_add(ROR_INTERSECT_INFO *info,
DBUG_PRINT("info", ("info->total_cost= %g", info->total_cost));
}
else
- trace_costs->add("disk_sweep_cost", static_cast<longlong>(0));
+ trace_costs->add("disk_sweep_cost", 0);
DBUG_PRINT("info", ("New out_rows: %g", info->out_rows));
DBUG_PRINT("info", ("New cost: %g, %scovering", info->total_cost,
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index a357d4f8c8a..0dfe95e81b0 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -505,7 +505,7 @@ static void trace_table_dependencies(THD *thd,
{
if (map & (1ULL << j))
{
- trace_one_table.add("map_bit", static_cast<longlong>(j));
+ trace_one_table.add("map_bit", j);
break;
}
}
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index e18ca6392d8..7127cbc00f6 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -5718,14 +5718,14 @@ static bool update_locale(sys_var *self, THD* thd, enum_var_type type)
static Sys_var_struct Sys_lc_messages(
"lc_messages", "Set the language used for the error messages",
SESSION_VAR(lc_messages), NO_CMD_LINE,
- my_offsetof(MY_LOCALE, name), DEFAULT(&my_default_lc_messages),
+ offsetof(MY_LOCALE, name), DEFAULT(&my_default_lc_messages),
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_locale), ON_UPDATE(update_locale));
static Sys_var_struct Sys_lc_time_names(
"lc_time_names", "Set the language used for the month "
"names and the days of the week",
SESSION_VAR(lc_time_names), NO_CMD_LINE,
- my_offsetof(MY_LOCALE, name), DEFAULT(&my_default_lc_time_names),
+ offsetof(MY_LOCALE, name), DEFAULT(&my_default_lc_time_names),
NO_MUTEX_GUARD, IN_BINLOG, ON_CHECK(check_locale));
static Sys_var_tz Sys_time_zone(