我在Macbook上运行MySQL服务器(用于测试)。版本是Homebrew的5.6.20。我开始遇到“行大小太大”错误,并且能够将其减少到此测试用例。表:
mysql> describe test;
+-------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+----------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| stuff | longtext | YES | | NULL | |
+-------+----------+------+-----+---------+----------------+
表格状态:
mysql> show table status where Name = 'test';
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+---------+
| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time | Update_time | Check_time | Collation | Checksum | Create_options | Comment |
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+---------+
| test | InnoDB | 10 | Compact | 1 | 16384 | 16384 | 0 | 0 | 5242880 | 2 | 2014-08-28 23:51:12 | NULL | NULL | utf8_general_ci | NULL | | |
+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-----------------+----------+----------------+---------+
当我尝试向表中的行插入stuff
超过5033932字节的行时出现错误。
mysql> select length(stuff) from test;
+---------------+
| length(stuff) |
+---------------+
| 5033932 |
+---------------+
mysql> update test set stuff = concat(stuff, 'a');
ERROR 1118 (42000): Row size too large (> 8126). Changing some columns to TEXT or BLOB or using ROW_FORMAT=DYNAMIC or ROW_FORMAT=COMPRESSED may help. In current row format, BLOB prefix of 768 bytes is stored inline.
我搜索了这个错误,大多数答案都涉及到太多的TEXT列,并且每个列都有768字节内联存储。如您所见,对我而言并非如此。另外,无论表中有多少列,数字5033932都保持不变。在我的原始应用程序中,有五列,并且当列大小超过5033932时,更新仍然失败。
我还看到人们通过切换行格式解决了这个问题,我将尝试一下,但是我想确切地了解是什么导致了此错误。
提前致谢!