Bug #58099 Null Bytes (\0) cause truncated query result in SQL Editor
Submitted: 9 Nov 2010 22:35 Modified: 6 Jan 2011 10:33
Reporter: Chris Bednarski Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S2 (Serious)
Version:5.2.29 SE r6756 OS:Windows (Windows 7 Pro)
Assigned to: Alfredo Kojima CPU Architecture:Any

[9 Nov 2010 22:35] Chris Bednarski
Description:
Results for queries on rows which contain a null byte character (\0) are truncated at the null byte character when displayed in the SQL Editor results pane.

Any data following the null byte character is not displayed in the Workbench client.  The full data can be viewed when queried via commandline or other client API.

I encountered this using php's object serialization, which uses null byte characters around object members.  See Note at: http://us2.php.net/manual/en/function.serialize.php

How to repeat:
Create table:

CREATE  TABLE IF NOT EXISTS `test`.`table1` (
  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  `value` VARCHAR(255) NULL ,
  PRIMARY KEY (`id`) ,
  UNIQUE INDEX `id_UNIQUE` (`id` ASC) )
ENGINE = InnoDB;

Insert record:

INSERT INTO test.table1 VALUES(null, 'Test data \0*\0 this will not display');

Select record in Workbench:

SELECT * FROM test.table1;

Result:

'1', 'Test data '

Notice that the result column is truncated after 'Test data', and the part with '\0*\0 this will not display' does not appear in the results column.

Select record from MySQL CLI:

SELECT * FROM test.table1;

+----+-------------------------------------+
| id | value                               |
+----+-------------------------------------+
|  1 | Test data  *  this will not display |
+----+-------------------------------------+

Suggested fix:
Prevent null byte \0 from truncating result output in SQL Editor.
[9 Nov 2010 22:42] MySQL Verification Team
Thank you for the bug report.
[10 Nov 2010 22:27] Alfredo Kojima
Easiest way to repeat is select 'hello\0world'

This has been fixed in backend and Mac, pending Linux and Windows.
[11 Nov 2010 14:14] Mike Lischke
The BE fix already fixed the Win part too.
[12 Nov 2010 2:09] Alfredo Kojima
Linux fixed too.
[8 Dec 2010 20:28] Johannes Taxacher
fix confirmed in repository
[6 Jan 2011 10:33] Tony Bedford
An entry has been added to the 5.2.31 changelog:

Results for queries on rows which contained a null byte character (\0) were truncated at the null byte character when displayed in the SQL Editor results pane.