Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
691f7e16
Commit
691f7e16
authored
Nov 14, 2021
by
Sergei Krivonos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-27036: allow Json_writer_[array|object] from Json_writer
parent
917b4210
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
13 deletions
+25
-13
sql/my_json_writer.h
sql/my_json_writer.h
+25
-13
No files found.
sql/my_json_writer.h
View file @
691f7e16
...
...
@@ -372,15 +372,21 @@ class Json_writer_struct
bool
closed
;
public:
explicit
Json_writer_struct
(
THD
*
thd
,
bool
expect_named_children
)
explicit
Json_writer_struct
(
Json_writer
*
writer
)
:
my_writer
(
writer
)
{
my_writer
=
thd
->
opt_trace
.
get_current_json
();
context
.
init
(
my_writer
);
closed
=
false
;
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
named_items_expectation
.
push_back
(
expect_named_children
);
#endif
}
explicit
Json_writer_struct
(
THD
*
thd
)
:
Json_writer_struct
(
thd
->
opt_trace
.
get_current_json
())
{
}
public:
virtual
~
Json_writer_struct
()
{
...
...
@@ -420,8 +426,8 @@ class Json_writer_object : public Json_writer_struct
my_writer
->
add_member
(
name
);
}
public:
explicit
Json_writer_object
(
THD
*
thd
,
const
char
*
str
=
nullptr
)
:
Json_writer_struct
(
thd
,
true
)
explicit
Json_writer_object
(
Json_writer
*
writer
,
const
char
*
str
=
nullptr
)
:
Json_writer_struct
(
writer
)
{
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
DBUG_ASSERT
(
named_item_expected
());
...
...
@@ -434,6 +440,11 @@ class Json_writer_object : public Json_writer_struct
}
}
explicit
Json_writer_object
(
THD
*
thd
,
const
char
*
str
=
nullptr
)
:
Json_writer_object
(
thd
->
opt_trace
.
get_current_json
(),
str
)
{
}
~
Json_writer_object
()
{
if
(
my_writer
&&
!
closed
)
...
...
@@ -593,25 +604,25 @@ class Json_writer_object : public Json_writer_struct
class
Json_writer_array
:
public
Json_writer_struct
{
public:
Json_writer_array
(
THD
*
thd
)
:
Json_writer_struct
(
thd
,
false
)
explicit
Json_writer_array
(
Json_writer
*
writer
,
const
char
*
str
=
nullptr
)
:
Json_writer_struct
(
writer
)
{
#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_array
();
}
}
Json_writer_array
(
THD
*
thd
,
const
char
*
s
tr
)
:
Json_writer_struct
(
thd
,
false
)
explicit
Json_writer_array
(
THD
*
thd
,
const
char
*
str
=
nullp
tr
)
:
Json_writer_array
(
thd
->
opt_trace
.
get_current_json
(),
str
)
{
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
DBUG_ASSERT
(
named_item_expected
());
#endif
if
(
unlikely
(
my_writer
))
my_writer
->
add_member
(
str
).
start_array
();
}
~
Json_writer_array
()
{
if
(
unlikely
(
my_writer
&&
!
closed
))
...
...
@@ -620,6 +631,7 @@ class Json_writer_array : public Json_writer_struct
closed
=
TRUE
;
}
}
void
end
()
{
DBUG_ASSERT
(
!
closed
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment