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

executor: support prepare DDL statements with no parameters #10144

Merged
merged 6 commits into from
May 6, 2019

Conversation

ian-p-cooke
Copy link
Contributor

What problem does this PR solve?

This PR improves compatibility with MySQL 5.7 by accepting some DDL as prepared statements.
Currently TiDB accepts no DDL as prepared statements (#9425).
MySQL 5.7 lists some DDL statements in the accepted SQL for prepared statements: https://dev.mysql.com/doc/refman/5.7/en/sql-syntax-prepared-statements.html

What is changed and how it works?

I removed the explicit check for DDL and relaxed the restriction from no DDL to ddl without parameters. I don't believe parameters are used often for DDL and I am unable to test DDL with parameters so I left that restriction in. Even so it's still useful; for example, Diesel's MySQL driver prepares all statements, including DDL, and with this change TiDB becomes more compatible with MySQL 5.7 and Diesel.

Check List

Tests

  • Unit test in prepared_test.go TestPreparedNameResolver

Code changes

no function signatures have changed.
The text of ErrPrepareDDL changed.

Side effects

  • SQL that was illegal before becomes legal (DDL with no parameters in prepared statements).

Related changes

  • Need to be included in the release note

@CLAassistant
Copy link

CLAassistant commented Apr 14, 2019

CLA assistant check
All committers have signed the CLA.

executor/prepared.go Outdated Show resolved Hide resolved
@zz-jason zz-jason changed the title * accept DDL statements with no parameters (#9425) executor: support prepare DDL statements with no parameters Apr 17, 2019
@zz-jason zz-jason added sig/execution SIG execution contribution This PR is from a community contributor. labels Apr 17, 2019
@ngaut
Copy link
Member

ngaut commented Apr 18, 2019

Thank you @ian-p-cooke

I can't figure out why we need to prepare DDL statements, could you explain your user case?

@ian-p-cooke
Copy link
Contributor Author

@ngaut the case I ran into was using Diesel's "migrate" feature with the mysql driver against a TiDB instance. The driver assumes that all SQL statements that it sends can be prepared, including the DDL. This works fine for a mysql instance but a TiDB instance fails on the DDL.

I talked to Diesel's maintainer and he suggested that TiDB would be better supported with a custom TiDB driver but I don't have time to work on that and the mysql driver works except for this DDL issue.

Since this issue improves the compatibility with mysql I thought it would be a good change to TiDB.

@ian-p-cooke
Copy link
Contributor Author

I think I messed up my pull request be rebasing on master manually. can this pull request be repaired or should I just start a new one?

@codecov
Copy link

codecov bot commented May 5, 2019

Codecov Report

Merging #10144 into master will increase coverage by 0.0151%.
The diff coverage is 0%.

@@               Coverage Diff               @@
##            master     #10144        +/-   ##
===============================================
+ Coverage   77.673%   77.6882%   +0.0151%     
===============================================
  Files          411        411                
  Lines        85435      85408        -27     
===============================================
- Hits         66360      66352         -8     
+ Misses       14110      14097        -13     
+ Partials      4965       4959         -6

@shenli
Copy link
Member

shenli commented May 5, 2019

@ian-p-cooke I think you can reset your branch and use force-push to update your repo.

@ngaut
Copy link
Member

ngaut commented May 5, 2019

Thanks for detail explanation @ian-p-cooke

@ian-p-cooke
Copy link
Contributor Author

ah, i used the 'update branch' button instead this time and now the pull request is back down to just my commits. I think you can squash them you pull, right? I won't do anything else with git right now.

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

@winkyao
Copy link
Contributor

winkyao commented May 5, 2019

@crazycs520 @bb7133 PTAL

Copy link
Member

@ngaut ngaut left a comment

Choose a reason for hiding this comment

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

LGTM

@ngaut ngaut merged commit c9cc3b7 into pingcap:master May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution This PR is from a community contributor. sig/execution SIG execution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants