apache / apache/datafusion-sqlparser-rs
MySQL Compatibility Issues: mysqldump
- 主要言語
- Rust
- スター
- 3.5k
- フォーク
- 772
- 平均マージ
- 4日 9時間
- マージ済み PR(30日)
- 17
説明
I ran into multiple MySQL compatibility issues when attempting to parse a dump produced by `sudo mysqldump dbname > dbname_backup.sql` (also see [mysqldump docs](https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html) or [mariadb docs](https://mariadb.com/kb/en/mysqldump/)).
Here is an example of `mysqldump` generated SQL (this database is from a [WordPress](https://wordpress.com/) installation):
```
-- MySQL dump 10.16 Distrib 10.1.26-MariaDB, for debian-linux-gnu (x86_64)
--
-- Table structure for table `wp_users`
--
DROP TABLE IF EXISTS `wp_users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `wp_users` (
`ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_login` varchar(60) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_pass` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_nicename` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_email` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_url` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_registered` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`user_activation_key` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`user_status` int(11) NOT NULL DEFAULT '0',
`display_name` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
PRIMARY KEY (`ID`),
KEY `user_login_key` (`user_login`),
KEY `user_nicename` (`user_nicename`),
KEY `user_email` (`user_email`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `wp_users`
--
LOCK TABLES `wp_users` WRITE;
/*!40000 ALTER TABLE `wp_users` DISABLE KEYS */;
INSERT INTO `wp_users` VALUES (1,'MyUser','PasswordHash','myuser','myuser@example.com','','2020-09-22 14:45:28','',0,'My\'User');
/*!40000 ALTER TABLE `wp_users` ENABLE KEYS */;
UNLOCK TABLES;
```
More specifically (deleting various bits to expose more errors):
- https://github.com/ballista-compute/sqlparser-rs/issues/279
- `sql parser error: Expected end of statement, found: ENGINE`
- `sql parser error: Expected an SQL statement, found: LOCK`
- `sql parser error: Expected ), found: User`
(see `'My\'User'` in the example - it seems like the escaping on the `'` immediately before `User` was not handled)
- `sql parser error: Expected an SQL statement, found: UNLOCK`
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
まず、issue に示されている mysqldump SQL を使って、ENGINE、LOCK TABLES、エスケープされたアポストロフィ、UNLOCK を含む parser のエラーを再現します。各構文を parser がサポートする MySQL または MariaDB の構文と比較します。完了条件は、一覧にある dump 文が回帰なしで正常に parse できることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- mariadb, mysql, rust
- 領域
- databases
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100