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
052dda61
Commit
052dda61
authored
Oct 17, 2021
by
Sergei Krivonos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made optional Json_writer_object / Json_writer_array consistency check
parent
cf8e78a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
CMakeLists.txt
CMakeLists.txt
+4
-0
sql/my_json_writer.cc
sql/my_json_writer.cc
+2
-0
sql/my_json_writer.h
sql/my_json_writer.h
+16
-0
No files found.
CMakeLists.txt
View file @
052dda61
...
...
@@ -185,6 +185,10 @@ IF(DISABLE_SHARED)
SET
(
WITHOUT_DYNAMIC_PLUGINS 1
)
ENDIF
()
OPTION
(
ENABLED_PROFILING
"Enable profiling"
ON
)
OPTION
(
ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
"Enable Json_writer_object / Json_writer_array checking to produce consistent JSON output"
OFF
)
IF
(
ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
)
ADD_DEFINITIONS
(
-DENABLED_JSON_WRITER_CONSISTENCY_CHECKS
)
ENDIF
()
OPTION
(
WITHOUT_SERVER
"Build only the client library and clients"
OFF
)
IF
(
UNIX
)
OPTION
(
WITH_VALGRIND
"Valgrind instrumentation"
OFF
)
...
...
sql/my_json_writer.cc
View file @
052dda61
...
...
@@ -260,7 +260,9 @@ void Json_writer::add_str(const String &str)
add_str
(
str
.
ptr
(),
str
.
length
());
}
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
thread_local
std
::
vector
<
bool
>
Json_writer_struct
::
named_items_expectation
;
#endif
Json_writer_temp_disable
::
Json_writer_temp_disable
(
THD
*
thd_arg
)
{
...
...
sql/my_json_writer.h
View file @
052dda61
...
...
@@ -312,7 +312,9 @@ class Json_value_helper
/* A common base for Json_writer_object and Json_writer_array */
class
Json_writer_struct
{
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
static
thread_local
std
::
vector
<
bool
>
named_items_expectation
;
#endif
protected:
Json_writer
*
my_writer
;
Json_value_helper
context
;
...
...
@@ -327,12 +329,16 @@ class Json_writer_struct
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
}
virtual
~
Json_writer_struct
()
{
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
named_items_expectation
.
pop_back
();
#endif
}
bool
trace_started
()
const
...
...
@@ -340,11 +346,13 @@ class Json_writer_struct
return
my_writer
!=
0
;
}
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
bool
named_item_expected
()
const
{
return
named_items_expectation
.
size
()
>
1
&&
*
(
named_items_expectation
.
rbegin
()
+
1
);
}
#endif
};
...
...
@@ -367,7 +375,9 @@ class Json_writer_object : public Json_writer_struct
explicit
Json_writer_object
(
THD
*
thd
)
:
Json_writer_struct
(
thd
,
true
)
{
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
DBUG_ASSERT
(
!
named_item_expected
());
#endif
if
(
unlikely
(
my_writer
))
my_writer
->
start_object
();
}
...
...
@@ -375,7 +385,9 @@ class Json_writer_object : public Json_writer_struct
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
();
}
...
...
@@ -542,7 +554,9 @@ class Json_writer_array : public Json_writer_struct
Json_writer_array
(
THD
*
thd
)
:
Json_writer_struct
(
thd
,
false
)
{
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
DBUG_ASSERT
(
!
named_item_expected
());
#endif
if
(
unlikely
(
my_writer
))
my_writer
->
start_array
();
}
...
...
@@ -550,7 +564,9 @@ class Json_writer_array : public Json_writer_struct
Json_writer_array
(
THD
*
thd
,
const
char
*
str
)
:
Json_writer_struct
(
thd
,
false
)
{
#ifdef ENABLED_JSON_WRITER_CONSISTENCY_CHECKS
DBUG_ASSERT
(
named_item_expected
());
#endif
if
(
unlikely
(
my_writer
))
my_writer
->
add_member
(
str
).
start_array
();
}
...
...
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