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

Conversation

Projects
None yet
8 participants
@lonng
Copy link
Member

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

This comment has been minimized.

Copy link
Member

lonng commented Jan 3, 2019

@kennytm kennytm added the status/DNM label Jan 3, 2019

@tiancaiamao

This comment has been minimized.

Copy link
Contributor

tiancaiamao commented Jan 3, 2019

Please update go.mod

@lonng lonng force-pushed the lonng:pr-if-not-exists branch 3 times, most recently from f5aa822 to 7eb9f1b Jan 3, 2019

@lonng lonng force-pushed the lonng:pr-if-not-exists branch from 7eb9f1b to 7507ebb Jan 4, 2019

@lonng

This comment has been minimized.

Copy link
Member

lonng commented Jan 4, 2019

/run-all-tests

@winkyao
Copy link
Member

winkyao left a comment

LGTM

@kennytm kennytm removed the status/DNM label Jan 4, 2019

@lonng lonng added the status/LGT1 label Jan 4, 2019

@eurekaka
Copy link
Contributor

eurekaka left a comment

LGTM

@eurekaka

This comment has been minimized.

Copy link
Contributor

eurekaka commented Jan 4, 2019

/run-unit-test

1 similar comment
@zyguan

This comment has been minimized.

Copy link
Contributor

zyguan commented Jan 4, 2019

/run-unit-test

@codecov-io

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

lonng commented Jan 4, 2019

/run-all-tests

@winkyao

winkyao approved these changes Jan 4, 2019

@zimulala

This comment has been minimized.

Copy link
Member

zimulala commented Jan 4, 2019

/run-unit-test

@lonng lonng merged commit e0b30fe into pingcap:master Jan 4, 2019

12 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
idc-jenkins-ci-tidb/build Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/common-test job succeeded
Details
idc-jenkins-ci-tidb/integration-common-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/integration-compatibility-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/integration-ddl-test Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/mybatis-test job succeeded
Details
idc-jenkins-ci-tidb/sqllogic-test-1 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/sqllogic-test-2 Jenkins job succeeded.
Details
idc-jenkins-ci-tidb/unit-test Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

@lonng lonng deleted the lonng:pr-if-not-exists branch Jan 4, 2019

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