summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2021-12-07 09:57:51 +0100
committerSergei Golubchik <serg@mariadb.org>2021-12-07 09:57:51 +0100
commit1e8bcbd0a0bfa07052e9458830672ea215c8664a (patch)
treee1208ed8e936938839c74ad235c79f7c9eaf4c50
parent23bfacf1cceb213111556ddb43c55e7c2eeb98e7 (diff)
downloadmariadb-git-1e8bcbd0a0bfa07052e9458830672ea215c8664a.tar.gz
Revert "MDEV-27036: re-enable my_json_writer-t unit test"
This reverts commit 2d21917e7db2db0900671aac2e29f49e4ff2acd7. No explainations, lots of code moved, wrong cmake changes
-rw-r--r--CMakeLists.txt3
-rw-r--r--cmake/ctest.cmake1
-rw-r--r--include/my_dir.h3
-rw-r--r--sql/CMakeLists.txt4
-rw-r--r--sql/my_json_writer.cc22
-rw-r--r--sql/my_json_writer.h20
-rw-r--r--sql/opt_range.cc55
-rw-r--r--sql/opt_range.h61
-rw-r--r--sql/set_var.cc5
-rw-r--r--sql/set_var.h3
-rw-r--r--sql/sql_explain.h2
-rw-r--r--sql/sql_select.cc63
-rw-r--r--sql/sql_select.h77
-rw-r--r--sql/sys_vars.cc6
-rw-r--r--sql/sys_vars.ic6
-rw-r--r--unittest/sql/CMakeLists.txt7
-rw-r--r--unittest/sql/my_json_writer-t.cc13
17 files changed, 152 insertions, 199 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 22f3f1101a4..5c045360631 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -142,7 +142,6 @@ IF (NOT CPACK_GENERATOR)
ENDIF(WIN32)
ENDIF(NOT CPACK_GENERATOR)
-INCLUDE(build_depends)
INCLUDE(FeatureSummary)
INCLUDE(misc)
INCLUDE(mysql_version)
@@ -539,6 +538,8 @@ IF(UNIX)
INSTALL_DOCUMENTATION(Docs/INSTALL-BINARY Docs/README-wsrep COMPONENT Readme)
ENDIF()
+INCLUDE(build_depends)
+
INCLUDE(CPack)
IF(WIN32 AND SIGNCODE)
diff --git a/cmake/ctest.cmake b/cmake/ctest.cmake
index db0defa1869..5bc1ce5f832 100644
--- a/cmake/ctest.cmake
+++ b/cmake/ctest.cmake
@@ -22,4 +22,3 @@ MACRO(MY_ADD_TESTS)
ENDFOREACH()
ENDMACRO()
-FIND_PACKAGE(Boost COMPONENTS unit_test_framework)
diff --git a/include/my_dir.h b/include/my_dir.h
index 2f152844e7e..12cf5db149d 100644
--- a/include/my_dir.h
+++ b/include/my_dir.h
@@ -17,9 +17,6 @@
#define MY_DIR_H
#include <sys/stat.h>
-#include <stddef.h>
-
-#include "my_global.h"
#ifdef __cplusplus
extern "C" {
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 5662d89d0d7..972cc0b736c 100644
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -206,7 +206,7 @@ RECOMPILE_FOR_EMBEDDED)
ADD_LIBRARY(sql STATIC ${SQL_SOURCE})
MAYBE_DISABLE_IPO(sql)
DTRACE_INSTRUMENT(sql)
-TARGET_LINK_LIBRARIES(sql PUBLIC
+TARGET_LINK_LIBRARIES(sql
mysys mysys_ssl dbug strings vio pcre2-8
tpool
${LIBWRAP} ${LIBCRYPT} ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT}
@@ -220,7 +220,7 @@ ENDIF()
FOREACH(se aria partition perfschema sql_sequence wsrep)
# These engines are used directly in sql sources.
IF(TARGET ${se})
- TARGET_LINK_LIBRARIES(sql PUBLIC ${se})
+ TARGET_LINK_LIBRARIES(sql ${se})
ENDIF()
ENDFOREACH()
diff --git a/sql/my_json_writer.cc b/sql/my_json_writer.cc
index 8bc582c50a8..8284c9bbfca 100644
--- a/sql/my_json_writer.cc
+++ b/sql/my_json_writer.cc
@@ -13,14 +13,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
-#include "my_json_writer.h"
-
-#include "sql_class.h"
#include "mariadb.h"
#include "sql_priv.h"
#include "sql_string.h"
-#include "log.h"
-
+#include "my_json_writer.h"
#if !defined(NDEBUG) || defined(JSON_WRITER_UNIT_TEST)
#include <iostream>
@@ -332,7 +328,6 @@ Json_writer_temp_disable::Json_writer_temp_disable(THD *thd_arg)
thd= thd_arg;
thd->opt_trace.disable_tracing_if_required();
}
-
Json_writer_temp_disable::~Json_writer_temp_disable()
{
thd->opt_trace.enable_tracing_if_required();
@@ -502,18 +497,3 @@ void Single_line_formatting_helper::disable_and_flush()
state= INACTIVE;
}
-
-Json_writer_struct::Json_writer_struct(THD *thd)
- : Json_writer_struct(thd->opt_trace.get_current_json())
-{
-}
-
-Json_writer_object::Json_writer_object(THD *thd, const char *str)
- : Json_writer_object(thd->opt_trace.get_current_json(), str)
-{
-}
-
-Json_writer_array::Json_writer_array(THD *thd, const char *str)
- : Json_writer_array(thd->opt_trace.get_current_json(), str)
-{
-}
diff --git a/sql/my_json_writer.h b/sql/my_json_writer.h
index 201e3136c08..a4e8c825582 100644
--- a/sql/my_json_writer.h
+++ b/sql/my_json_writer.h
@@ -17,6 +17,7 @@
#define JSON_WRITER_INCLUDED
#include "my_base.h"
+#include "sql_select.h"
#if !defined(NDEBUG) || defined(JSON_WRITER_UNIT_TEST) || defined ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
#include <set>
@@ -31,7 +32,6 @@ constexpr uint FAKE_SELECT_LEX_ID= UINT_MAX;
// Also, mock objects are defined in my_json_writer-t.cc
#define VALIDITY_ASSERT(x) if (!(x)) this->invalid_json= true;
#else
-#include "sql_select.h"
#define VALIDITY_ASSERT(x) DBUG_ASSERT(x)
#endif
@@ -40,11 +40,8 @@ constexpr uint FAKE_SELECT_LEX_ID= UINT_MAX;
class Opt_trace_stmt;
class Opt_trace_context;
class Json_writer;
-struct TABLE;
struct TABLE_LIST;
-struct st_join_table;
-using JOIN_TAB= struct st_join_table;
/*
Single_line_formatting_helper is used by Json_writer to do better formatting
@@ -390,7 +387,10 @@ protected:
named_items_expectation.push_back(expect_named_children);
#endif
}
- explicit Json_writer_struct(THD *thd);
+ explicit Json_writer_struct(THD *thd)
+ : Json_writer_struct(thd->opt_trace.get_current_json())
+ {
+ }
public:
@@ -446,7 +446,10 @@ public:
}
}
- explicit Json_writer_object(THD* thd, const char *str= nullptr);
+ explicit Json_writer_object(THD* thd, const char *str= nullptr)
+ : Json_writer_object(thd->opt_trace.get_current_json(), str)
+ {
+ }
~Json_writer_object()
{
@@ -616,7 +619,10 @@ public:
}
}
- explicit Json_writer_array(THD *thd, const char *str= nullptr);
+ explicit Json_writer_array(THD *thd, const char *str= nullptr)
+ : Json_writer_array(thd->opt_trace.get_current_json(), str)
+ {
+ }
~Json_writer_array()
{
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 2ef30924aa5..06063cb9ae1 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1254,14 +1254,6 @@ void SQL_SELECT::cleanup()
close_cached_file(&file);
}
-int SQL_SELECT::skip_record(THD *thd)
-{
- int rc= MY_TEST(!cond || cond->val_int());
- if (thd->is_error())
- rc= -1;
- return rc;
-}
-
SQL_SELECT::~SQL_SELECT()
{
@@ -1880,20 +1872,6 @@ QUICK_RANGE::QUICK_RANGE()
min_keypart_map(0), max_keypart_map(0)
{}
-QUICK_RANGE::QUICK_RANGE(THD *thd, const uchar *min_key_arg, uint min_length_arg, key_part_map min_keypart_map_arg, const uchar *max_key_arg, uint max_length_arg, key_part_map max_keypart_map_arg, uint flag_arg)
-: min_key((uchar*) thd->memdup(min_key_arg, min_length_arg + 1)),
- max_key((uchar*) thd->memdup(max_key_arg, max_length_arg + 1)),
- min_length((uint16) min_length_arg),
- max_length((uint16) max_length_arg),
- flag((uint16) flag_arg),
- min_keypart_map(min_keypart_map_arg),
- max_keypart_map(max_keypart_map_arg)
-{
-#ifdef HAVE_valgrind
- dummy=0;
-#endif
-}
-
SEL_ARG::SEL_ARG(SEL_ARG &arg) :Sql_alloc()
{
type=arg.type;
@@ -10870,31 +10848,6 @@ uint SEL_ARG::get_max_key_part() const
return max_part;
}
-SEL_ARG *SEL_ARG::clone_and(THD *thd, SEL_ARG *arg)
-{ // Get overlapping range
- uchar *new_min,*new_max;
- uint8 flag_min,flag_max;
- if (cmp_min_to_min(arg) >= 0)
- {
- new_min=min_value; flag_min=min_flag;
- }
- else
- {
- new_min=arg->min_value; flag_min=arg->min_flag; /* purecov: deadcode */
- }
- if (cmp_max_to_max(arg) <= 0)
- {
- new_max=max_value; flag_max=max_flag;
- }
- else
- {
- new_max=arg->max_value; flag_max=arg->max_flag;
- }
- return new (thd->mem_root) SEL_ARG(field, part, new_min, new_max, flag_min,
- flag_max,
- MY_TEST(maybe_flag && arg->maybe_flag));
-}
-
/*
Remove the SEL_ARG graph elements which have part > max_part.
@@ -16615,11 +16568,3 @@ void print_keyparts_name(String *out, const KEY_PART_INFO *key_part,
}
out->append(STRING_WITH_LEN(")"));
}
-
-bool RANGE_OPT_PARAM::statement_should_be_aborted() const
-{
- return thd->killed
- || thd->is_fatal_error
- || thd->is_error()
- || alloced_sel_args > SEL_ARG::MAX_SEL_ARGS;
-}
diff --git a/sql/opt_range.h b/sql/opt_range.h
index 65e2d6db9ae..1014176ecc5 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -36,9 +36,8 @@
#include "sql_class.h" // set_var.h: THD
#include "set_var.h" /* Item */
-class Item_sum;
class JOIN;
-class Unique;
+class Item_sum;
struct KEY_PART {
uint16 key,part;
@@ -390,7 +389,30 @@ public:
{
return sel_cmp(field,max_value, arg->min_value, max_flag, arg->min_flag);
}
- SEL_ARG *clone_and(THD *thd, SEL_ARG* arg);
+ SEL_ARG *clone_and(THD *thd, SEL_ARG* arg)
+ { // Get overlapping range
+ uchar *new_min,*new_max;
+ uint8 flag_min,flag_max;
+ if (cmp_min_to_min(arg) >= 0)
+ {
+ new_min=min_value; flag_min=min_flag;
+ }
+ else
+ {
+ new_min=arg->min_value; flag_min=arg->min_flag; /* purecov: deadcode */
+ }
+ if (cmp_max_to_max(arg) <= 0)
+ {
+ new_max=max_value; flag_max=max_flag;
+ }
+ else
+ {
+ new_max=arg->max_value; flag_max=arg->max_flag;
+ }
+ return new (thd->mem_root) SEL_ARG(field, part, new_min, new_max, flag_min,
+ flag_max,
+ MY_TEST(maybe_flag && arg->maybe_flag));
+ }
SEL_ARG *clone_first(SEL_ARG *arg)
{ // min <= X < arg->min
return new SEL_ARG(field,part, min_value, arg->min_value,
@@ -711,7 +733,14 @@ public:
bool force_default_mrr;
KEY_PART *key[MAX_KEY]; /* First key parts of keys used in the query */
- bool statement_should_be_aborted() const;
+ bool statement_should_be_aborted() const
+ {
+ return
+ thd->killed ||
+ thd->is_fatal_error ||
+ thd->is_error() ||
+ alloced_sel_args > SEL_ARG::MAX_SEL_ARGS;
+ }
};
@@ -734,9 +763,21 @@ class QUICK_RANGE :public Sql_alloc {
QUICK_RANGE(); /* Full range */
QUICK_RANGE(THD *thd, const uchar *min_key_arg, uint min_length_arg,
key_part_map min_keypart_map_arg,
- const uchar *max_key_arg, uint max_length_arg,
+ const uchar *max_key_arg, uint max_length_arg,
key_part_map max_keypart_map_arg,
- uint flag_arg);
+ uint flag_arg)
+ : min_key((uchar*) thd->memdup(min_key_arg, min_length_arg + 1)),
+ max_key((uchar*) thd->memdup(max_key_arg, max_length_arg + 1)),
+ min_length((uint16) min_length_arg),
+ max_length((uint16) max_length_arg),
+ flag((uint16) flag_arg),
+ min_keypart_map(min_keypart_map_arg),
+ max_keypart_map(max_keypart_map_arg)
+ {
+#ifdef HAVE_valgrind
+ dummy=0;
+#endif
+ }
/**
Initalizes a key_range object for communication with storage engine.
@@ -1683,7 +1724,13 @@ class SQL_SELECT :public Sql_alloc {
-1 if error
1 otherwise
*/
- int skip_record(THD *thd);
+ inline int skip_record(THD *thd)
+ {
+ int rc= MY_TEST(!cond || cond->val_int());
+ if (thd->is_error())
+ rc= -1;
+ return rc;
+ }
int test_quick_select(THD *thd, key_map keys, table_map prev_tables,
ha_rows limit, bool force_quick_range,
bool ordered_output, bool remove_false_parts_of_where,
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 07e378e50d1..4b3e23b06c0 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -241,11 +241,6 @@ const uchar *sys_var::global_value_ptr(THD *thd, const LEX_CSTRING *base) const
return global_var_ptr();
}
-uchar *sys_var::session_var_ptr(THD *thd) const
-{
- return ((uchar*)&(thd->variables)) + offset;
-}
-
bool sys_var::check(THD *thd, set_var *var)
{
if (unlikely((var->value && do_check(thd, var)) ||
diff --git a/sql/set_var.h b/sql/set_var.h
index cc279af5355..2d538624825 100644
--- a/sql/set_var.h
+++ b/sql/set_var.h
@@ -247,7 +247,8 @@ protected:
Typically it's the same as session_value_ptr(), but it's different,
for example, for ENUM, that is printed as a string, but stored as a number.
*/
- uchar *session_var_ptr(THD *thd) const;
+ uchar *session_var_ptr(THD *thd) const
+ { return ((uchar*)&(thd->variables)) + offset; }
uchar *global_var_ptr() const
{ return ((uchar*)&global_system_variables) + offset; }
diff --git a/sql/sql_explain.h b/sql/sql_explain.h
index 709ddd3f745..bfd52290374 100644
--- a/sql/sql_explain.h
+++ b/sql/sql_explain.h
@@ -54,8 +54,6 @@ it into the slow query log.
#ifndef SQL_EXPLAIN_INCLUDED
#define SQL_EXPLAIN_INCLUDED
-class select_result_sink;
-
class String_list: public List<char>
{
public:
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index bbfc8e0bf9b..2830e65a49e 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -12569,13 +12569,6 @@ inline void JOIN::eval_select_list_used_tables()
}
}
-JOIN_TAB *JOIN::get_sort_by_join_tab()
-{
- return (need_tmp || !sort_by_table || skip_sort_order
- || ((group || tmp_table_param.sum_func_count) && !group_list))
- ? nullptr : join_tab+const_tables;
-}
-
/*
Determine {after which table we'll produce ordered set}
@@ -13998,17 +13991,6 @@ bool JOIN_TAB::pfs_batch_update(JOIN *join)
(!select_cond || !select_cond->with_subquery()); // 3
}
-int st_join_table::get_non_merged_semijoin_select() const
-{
- Item_in_subselect *subq;
- if (table->pos_in_table_list &&
- (subq= table->pos_in_table_list->jtbm_subselect))
- {
- return subq->unit->first_select()->select_number;
- }
- return 0; /* Not a merged semi-join */
-}
-
/**
Build a TABLE_REF structure for index lookup in the temporary table
@@ -30258,48 +30240,3 @@ static bool process_direct_rownum_comparison(THD *thd, SELECT_LEX_UNIT *unit,
/**
@} (end of group Query_Optimizer)
*/
-
-store_key::store_key_result store_key_item::copy_inner()
-{
- TABLE *table= to_field->table;
- MY_BITMAP *old_map= dbug_tmp_use_all_columns(table,
- &table->write_set);
- int res= FALSE;
-
- /*
- It looks like the next statement is needed only for a simplified
- hash function over key values used now in BNLH join.
- When the implementation of this function will be replaced for a proper
- full version this statement probably should be removed.
- */
- to_field->reset();
-
- if (use_value)
- item->save_val(to_field);
- else
- res= item->save_in_field(to_field, 1);
- /*
- Item::save_in_field() may call Item::val_xxx(). And if this is a subquery
- we need to check for errors executing it and react accordingly
- */
- if (!res && table->in_use->is_error())
- res= 1; /* STORE_KEY_FATAL */
- dbug_tmp_restore_column_map(&table->write_set, old_map);
- null_key= to_field->is_null() || item->null_value;
- return ((err != 0 || res < 0 || res > 2)
- ? STORE_KEY_FATAL : (store_key_result) res);
-}
-
-store_key::store_key_result store_key::copy(THD *thd)
-{
- enum store_key_result result;
- enum_check_fields org_count_cuted_fields= thd->count_cuted_fields;
- sql_mode_t org_sql_mode= thd->variables.sql_mode;
- thd->variables.sql_mode&= ~(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
- thd->variables.sql_mode|= MODE_INVALID_DATES;
- thd->count_cuted_fields= CHECK_FIELD_IGNORE;
- result= copy_inner();
- thd->count_cuted_fields= org_count_cuted_fields;
- thd->variables.sql_mode= org_sql_mode;
- return result;
-}
diff --git a/sql/sql_select.h b/sql/sql_select.h
index ce8ee69ae3c..d4e06f42249 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -30,17 +30,11 @@
#include "procedure.h"
#include "sql_array.h" /* Array */
-#include "sql_class.h"
-#include "sql_lex.h"
#include "records.h" /* READ_RECORD */
#include "opt_range.h" /* SQL_SELECT, QUICK_SELECT_I */
#include "filesort.h"
-class POSITION;
-#ifndef TMP_ENGINE_COLUMNDEF
-class TMP_ENGINE_COLUMNDEF;
-#endif
-
+typedef struct st_join_table JOIN_TAB;
/* Values in optimize */
#define KEY_OPTIMIZE_EXISTS 1U
#define KEY_OPTIMIZE_REF_OR_NULL 2U
@@ -205,8 +199,6 @@ enum join_type { JT_UNKNOWN,JT_SYSTEM,JT_CONST,JT_EQ_REF,JT_REF,JT_MAYBE_REF,
JT_HASH, JT_HASH_RANGE, JT_HASH_NEXT, JT_HASH_INDEX_MERGE};
class JOIN;
-struct st_join_table;
-using JOIN_TAB= struct st_join_table;
enum enum_nested_loop_state
{
@@ -258,7 +250,7 @@ class Filesort;
struct SplM_plan_info;
class SplM_opt_info;
-struct st_join_table {
+typedef struct st_join_table {
TABLE *table;
TABLE_LIST *tab_list;
KEYUSE *keyuse; /**< pointer to first used key */
@@ -657,7 +649,16 @@ struct st_join_table {
If this join_tab reads a non-merged semi-join (also called jtbm), return
the select's number. Otherwise, return 0.
*/
- int get_non_merged_semijoin_select() const;
+ int get_non_merged_semijoin_select() const
+ {
+ Item_in_subselect *subq;
+ if (table->pos_in_table_list &&
+ (subq= table->pos_in_table_list->jtbm_subselect))
+ {
+ return subq->unit->first_select()->select_number;
+ }
+ return 0; /* Not a merged semi-join */
+ }
bool access_from_tables_is_allowed(table_map used_tables,
table_map sjm_lookup_tables)
@@ -685,7 +686,7 @@ struct st_join_table {
table_map remaining_tables);
bool fix_splitting(SplM_plan_info *spl_plan, table_map remaining_tables,
bool is_const_table);
-};
+} JOIN_TAB;
#include "sql_join_cache.h"
@@ -1662,7 +1663,12 @@ public:
Return the table for which an index scan can be used to satisfy
the sort order needed by the ORDER BY/(implicit) GROUP BY clause
*/
- JOIN_TAB *get_sort_by_join_tab();
+ JOIN_TAB *get_sort_by_join_tab()
+ {
+ return (need_tmp || !sort_by_table || skip_sort_order ||
+ ((group || tmp_table_param.sum_func_count) && !group_list)) ?
+ NULL : join_tab+const_tables;
+ }
bool setup_subquery_caches();
bool shrink_join_buffers(JOIN_TAB *jt,
ulonglong curr_space,
@@ -1833,7 +1839,19 @@ public:
@details this function makes sure truncation warnings when preparing the
key buffers don't end up as errors (because of an enclosing INSERT/UPDATE).
*/
- enum store_key_result copy(THD *thd);
+ enum store_key_result copy(THD *thd)
+ {
+ enum store_key_result result;
+ enum_check_fields org_count_cuted_fields= thd->count_cuted_fields;
+ sql_mode_t org_sql_mode= thd->variables.sql_mode;
+ thd->variables.sql_mode&= ~(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
+ thd->variables.sql_mode|= MODE_INVALID_DATES;
+ thd->count_cuted_fields= CHECK_FIELD_IGNORE;
+ result= copy_inner();
+ thd->count_cuted_fields= org_count_cuted_fields;
+ thd->variables.sql_mode= org_sql_mode;
+ return result;
+ }
protected:
Field *to_field; // Store data here
@@ -1919,7 +1937,36 @@ public:
const char *name() const override { return "func"; }
protected:
- enum store_key_result copy_inner() override;
+ enum store_key_result copy_inner() override
+ {
+ TABLE *table= to_field->table;
+ MY_BITMAP *old_map= dbug_tmp_use_all_columns(table,
+ &table->write_set);
+ int res= FALSE;
+
+ /*
+ It looks like the next statement is needed only for a simplified
+ hash function over key values used now in BNLH join.
+ When the implementation of this function will be replaced for a proper
+ full version this statement probably should be removed.
+ */
+ to_field->reset();
+
+ if (use_value)
+ item->save_val(to_field);
+ else
+ res= item->save_in_field(to_field, 1);
+ /*
+ Item::save_in_field() may call Item::val_xxx(). And if this is a subquery
+ we need to check for errors executing it and react accordingly
+ */
+ if (!res && table->in_use->is_error())
+ res= 1; /* STORE_KEY_FATAL */
+ dbug_tmp_restore_column_map(&table->write_set, old_map);
+ null_key= to_field->is_null() || item->null_value;
+ return ((err != 0 || res < 0 || res > 2) ? STORE_KEY_FATAL :
+ (store_key_result) res);
+ }
};
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 5c17f8a633e..7127cbc00f6 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -6794,9 +6794,3 @@ static Sys_var_ulonglong Sys_max_rowid_filter_size(
SESSION_VAR(max_rowid_filter_size), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(1024, (ulonglong)~(intptr)0), DEFAULT(128*1024),
BLOCK_SIZE(1));
-
-bool Sys_var_mybool::session_update(THD *thd, set_var *var)
-{
- session_var(thd, my_bool)= var->save_result.ulonglong_value != 0;
- return false;
-}
diff --git a/sql/sys_vars.ic b/sql/sys_vars.ic
index 47b2241d1a9..97e3a28b67e 100644
--- a/sql/sys_vars.ic
+++ b/sql/sys_vars.ic
@@ -460,7 +460,11 @@ public:
SYSVAR_ASSERT(getopt.arg_type == OPT_ARG || getopt.id < 0);
SYSVAR_ASSERT(size == sizeof(my_bool));
}
- bool session_update(THD *thd, set_var *var);
+ bool session_update(THD *thd, set_var *var)
+ {
+ session_var(thd, my_bool)= var->save_result.ulonglong_value != 0;
+ return false;
+ }
bool global_update(THD *thd, set_var *var)
{
global_var(my_bool)= var->save_result.ulonglong_value != 0;
diff --git a/unittest/sql/CMakeLists.txt b/unittest/sql/CMakeLists.txt
index f7367baa082..7dd0074eddb 100644
--- a/unittest/sql/CMakeLists.txt
+++ b/unittest/sql/CMakeLists.txt
@@ -31,7 +31,6 @@ ADD_DEPENDENCIES(mf_iocache-t GenError)
MY_ADD_TEST(mf_iocache)
# Json writer needs String which needs sql library
-ADD_EXECUTABLE(my_json_writer-t my_json_writer-t.cc dummy_builtins.cc)
-TARGET_LINK_LIBRARIES(my_json_writer-t PUBLIC sql mytap)
-TARGET_COMPILE_DEFINITIONS(my_json_writer-t PUBLIC JSON_WRITER_UNIT_TEST)
-MY_ADD_TEST(my_json_writer)
+#ADD_EXECUTABLE(my_json_writer-t my_json_writer-t.cc dummy_builtins.cc)
+#TARGET_LINK_LIBRARIES(my_json_writer-t sql mytap)
+#MY_ADD_TEST(my_json_writer)
diff --git a/unittest/sql/my_json_writer-t.cc b/unittest/sql/my_json_writer-t.cc
index 52988f7a979..a585c17c75f 100644
--- a/unittest/sql/my_json_writer-t.cc
+++ b/unittest/sql/my_json_writer-t.cc
@@ -26,6 +26,7 @@
*/
struct TABLE;
+struct JOIN_TAB;
class Json_writer;
@@ -38,15 +39,13 @@ public:
Json_writer *get_current_json() { return nullptr; }
};
-class THD
+class THD
{
public:
Opt_trace opt_trace;
};
-#ifndef JSON_WRITER_UNIT_TEST
#define JSON_WRITER_UNIT_TEST
-#endif
#include "../sql/my_json_writer.h"
#include "../sql/my_json_writer.cc"
@@ -125,15 +124,19 @@ int main(int args, char **argv)
w.start_object();
w.add_member("name").add_ll(1);
w.add_member("name").add_ll(2);
+ w.end_object();
ok(w.invalid_json, "JSON object member name collision");
}
{
Json_writer w;
w.start_object();
- w.add_member("name").start_object();
+ w.add_member("name").add_ll(1);
+ w.start_object();
w.add_member("name").add_ll(2);
- ok(!w.invalid_json, "This must be valid JSON: nested object member has the same name");
+ w.end_object();
+ w.end_object();
+ ok(!w.invalid_json, "Valid JSON: nested object member name is the same");
}
diag("Done");