apache / apache/datafusion-sqlparser-rs
MySQL Compatibility Issues: mysqldump
- Dominant language
- Rust
- Stars
- 3.5k
- Forks
- 772
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 17
Description
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`
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the parser errors with the mysqldump SQL shown in the issue, including ENGINE, LOCK TABLES, escaped apostrophes, and UNLOCK. Compare each construct with the parser's supported MySQL or MariaDB syntax; done means the listed dump statements parse successfully without regressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mariadb, mysql, rust
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100