Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(mysqldump): support mysqldump dump schema #4972

Merged
merged 3 commits into from
Apr 20, 2022

Conversation

BohuTANG
Copy link
Member

@BohuTANG BohuTANG commented Apr 20, 2022

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

Reference MySQL 8.0:
https://github.com/mysql/mysql-server/blob/8.0/client/mysqldump.cc

Export:

mysqldump --set-gtid-purged=OFF --no-tablespaces --no-data --triggers=0 --column-statistics=0 -uroot -h127.0.0.1 -P3307 dd1 >/tmp/dd1.sql
-- MySQL dump 10.13  Distrib 8.0.28, for Linux (x86_64)
--
-- Host: 127.0.0.1    Database: dd1
-- ------------------------------------------------------
-- Server version	8.0.26-v0.7.23-nightly-0f576a7-simd(rust-1.61.0-nightly-2022-04-20T08:39:39.983444754Z)

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `t1`
--

DROP TABLE IF EXISTS `t1`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `t1` (
  `a` INT,
) ENGINE=FUSE;
/*!40101 SET character_set_client = @saved_cs_client */;


/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2022-04-20 19:37:26

Import:

mysql -h127.0.0.1 -uroot -P3307 dd1 < /tmp/dd1.sql

Changelog

  • New Feature

Related Issues

Fixes #issue

@vercel
Copy link

vercel bot commented Apr 20, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Updated
databend ⬜️ Ignored (Inspect) Apr 20, 2022 at 0:23AM (UTC)

@mergify
Copy link
Contributor

mergify bot commented Apr 20, 2022

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@mergify mergify bot added the pr-feature this PR introduces a new feature to the codebase label Apr 20, 2022
…gtid-purged=OFF --no-tablespaces --no-data --triggers=0 --column-statistics=0 -uroot -h127.0.0.1 -P3307 dd1
@BohuTANG BohuTANG marked this pull request as ready for review April 20, 2022 12:25
@BohuTANG BohuTANG requested a review from TCeason April 20, 2022 12:25
@TCeason
Copy link
Collaborator

TCeason commented Apr 20, 2022

LGTM

@@ -346,6 +346,8 @@ impl<'a> DfParser<'a> {
Ok(DfStatement::ShowSettings(DfShowSettings))
} else if self.consume_token("CREATE") {
self.parse_show_create()
} else if self.consume_token("FIELDS") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} else if self.consume_token("FIELDS") {

} else if self.consume_token("FIELDS") || self.consume_token("COLUMNS") {

maybe we can also support columns?

SHOW [EXTENDED] [FULL] {COLUMNS | FIELDS}
    {FROM | IN} tbl_name
    [{FROM | IN} db_name]
    [LIKE 'pattern' | WHERE expr]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, will try it later in this PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I have a check, this syntax is not support LIKE and only for mysqldump not for user in databend now.

@BohuTANG BohuTANG marked this pull request as draft April 20, 2022 13:34
@BohuTANG BohuTANG marked this pull request as ready for review April 20, 2022 13:38
@BohuTANG BohuTANG merged commit b7f4704 into databendlabs:main Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-review pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants