PS-10347 [8.0]: Ensure strict JSON compliance and robust field separation in audit_log_read()/AuditJsonHandler #5776
+386
−28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The previous approach of appending ", " after every value handler was inconsistent and required error-prone comma removal logic in EndObject.
This change adopts a safer, state-driven approach:
audit_log_read()UDF was failing to respect themax_array_lengthparameter, returning all records instead of the specified limit. This was caused by the read loop not checking theis_batch_endflag.Additionally, attempting to read the remaining records in a subsequent call caused an infinite loop or parsing errors. This occurred because a new
rapidjson::Readerwas created for each call, losing the internal state required to resume parsing mid-stream (e.g., handling the comma separator between array elements).The fix involves:
is_batch_endflag in theAuditLogReader::readloop to stop processing when the limit is reached.rapidjson::Readerinstance withinAuditLogReaderContextto preserve parsing state across multipleaudit_log_read()calls.reader->HasParseError()to prevent infinite loops on malformed data or state mismatches.udf_audit_log_read_validate_outputtest case to verify correct behavior formax_array_length.