Bug 548685

Summary: Extra characters appear in BLOB after mysqldump/import
Product: Red Hat Enterprise Linux 5 Reporter: Bryan Mason <bmason>
Component: mysqlAssignee: Tom Lane <tgl>
Status: CLOSED ERRATA QA Contact: qe-baseos-daemons
Severity: urgent Docs Contact:
Priority: urgent    
Version: 5.4CC: azelinka, Bjorn.Wiberg, byte, cww, hhorak, jwest, kvolny, plyons
Target Milestone: rcKeywords: Patch, ZStream
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
During a dump or reload, long BLOB (binary large object) values could be corrupted if they exceeded the maximum packet size set for MySQL. This update corrects the erroneous logic that caused incorrect insertion of a newline, resolving this issue.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-01-08 04:53:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 658863    
Attachments:
Description Flags
Proposed patch none

Description Bryan Mason 2009-12-18 07:57:50 UTC
Created attachment 379162 [details]
Proposed patch

Description of problem:

  When importing large blobs (larger than the value of the mysql
  client's max_allowed_packet), extra invalid characters will be added
  to the data.

Version-Release number of selected component (if applicable):

  mysql-5.0.77-3.el5

How reproducible:

  100%

Steps to Reproduce:

  1) Increase the value of the server's max_allowed_packet option to a
     sufficiently large value by adding the following to /etc/my.cnf

       max_allowed_packet=16777216
   
     and then restarting the mysql daemon.

  2) Run the following:

       # mysql
       Welcome to the MySQL monitor.  Commands end with ; or \g.
       Your MySQL connection id is 8
       Server version: 5.0.77 Source distribution

       Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

       mysql> create database test_db;
       Query OK, 1 row affected (0.00 sec)

       mysql> use test_db;
       Database changed

       mysql> create table t1 (data longblob);
       Query OK, 0 rows affected (0.01 sec)

       mysql> insert into t1 select repeat('1', 2*1024*1024);
       Query OK, 1 row affected (0.03 sec)
       Records: 1  Duplicates: 0  Warnings: 0

       mysql> select length(data) from t1;
       +--------------+
       | length(data) |
       +--------------+
       |      2097152 | 
       +--------------+
       1 row in set (0.00 sec)
       mysql> exit
       Bye

       # mysqldump test_db t1 > test_db-t1.sql
       # mysql test_db --max_allowed_packet=1M < test_db-t1.sql
       # mysql test_db
       Reading table information for completion of table and column names
       You can turn off this feature to get a quicker startup with -A

       Welcome to the MySQL monitor.  Commands end with ; or \g.
       Your MySQL connection id is 12
       Server version: 5.0.77 Source distribution

       Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

       mysql> select length(data) from t1;
       +--------------+
       | length(data) |
       +--------------+
       |      2097153 | 
       +--------------+
       1 row in set (0.00 sec)

      mysql> 
  
Actual results:

  The entered into the table is different than what was extracted
  using the mysqldump command.

Expected results:

  The data should be the same.

Additional info:

  This is upstream MySQL bug 41486 (http://bugs.mysql.com/bug.php?id=41486).

  The attached patch is the fix for that issue backported to
  mysql-5.0.77-3.  The patch seems to have resolved the issue -- the
  built-in tests passed and the build was successful.

Comment 7 Jaromir Hradilek 2010-12-06 16:42:44 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
During a dump or reload, long BLOB (binary large object) values could be corrupted if they exceeded the maximum packet size set for MySQL. This update corrects the erroneous logic that caused incorrect insertion of a newline, resolving this issue.

Comment 9 Tom Lane 2011-03-15 22:09:41 UTC
For the record, the patch applied for this turns out to cause problems of its own; see bug #675906

Comment 16 errata-xmlrpc 2013-01-08 04:53:57 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2013-0121.html