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

planner,executor: support show create database if not exists syntax #8926

Merged
merged 4 commits into from
Jan 4, 2019
Merged

planner,executor: support show create database if not exists syntax #8926

merged 4 commits into from
Jan 4, 2019

Conversation

lonng
Copy link
Contributor

@lonng lonng commented Jan 3, 2019

What problem does this PR solve?

pingcap/parser#147
pingcap/parser#148

MySQL compatibility: show create database if not exists syntax

See: https://dev.mysql.com/doc/refman/5.7/en/show-create-database.html

MySQL

MariaDB [(none)]> show create database b2;
+----------+----------------------------------------------------------------+
| Database | Create Database                                                |
+----------+----------------------------------------------------------------+
| b2       | CREATE DATABASE `b2` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
+----------+----------------------------------------------------------------+
1 row in set (0.002 sec)

MariaDB [(none)]> show create database if not exists b2;
+----------+-----------------------------------------------------------------------------------------+
| Database | Create Database                                                                         |
+----------+-----------------------------------------------------------------------------------------+
| b2       | CREATE DATABASE /*!32312 IF NOT EXISTS*/ `b2` /*!40100 DEFAULT CHARACTER SET utf8mb4 */ |
+----------+-----------------------------------------------------------------------------------------+
1 row in set (0.000 sec)

TiDB

MySQL [b1]> show create batabase b2;
ERROR 1105 (HY000): line 1 column 20 near " b2" (total length 23)
MySQL [b1]> show create database b2;
+----------+-----------------------------------------------------------------+
| Database | Create Database                                                 |
+----------+-----------------------------------------------------------------+
| b2       | CREATE DATABASE `b2` /* !40100 DEFAULT CHARACTER SET utf8mb4 */ |
+----------+-----------------------------------------------------------------+
1 row in set (0.000 sec)

MySQL [b1]> show create database if not exists b2;
ERROR 1105 (HY000): line 1 column 23 near " not exists b2" (total length 37)

What is changed and how it works?

Insert /*!32312 IF NOT EXISTS*/ before shema name when statement contains if not exists

Check List

Tests

  • Unit test

Code changes

Side effects

Related changes

  • Need to cherry-pick to the release branch

This change is Reviewable

@lonng
Copy link
Contributor Author

lonng commented Jan 3, 2019

@tiancaiamao
Copy link
Contributor

Please update go.mod

@lonng
Copy link
Contributor Author

lonng commented Jan 4, 2019

/run-all-tests

Copy link
Contributor

@winkyao winkyao left a comment

Choose a reason for hiding this comment

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

LGTM

@kennytm kennytm removed the status/DNM label Jan 4, 2019
@lonng lonng added the status/LGT1 Indicates that a PR has LGTM 1. label Jan 4, 2019
Copy link
Contributor

@eurekaka eurekaka left a comment

Choose a reason for hiding this comment

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

LGTM

@eurekaka eurekaka added sig/planner SIG: Planner sig/execution SIG execution status/LGT2 Indicates that a PR has LGTM 2. and removed component/parser status/LGT1 Indicates that a PR has LGTM 1. labels Jan 4, 2019
@eurekaka
Copy link
Contributor

eurekaka commented Jan 4, 2019

/run-unit-test

1 similar comment
@zyguan
Copy link
Contributor

zyguan commented Jan 4, 2019

/run-unit-test

@codecov-io
Copy link

codecov-io commented Jan 4, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@cef6e75). Click here to learn what that means.
The diff coverage is 28.57%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #8926   +/-   ##
=========================================
  Coverage          ?   67.54%           
=========================================
  Files             ?      363           
  Lines             ?    74989           
  Branches          ?        0           
=========================================
  Hits              ?    50649           
  Misses            ?    19880           
  Partials          ?     4460
Impacted Files Coverage Δ
planner/core/common_plans.go 60.98% <ø> (ø)
executor/show.go 40.85% <0%> (ø)
planner/core/planbuilder.go 48.68% <100%> (ø)
executor/builder.go 82.77% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cef6e75...e88a958. Read the comment docs.

@lonng
Copy link
Contributor Author

lonng commented Jan 4, 2019

/run-all-tests

@zimulala
Copy link
Contributor

zimulala commented Jan 4, 2019

/run-unit-test

@lonng lonng merged commit e0b30fe into pingcap:master Jan 4, 2019
@lonng lonng deleted the pr-if-not-exists branch January 4, 2019 05:31
zimulala added a commit that referenced this pull request Jan 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution sig/planner SIG: Planner status/LGT2 Indicates that a PR has LGTM 2. type/compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants