Skip to content

Commit 1e8bcbd

Browse files
committed
Revert "MDEV-27036: re-enable my_json_writer-t unit test"
This reverts commit 2d21917. No explainations, lots of code moved, wrong cmake changes
1 parent 23bfacf commit 1e8bcbd

17 files changed

+152
-199
lines changed

CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ IF (NOT CPACK_GENERATOR)
142142
ENDIF(WIN32)
143143
ENDIF(NOT CPACK_GENERATOR)
144144

145-
INCLUDE(build_depends)
146145
INCLUDE(FeatureSummary)
147146
INCLUDE(misc)
148147
INCLUDE(mysql_version)
@@ -539,6 +538,8 @@ IF(UNIX)
539538
INSTALL_DOCUMENTATION(Docs/INSTALL-BINARY Docs/README-wsrep COMPONENT Readme)
540539
ENDIF()
541540

541+
INCLUDE(build_depends)
542+
542543
INCLUDE(CPack)
543544

544545
IF(WIN32 AND SIGNCODE)

cmake/ctest.cmake

-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ MACRO(MY_ADD_TESTS)
2222
ENDFOREACH()
2323
ENDMACRO()
2424

25-
FIND_PACKAGE(Boost COMPONENTS unit_test_framework)

include/my_dir.h

-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
#define MY_DIR_H
1818

1919
#include <sys/stat.h>
20-
#include <stddef.h>
21-
22-
#include "my_global.h"
2320

2421
#ifdef __cplusplus
2522
extern "C" {

sql/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ RECOMPILE_FOR_EMBEDDED)
206206
ADD_LIBRARY(sql STATIC ${SQL_SOURCE})
207207
MAYBE_DISABLE_IPO(sql)
208208
DTRACE_INSTRUMENT(sql)
209-
TARGET_LINK_LIBRARIES(sql PUBLIC
209+
TARGET_LINK_LIBRARIES(sql
210210
mysys mysys_ssl dbug strings vio pcre2-8
211211
tpool
212212
${LIBWRAP} ${LIBCRYPT} ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT}
@@ -220,7 +220,7 @@ ENDIF()
220220
FOREACH(se aria partition perfschema sql_sequence wsrep)
221221
# These engines are used directly in sql sources.
222222
IF(TARGET ${se})
223-
TARGET_LINK_LIBRARIES(sql PUBLIC ${se})
223+
TARGET_LINK_LIBRARIES(sql ${se})
224224
ENDIF()
225225
ENDFOREACH()
226226

sql/my_json_writer.cc

+1-21
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@
1313
along with this program; if not, write to the Free Software
1414
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
1515

16-
#include "my_json_writer.h"
17-
18-
#include "sql_class.h"
1916
#include "mariadb.h"
2017
#include "sql_priv.h"
2118
#include "sql_string.h"
22-
#include "log.h"
23-
19+
#include "my_json_writer.h"
2420

2521
#if !defined(NDEBUG) || defined(JSON_WRITER_UNIT_TEST)
2622
#include <iostream>
@@ -332,7 +328,6 @@ Json_writer_temp_disable::Json_writer_temp_disable(THD *thd_arg)
332328
thd= thd_arg;
333329
thd->opt_trace.disable_tracing_if_required();
334330
}
335-
336331
Json_writer_temp_disable::~Json_writer_temp_disable()
337332
{
338333
thd->opt_trace.enable_tracing_if_required();
@@ -502,18 +497,3 @@ void Single_line_formatting_helper::disable_and_flush()
502497
state= INACTIVE;
503498
}
504499

505-
506-
Json_writer_struct::Json_writer_struct(THD *thd)
507-
: Json_writer_struct(thd->opt_trace.get_current_json())
508-
{
509-
}
510-
511-
Json_writer_object::Json_writer_object(THD *thd, const char *str)
512-
: Json_writer_object(thd->opt_trace.get_current_json(), str)
513-
{
514-
}
515-
516-
Json_writer_array::Json_writer_array(THD *thd, const char *str)
517-
: Json_writer_array(thd->opt_trace.get_current_json(), str)
518-
{
519-
}

sql/my_json_writer.h

+13-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define JSON_WRITER_INCLUDED
1818

1919
#include "my_base.h"
20+
#include "sql_select.h"
2021

2122
#if !defined(NDEBUG) || defined(JSON_WRITER_UNIT_TEST) || defined ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
2223
#include <set>
@@ -31,7 +32,6 @@ constexpr uint FAKE_SELECT_LEX_ID= UINT_MAX;
3132
// Also, mock objects are defined in my_json_writer-t.cc
3233
#define VALIDITY_ASSERT(x) if (!(x)) this->invalid_json= true;
3334
#else
34-
#include "sql_select.h"
3535
#define VALIDITY_ASSERT(x) DBUG_ASSERT(x)
3636
#endif
3737

@@ -40,11 +40,8 @@ constexpr uint FAKE_SELECT_LEX_ID= UINT_MAX;
4040
class Opt_trace_stmt;
4141
class Opt_trace_context;
4242
class Json_writer;
43-
struct TABLE;
4443
struct TABLE_LIST;
4544

46-
struct st_join_table;
47-
using JOIN_TAB= struct st_join_table;
4845

4946
/*
5047
Single_line_formatting_helper is used by Json_writer to do better formatting
@@ -390,7 +387,10 @@ class Json_writer_struct
390387
named_items_expectation.push_back(expect_named_children);
391388
#endif
392389
}
393-
explicit Json_writer_struct(THD *thd);
390+
explicit Json_writer_struct(THD *thd)
391+
: Json_writer_struct(thd->opt_trace.get_current_json())
392+
{
393+
}
394394

395395
public:
396396

@@ -446,7 +446,10 @@ class Json_writer_object : public Json_writer_struct
446446
}
447447
}
448448

449-
explicit Json_writer_object(THD* thd, const char *str= nullptr);
449+
explicit Json_writer_object(THD* thd, const char *str= nullptr)
450+
: Json_writer_object(thd->opt_trace.get_current_json(), str)
451+
{
452+
}
450453

451454
~Json_writer_object()
452455
{
@@ -616,7 +619,10 @@ class Json_writer_array : public Json_writer_struct
616619
}
617620
}
618621

619-
explicit Json_writer_array(THD *thd, const char *str= nullptr);
622+
explicit Json_writer_array(THD *thd, const char *str= nullptr)
623+
: Json_writer_array(thd->opt_trace.get_current_json(), str)
624+
{
625+
}
620626

621627
~Json_writer_array()
622628
{

sql/opt_range.cc

-55
Original file line numberDiff line numberDiff line change
@@ -1254,14 +1254,6 @@ void SQL_SELECT::cleanup()
12541254
close_cached_file(&file);
12551255
}
12561256

1257-
int SQL_SELECT::skip_record(THD *thd)
1258-
{
1259-
int rc= MY_TEST(!cond || cond->val_int());
1260-
if (thd->is_error())
1261-
rc= -1;
1262-
return rc;
1263-
}
1264-
12651257

12661258
SQL_SELECT::~SQL_SELECT()
12671259
{
@@ -1880,20 +1872,6 @@ QUICK_RANGE::QUICK_RANGE()
18801872
min_keypart_map(0), max_keypart_map(0)
18811873
{}
18821874

1883-
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)
1884-
: min_key((uchar*) thd->memdup(min_key_arg, min_length_arg + 1)),
1885-
max_key((uchar*) thd->memdup(max_key_arg, max_length_arg + 1)),
1886-
min_length((uint16) min_length_arg),
1887-
max_length((uint16) max_length_arg),
1888-
flag((uint16) flag_arg),
1889-
min_keypart_map(min_keypart_map_arg),
1890-
max_keypart_map(max_keypart_map_arg)
1891-
{
1892-
#ifdef HAVE_valgrind
1893-
dummy=0;
1894-
#endif
1895-
}
1896-
18971875
SEL_ARG::SEL_ARG(SEL_ARG &arg) :Sql_alloc()
18981876
{
18991877
type=arg.type;
@@ -10870,31 +10848,6 @@ uint SEL_ARG::get_max_key_part() const
1087010848
return max_part;
1087110849
}
1087210850

10873-
SEL_ARG *SEL_ARG::clone_and(THD *thd, SEL_ARG *arg)
10874-
{ // Get overlapping range
10875-
uchar *new_min,*new_max;
10876-
uint8 flag_min,flag_max;
10877-
if (cmp_min_to_min(arg) >= 0)
10878-
{
10879-
new_min=min_value; flag_min=min_flag;
10880-
}
10881-
else
10882-
{
10883-
new_min=arg->min_value; flag_min=arg->min_flag; /* purecov: deadcode */
10884-
}
10885-
if (cmp_max_to_max(arg) <= 0)
10886-
{
10887-
new_max=max_value; flag_max=max_flag;
10888-
}
10889-
else
10890-
{
10891-
new_max=arg->max_value; flag_max=arg->max_flag;
10892-
}
10893-
return new (thd->mem_root) SEL_ARG(field, part, new_min, new_max, flag_min,
10894-
flag_max,
10895-
MY_TEST(maybe_flag && arg->maybe_flag));
10896-
}
10897-
1089810851

1089910852
/*
1090010853
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,
1661516568
}
1661616569
out->append(STRING_WITH_LEN(")"));
1661716570
}
16618-
16619-
bool RANGE_OPT_PARAM::statement_should_be_aborted() const
16620-
{
16621-
return thd->killed
16622-
|| thd->is_fatal_error
16623-
|| thd->is_error()
16624-
|| alloced_sel_args > SEL_ARG::MAX_SEL_ARGS;
16625-
}

sql/opt_range.h

+54-7
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@
3636
#include "sql_class.h" // set_var.h: THD
3737
#include "set_var.h" /* Item */
3838

39-
class Item_sum;
4039
class JOIN;
41-
class Unique;
40+
class Item_sum;
4241

4342
struct KEY_PART {
4443
uint16 key,part;
@@ -390,7 +389,30 @@ class SEL_ARG :public Sql_alloc
390389
{
391390
return sel_cmp(field,max_value, arg->min_value, max_flag, arg->min_flag);
392391
}
393-
SEL_ARG *clone_and(THD *thd, SEL_ARG* arg);
392+
SEL_ARG *clone_and(THD *thd, SEL_ARG* arg)
393+
{ // Get overlapping range
394+
uchar *new_min,*new_max;
395+
uint8 flag_min,flag_max;
396+
if (cmp_min_to_min(arg) >= 0)
397+
{
398+
new_min=min_value; flag_min=min_flag;
399+
}
400+
else
401+
{
402+
new_min=arg->min_value; flag_min=arg->min_flag; /* purecov: deadcode */
403+
}
404+
if (cmp_max_to_max(arg) <= 0)
405+
{
406+
new_max=max_value; flag_max=max_flag;
407+
}
408+
else
409+
{
410+
new_max=arg->max_value; flag_max=arg->max_flag;
411+
}
412+
return new (thd->mem_root) SEL_ARG(field, part, new_min, new_max, flag_min,
413+
flag_max,
414+
MY_TEST(maybe_flag && arg->maybe_flag));
415+
}
394416
SEL_ARG *clone_first(SEL_ARG *arg)
395417
{ // min <= X < arg->min
396418
return new SEL_ARG(field,part, min_value, arg->min_value,
@@ -711,7 +733,14 @@ class RANGE_OPT_PARAM
711733
bool force_default_mrr;
712734
KEY_PART *key[MAX_KEY]; /* First key parts of keys used in the query */
713735

714-
bool statement_should_be_aborted() const;
736+
bool statement_should_be_aborted() const
737+
{
738+
return
739+
thd->killed ||
740+
thd->is_fatal_error ||
741+
thd->is_error() ||
742+
alloced_sel_args > SEL_ARG::MAX_SEL_ARGS;
743+
}
715744
};
716745

717746

@@ -734,9 +763,21 @@ class QUICK_RANGE :public Sql_alloc {
734763
QUICK_RANGE(); /* Full range */
735764
QUICK_RANGE(THD *thd, const uchar *min_key_arg, uint min_length_arg,
736765
key_part_map min_keypart_map_arg,
737-
const uchar *max_key_arg, uint max_length_arg,
766+
const uchar *max_key_arg, uint max_length_arg,
738767
key_part_map max_keypart_map_arg,
739-
uint flag_arg);
768+
uint flag_arg)
769+
: min_key((uchar*) thd->memdup(min_key_arg, min_length_arg + 1)),
770+
max_key((uchar*) thd->memdup(max_key_arg, max_length_arg + 1)),
771+
min_length((uint16) min_length_arg),
772+
max_length((uint16) max_length_arg),
773+
flag((uint16) flag_arg),
774+
min_keypart_map(min_keypart_map_arg),
775+
max_keypart_map(max_keypart_map_arg)
776+
{
777+
#ifdef HAVE_valgrind
778+
dummy=0;
779+
#endif
780+
}
740781

741782
/**
742783
Initalizes a key_range object for communication with storage engine.
@@ -1683,7 +1724,13 @@ class SQL_SELECT :public Sql_alloc {
16831724
-1 if error
16841725
1 otherwise
16851726
*/
1686-
int skip_record(THD *thd);
1727+
inline int skip_record(THD *thd)
1728+
{
1729+
int rc= MY_TEST(!cond || cond->val_int());
1730+
if (thd->is_error())
1731+
rc= -1;
1732+
return rc;
1733+
}
16871734
int test_quick_select(THD *thd, key_map keys, table_map prev_tables,
16881735
ha_rows limit, bool force_quick_range,
16891736
bool ordered_output, bool remove_false_parts_of_where,

sql/set_var.cc

-5
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,6 @@ const uchar *sys_var::global_value_ptr(THD *thd, const LEX_CSTRING *base) const
241241
return global_var_ptr();
242242
}
243243

244-
uchar *sys_var::session_var_ptr(THD *thd) const
245-
{
246-
return ((uchar*)&(thd->variables)) + offset;
247-
}
248-
249244
bool sys_var::check(THD *thd, set_var *var)
250245
{
251246
if (unlikely((var->value && do_check(thd, var)) ||

sql/set_var.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ class sys_var: protected Value_source // for double_from_string_with_check
247247
Typically it's the same as session_value_ptr(), but it's different,
248248
for example, for ENUM, that is printed as a string, but stored as a number.
249249
*/
250-
uchar *session_var_ptr(THD *thd) const;
250+
uchar *session_var_ptr(THD *thd) const
251+
{ return ((uchar*)&(thd->variables)) + offset; }
251252

252253
uchar *global_var_ptr() const
253254
{ return ((uchar*)&global_system_variables) + offset; }

sql/sql_explain.h

-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ it into the slow query log.
5454
#ifndef SQL_EXPLAIN_INCLUDED
5555
#define SQL_EXPLAIN_INCLUDED
5656

57-
class select_result_sink;
58-
5957
class String_list: public List<char>
6058
{
6159
public:

0 commit comments

Comments
 (0)