Bug #107222 ClientPreparedStatement.toString() no longer interpolates byte arrays
Submitted: 5 May 14:34 Modified: 9 May 10:14
Reporter: Shaun Brockhoff Email Updates:
Status: Verified Impact on me:
Category:Connector / J Severity:S3 (Non-critical)
Version:8.0.29 OS:Any
Assigned to: CPU Architecture:Any

[5 May 14:34] Shaun Brockhoff
Prior to Connector/J 8.0.29, our app would use ClientPreparedStatement.asSql() to log the full query string for local debugging. For example:

private void debugLog(PreparedStatement pstmt) {
  ClientPreparedStatement clientPstmt = pstmt.unwrap(ClientPreparedStatement.class);
  LOGGER.debug("Query: {}", clientPstmt.asSql());

8.0.29 removes ClientPreparedStatement.asSql(), and using ClientPreparedStatement.toString() mostly works as a replacement, except that byte arrays are no longer interpolated. We use binary columns heavily for uuids, so a query that previously printed as:

...where `report`.`uuid` = x'3043FC54205E4BF5ABAE543F9AA8850F00000000'

now prints as:

...where `report`.`uuid` = ** BYTE ARRAY DATA **

How to repeat:
Use ClientPreparedStatement.toString() for a query against a binary column, e.g. binary(16) column for uuids.
[9 May 10:15] Filipe Silva
Thank you for your interest in MySQL Connector/J and for this bug report.

It was verified as described.
[27 Jul 2:48] ChangXu Si
The null value in 8.0.28 will be displayed "null" but in 8.0.29 whil be displayed ** BYTE ARRAY DATA **
In version 8.0.30, this bug still exists.