diff options
author | Sergei Petrunia <psergey@askmonty.org> | 2014-05-27 21:04:45 +0400 |
---|---|---|
committer | Sergei Petrunia <psergey@askmonty.org> | 2014-05-27 21:04:45 +0400 |
commit | 5cfd3270ec79238b27765af3062ae7d97f6f06d0 (patch) | |
tree | 2bfa2bb941567c1eb7f81d7b86962973e6fbf1c6 /sql/my_json_writer.h | |
parent | 0925ab9d88f4328810d25392333a4cac11c6e694 (diff) | |
download | mariadb-git-5cfd3270ec79238b27765af3062ae7d97f6f06d0.tar.gz |
MDEV-6109: EXPLAIN JSON10.1-explain-json
- First code, "EXPLAIN FORMAT=JSON stmt" and "ANALYZE FORMAT=JSON stmt"
work for basic queries. Complex constructs (e.g subqueries, etc) not
yet supported.
- No test infrastructure yet
Diffstat (limited to 'sql/my_json_writer.h')
-rw-r--r-- | sql/my_json_writer.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sql/my_json_writer.h b/sql/my_json_writer.h new file mode 100644 index 00000000000..403d7e0688c --- /dev/null +++ b/sql/my_json_writer.h @@ -0,0 +1,43 @@ +/* Todo: SkySQL copyrights */ + +class Json_writer +{ +public: + /* Add a member. We must be in an object. */ + Json_writer& add_member(const char *name); + + /* Add atomic values */ + void add_ll(longlong val); + void add_str(const char* val); + void add_str(const String &str); + void add_double(double val); + void add_bool(bool val); + + /* Start a child object */ + void start_object(); + void start_array(); + + void end_object(); + void end_array(); + + Json_writer() : + indent_level(0), document_start(true), element_started(false), + first_child(true) + {} +private: + // stack of (name, bool is_object_or_array) elements. + int indent_level; + enum { INDENT_SIZE = 2 }; + + bool document_start; + bool element_started; + bool first_child; + + void append_indent(); + void start_element(); + + //const char *new_member_name; +public: + String output; +}; + |