Bug 548685 - Extra characters appear in BLOB after mysqldump/import
Summary: Extra characters appear in BLOB after mysqldump/import
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: mysql
Version: 5.4
Hardware: All
OS: Linux
urgent
urgent
Target Milestone: rc
: ---
Assignee: Tom Lane
QA Contact: qe-baseos-daemons
URL:
Whiteboard:
Depends On:
Blocks: 658863
TreeView+ depends on / blocked
 
Reported: 2009-12-18 07:57 UTC by Bryan Mason
Modified: 2018-11-14 17:56 UTC (History)
8 users (show)

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.
Clone Of:
Environment:
Last Closed: 2013-01-08 04:53:57 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Proposed patch (8.56 KB, patch)
2009-12-18 07:57 UTC, Bryan Mason
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2013:0121 0 normal SHIPPED_LIVE Low: mysql security and bug fix update 2013-01-08 09:10:21 UTC

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


Note You need to log in before you can comment on or make changes to this bug.