Skip to content

MDEV-36986 Support tracing arrays of primitive types - #5583

Open
bsrikanth-mariadb wants to merge 1 commit into
mainfrom
13.2-MDEV-36986-support-tracing-array-of-primitive-types
Open

MDEV-36986 Support tracing arrays of primitive types#5583
bsrikanth-mariadb wants to merge 1 commit into
mainfrom
13.2-MDEV-36986-support-tracing-array-of-primitive-types

Conversation

@bsrikanth-mariadb

@bsrikanth-mariadb bsrikanth-mariadb commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Single_line_formatting_helper accumulates array elements that may fit on one line, and printed all of them quoted when flushing numbers, booleans and nulls thus came out as JSON strings:

"depends_on_map_bits": ["0"] instead of [0]

Solution is to:

Remember per element whether it arrived via add_escaped_str() (a string, quote it) or add_unquoted_str() (a number, boolean or null, don't), in a parallel quoted[] array reset together with the buffer, and honour it in both flush paths. This also fixes disable_and_flush(), which called add_str() and so escaped the buffered strings a second time.

add_size() output stays quoted: it may carry a unit suffix ("2KiB").

While at it:

  • Json_writer_array::add(ulonglong) cast to longlong, printing values above LLONG_MAX as negative. Use add_ull(). add(size_t) had the same bug and is compiled out on _WIN64, so fixing only one would have made the output platform-dependent.
  • on_add_str() now enforces MAX_ELEMENTS instead of only asserting it, so quoted[] cannot be overrun in a release build if the line length accounting ever changes.

opt_context_schema.inc: rec_per_key holds numbers now, not strings. Also fix two syntax errors that left the schema invalid JSON, so it is usable once MDEV-38033 enables the JSON_SCHEMA_VALID() check in run_query_twice_and_compare_stats.inc.

Single_line_formatting_helper accumulates array elements that may fit on
one line, and printed all of them quoted when flushing. Numbers, booleans
and nulls thus came out as JSON strings:

  "depends_on_map_bits": ["0"]   instead of   [0]

Remember per element whether it arrived via add_escaped_str() (a string,
quote it) or add_unquoted_str() (a number, boolean or null, don't), in a
parallel quoted[] array reset together with the buffer, and honour it in
both flush paths. This also fixes disable_and_flush(), which called
add_str() and so escaped the buffered strings a second time.

add_size() output stays quoted: it may carry a unit suffix ("2KiB").

While at it:
 - Json_writer_array::add(ulonglong) cast to longlong, printing values
   above LLONG_MAX as negative. Use add_ull(). add(size_t) had the same
   bug and is compiled out on _WIN64, so fixing only one would have made
   the output platform-dependent.
 - on_add_str() now enforces MAX_ELEMENTS instead of only asserting it,
   so quoted[] cannot be overrun in a release build if the line length
   accounting ever changes.

opt_context_schema.inc: rec_per_key holds numbers now, not strings. Also
fix two syntax errors that left the schema invalid JSON, so it is usable
once MDEV-38033 enables the JSON_SCHEMA_VALID() check in
run_query_twice_and_compare_stats.inc.
@bsrikanth-mariadb
bsrikanth-mariadb force-pushed the 13.2-MDEV-36986-support-tracing-array-of-primitive-types branch from 1b03eeb to f895946 Compare August 21, 2026 15:34
@bsrikanth-mariadb
bsrikanth-mariadb marked this pull request as ready for review August 24, 2026 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant