summaryrefslogtreecommitdiff
path: root/sql/my_json_writer.h
diff options
context:
space:
mode:
authorSergei Krivonos <sergei.krivonos@mariadb.com>2021-10-25 00:19:37 +0300
committerSergei Krivonos <sergeikrivonos@gmail.com>2021-11-09 12:06:49 +0200
commitb17576322b600f53c7a0b74cf14830ad5bbad98e (patch)
tree53a79159fb27e2aa8a02446bdc7d5d0b21e80d36 /sql/my_json_writer.h
parentcf047efd42ab64d730e2b84c7482e56b695678ef (diff)
downloadmariadb-git-b17576322b600f53c7a0b74cf14830ad5bbad98e.tar.gz
MDEV-23766: add Json_writer consistency asserts to check array/object sequence
Diffstat (limited to 'sql/my_json_writer.h')
-rw-r--r--sql/my_json_writer.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/sql/my_json_writer.h b/sql/my_json_writer.h
index bc8002de529..94cd438bbb0 100644
--- a/sql/my_json_writer.h
+++ b/sql/my_json_writer.h
@@ -181,6 +181,17 @@ private:
class Json_writer
{
+#ifndef NDEBUG
+
+ std::vector<bool> named_items_expectation;
+
+ bool named_item_expected() const;
+
+ bool got_name;
+ bool is_on_fmt_helper_call;
+
+#endif
+
public:
/* Add a member. We must be in an object. */
Json_writer& add_member(const char *name);
@@ -204,6 +215,11 @@ public:
private:
void add_unquoted_str(const char* val);
void add_unquoted_str(const char* val, size_t len);
+
+ bool on_add_str(const char *str, size_t num_bytes);
+ bool on_start_array();
+ void on_start_object();
+
public:
/* Start a child object */
void start_object();
@@ -221,6 +237,10 @@ public:
size_t get_truncated_bytes() { return output.get_truncated_bytes(); }
Json_writer() :
+#ifndef NDEBUG
+ got_name(false),
+ is_on_fmt_helper_call(false),
+#endif
indent_level(0), document_start(true), element_started(false),
first_child(true)
{