-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
ddl: support drop sequence in TiDB #14442
Conversation
@@ -84,3 +84,37 @@ func (s *testSequenceSuite) TestCreateSequence(c *C) { | |||
c.Assert(err, NotNil) | |||
c.Assert(err.Error(), Equals, "[planner:1142]CREATE command denied to user 'localhost'@'myuser' for table 'my_seq'") | |||
} | |||
|
|||
func (s *testSequenceSuite) TestDropSequence(c *C) { | |||
s.tk = testkit.NewTestKit(c, s.store) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the test case for drop table SEQUCNE_NAME
, 'drop view SEQUCNE_NAME`.
Also, we need to test the behavior for drop sequence TABLE_NAME
, drop sequence VIEW_NAME
, but not in this function. You can find a suitable place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch.
It does not look like privilege checks are being done here. I assume it will be handled in a followup PR? |
Good catch! thanks for reminding me. |
executor/ddl.go
Outdated
|
||
} | ||
|
||
func (e *DDLExec) dropTableViewSequence(objects []*ast.TableName, obt objectType, ifExists bool) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming is weird. How about renaming it to dropTableObject
and add some comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, addressed.
executor/ddl.go
Outdated
viewObject | ||
sequenceObject | ||
) | ||
|
||
func (e *DDLExec) executeDropTableOrView(s *ast.DropTableStmt) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please separate this function to executeDropTable
and executeDropView
(just what you did for Sequences).
Both of them can simply call dropTableViewSequence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, addressed.
I've added the check, please take a look~ |
/build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM
Exactly right, I've fixed it, PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-unit-test |
/run-unit-test |
/run-all-tests |
/rebuild |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/merge |
/run-all-tests |
support drop sequence in TiDB.
What problem does this PR solve?
What is changed and how it works?
dropTableOrView
, so I merge them together.HDel()
won't take effect if the sequence kv-pair is not exist in case of drop table/view)Check List
Tests
Code changes
Related changes
Release note