Bug #75541 mysqldump error message line number is wrong by 1
Submitted: 17 Jan 2015 21:16 Modified: 19 Jan 2015 5:19
Reporter: Oli Sennhauser Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: mysqldump Command-line Client Severity:S3 (Non-critical)
Version:5.6.21, 5.6.22, 5.7.6 OS:Any
Assigned to: CPU Architecture:Any
Tags: max_allowed_packet, mysqldump

[17 Jan 2015 21:16] Oli Sennhauser
Description:
mysqldump error message line number when hitting max_allowd_packet size error is wrong by 1 (starting at row 0).

How to repeat:
CREATE TABLE `test` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `data` longtext,
  `ts` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB
;
insert into test values (NULL, 'Angang', NULL);
insert into test values (NULL, 'Angang', NULL);
insert into test values (NULL, 'Angang', NULL);
insert into test values (NULL, 'Angang', NULL);

set global max_allowed_packet = 20000000;

8 times:
update test set data=concat(data, repeat('bla', 100000)) where id = 3;

mysql> select id, left(data, 30), ts, length(data) from test;
+----+--------------------------------+------+--------------+
| id | left(data, 30)                 | ts   | length(data) |
+----+--------------------------------+------+--------------+
|  1 | test                           | NULL |            4 |
|  2 | test                           | NULL |            4 |
|  3 | Angangblablablablablablablabla | NULL |      2400006 |
|  4 | test                           | NULL |            4 |
+----+--------------------------------+------+--------------+
4 rows in set (0.00 sec)

set global max_allowed_packet = 1000000;

shell> mysqldump --user=root test  > /tmp/test_dump.sql
mysqldump: Error 2020: Got packet bigger than 'max_allowed_packet' bytes when dumping table `test` at row: 2

Suggested fix:
Erroneous row is definitely #3 and not #2. This results from starting the number count with 0.
This is completely not intuitive and what I would expect...
[19 Jan 2015 5:19] MySQL Verification Team
Hello Oli Sennhauser,

Thank you for the report and test case.

Thanks,
Umesh
[19 Jan 2015 5:21] MySQL Verification Team
//used max_allowed_packet directly with mysqldump client instead of using it from global vars or client section of my.cnf to see it

// 5.7.6

[ushastry@ushastry]/export/umesh/mysql-5.7.6: bin/mysqldump -u root -p test -S /tmp/mysql_ushastry.sock --max-allowed-packet=1000000 > h.sql
Enter password:
mysqldump: Error 2020: Got packet bigger than 'max_allowed_packet' bytes when dumping table `test` at row: 2

// 5.6.22

[ushastry@ushastry]/export/umesh/mysql-5.6.24: bin/mysqldump -u root -p test -S /tmp/mysql_ushastry.sock --max-allowed-packet=1000000 > h.sql
Enter password:
mysqldump: Error 2020: Got packet bigger than 'max_allowed_packet' bytes when dumping table `test` at row: 2