mysqldump 产生一个损坏的 sql 文件(显然在存储了生成列的表上)(MySQL v8.0.21)

mysqldump produce a corrupted sql file (apparently on tables with stored generated column) (MySQL v8.0.21)

我正在使用 MySQL v8.0.21 和 mysqldump v8.0.23。

我有一个具有以下架构的 table:

mysql> desc resource_downloads;
+-------------+--------------+------+-----+---------+------------------+
| Field       | Type         | Null | Key | Default | Extra            |
+-------------+--------------+------+-----+---------+------------------+
| compositeId | varchar(250) | NO   | PRI | NULL    | STORED GENERATED |
| resourceId  | int unsigned | NO   | MUL | NULL    |                  |
| userId      | int unsigned | NO   | MUL | NULL    |                  |
| fileId      | int unsigned | YES  | MUL | NULL    |                  |
+-------------+--------------+------+-----+---------+------------------+

和以下值:

mysql> select * from resource_downloads;
+-------------+------------+--------+--------+
| compositeId | resourceId | userId | fileId |
+-------------+------------+--------+--------+
| 24-150-NULL |         24 |    150 |   NULL |
| 37-150-NULL |         37 |    150 |   NULL |
| 56-150-48   |         56 |    150 |     48 |
| 56-150-NULL |         56 |    150 |   NULL |
+-------------+------------+--------+--------+
4 rows in set (0.00 sec)

这是创建 table 的 SQL 语句:

CREATE TABLE `resource_downloads` (`compositeId` varchar(250) AS (CONCAT_WS('-', resourceId, userId, IFNULL(fileId, 'NULL'))) STORED NOT NULL, `resourceId` int UNSIGNED NOT NULL, `userId` int UNSIGNED NOT NULL, `fileId` int UNSIGNED NULL, PRIMARY KEY (`compositeId`)) ENGINE=InnoDB

执行以下 mysqldump 命令时:

mysqldump -u $DB_USER -p$DB_PASSWORD $DB_NAME > dump.sql

它确实为 resource_downloads table 生成以下内容:

--
-- Dumping data for table `resource_downloads`
--

LOCK TABLES `resource_downloads` WRITE;
/*!40000 ALTER TABLE `resource_downloads` DISABLE KEYS */;
INSERT INTO `resource_downloads` (`resourceId`, `userId`, `fileId`) VALUES ,24,150,NULL),,24,150,NULL),37,150,NULL),,24,150,NULL),37,150,NULL),56,150,48),,24,150,NULL),37,150,NULL),56,150,48),56,150,NULL);
/*!40000 ALTER TABLE `resource_downloads` ENABLE KEYS */;
UNLOCK TABLES;

如您所见,它已损坏,不是有效的 SQL 语句。

我没有找到与此特定情况对应的任何内容,我猜这是由于生成的存储列所致,因为它是几天前我在我的数据库中引入它后才出现的。

对于这种情况,是否有任何解决方法可以生成可用的数据库转储?我可以考虑从转储中排除这个 table 但这很不方便...

如果将生成的列移到末尾,像这样:

CREATE TABLE `resource_downloads` (
   `resourceId` int UNSIGNED NOT NULL, 
   `userId` int UNSIGNED NOT NULL, 
   `fileId` int UNSIGNED NULL, 
   `compositeId` varchar(250) AS (CONCAT_WS('-', resourceId, userId, IFNULL(fileId, 'NULL'))) STORED NOT NULL, 
   PRIMARY KEY (`compositeId`)
) ENGINE=InnoDB;

而不是这样:

CREATE TABLE `resource_downloads` (
   `compositeId` varchar(250) AS (CONCAT_WS('-', resourceId, userId, IFNULL(fileId, 'NULL'))) STORED NOT NULL, 
   `resourceId` int UNSIGNED NOT NULL, 
   `userId` int UNSIGNED NOT NULL, 
   `fileId` int UNSIGNED NULL, 
   PRIMARY KEY (`compositeId`)
) ENGINE=InnoDB;

mysqldump 似乎运行正常。 (使用 mysqldump 8.0.25 测试)