summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Krivonos <sergeikrivonos@gmail.com>2021-11-09 20:06:22 +0200
committerSergei Krivonos <sergeikrivonos@gmail.com>2021-11-19 16:39:04 +0200
commit34f53bf941db1f2348f964b7375f0f567c6c6f12 (patch)
tree797bc4e54bb7176571c155f0b6bc32d09f55ae23
parent26663cf9a715fd8e330b709fe9aa728e8f47b332 (diff)
downloadmariadb-git-bb-10.7-MDEV-23766.tar.gz
MDEV-23766: fix by assert (Windows)bb-10.7-releasebb-10.7-MDEV-23766
-rw-r--r--sql/my_json_writer.h25
-rw-r--r--sql/opt_range.cc7
2 files changed, 14 insertions, 18 deletions
diff --git a/sql/my_json_writer.h b/sql/my_json_writer.h
index 59dc58dec95..1afcec883e9 100644
--- a/sql/my_json_writer.h
+++ b/sql/my_json_writer.h
@@ -19,14 +19,14 @@
#include "my_base.h"
#include "sql_select.h"
-#if !defined(NDEBUG) || defined(JSON_WRITER_UNIT_TEST)
+#if !defined(NDEBUG) || defined(JSON_WRITER_UNIT_TEST) || defined(ENABLED_JSON_WRITER_CONSISTENCY_CHECKS)
#include <vector>
#endif
#ifdef JSON_WRITER_UNIT_TEST
#include "sql_string.h"
// Also, mock objects are defined in my_json_writer-t.cc
-#define VALIDITY_ASSERT(x) if ((!x)) this->invalid_json= true;
+#define VALIDITY_ASSERT(x) if (!(x)) this->invalid_json= true;
#else
#include "sql_select.h"
#define VALIDITY_ASSERT(x) DBUG_ASSERT(x)
@@ -358,6 +358,9 @@ public:
/* A common base for Json_writer_object and Json_writer_array */
class Json_writer_struct
{
+ Json_writer_struct(const Json_writer_struct&)= delete;
+ Json_writer_struct& operator=(const Json_writer_struct&)= delete;
+
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
static thread_local std::vector<bool> named_items_expectation;
#endif
@@ -418,24 +421,18 @@ private:
my_writer->add_member(name);
}
public:
- explicit Json_writer_object(THD *thd)
- : Json_writer_struct(thd, true)
+ explicit Json_writer_object(THD* thd, const char *str= nullptr)
+ : Json_writer_struct(thd, true)
{
#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_object();
- }
-
- explicit Json_writer_object(THD* thd, const char *str)
- : Json_writer_struct(thd, true)
- {
-#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
- DBUG_ASSERT(named_item_expected());
-#endif
- if (unlikely(my_writer))
- my_writer->add_member(str).start_object();
+ }
}
~Json_writer_object()
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index af703cfcf5c..9dc1bcf733f 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -5132,9 +5132,8 @@ TABLE_READ_PLAN *get_best_disjunct_quick(PARAM *param, SEL_IMERGE *imerge,
n_child_scans)))
DBUG_RETURN(NULL);
- Json_writer_object trace_best_disjunct = named_trace
- ? Json_writer_object(thd, "best_disjunct_quick")
- : Json_writer_object(thd);
+ const char* trace_best_disjunct_obj_name= named_trace ? "best_disjunct_quick" : nullptr;
+ Json_writer_object trace_best_disjunct(thd, trace_best_disjunct_obj_name);
Json_writer_array to_merge(thd, "indexes_to_merge");
/*
Collect best 'range' scan for each of disjuncts, and, while doing so,
@@ -5678,7 +5677,7 @@ void print_keyparts(THD *thd, KEY *key, uint key_parts)
DBUG_ASSERT(thd->trace_started());
KEY_PART_INFO *part= key->key_part;
- Json_writer_array keyparts= Json_writer_array(thd, "keyparts");
+ Json_writer_array keyparts(thd, "keyparts");
for(uint i= 0; i < key_parts; i++, part++)
keyparts.add(part->field->field_name);
}