Skip to content

ddl: support multi-table statements#4327

Merged
sougou merged 1 commit intovitessio:masterfrom
planetscale:ss-multi-ddl
Nov 4, 2018
Merged

ddl: support multi-table statements#4327
sougou merged 1 commit intovitessio:masterfrom
planetscale:ss-multi-ddl

Conversation

@sougou
Copy link
Copy Markdown
Contributor

@sougou sougou commented Oct 30, 2018

rename and drop allow multiple tables in the DDL.
This change adds support for them.

  • Introduced two new members to DDL: 'from' and 'to' table lists.
  • NewName is deprecated.
  • For single table DDLs, only Table is set.
  • For multi-table DDLs, 'from' and 'to' tables are set as needed.
  • The vttablet ddl plan had unused fields. They've been deleted.
  • The permissions code has been updated to use the new table names.

Signed-off-by: Sugu Sougoumarane ssougou@gmail.com

rename and drop allow multiple tables in the DDL.
This change adds support for them.

* Introduced two new members to DDL: 'from' and 'to' table lists.
* NewName is deprecated.
* For single table DDLs, only Table is set.
* For multi-table DDLs, 'from' and 'to' tables are set as needed.
* The vttablet ddl plan had unused fields. They've been deleted.
* The permissions code has been updated to use the new table names.

Signed-off-by: Sugu Sougoumarane <ssougou@gmail.com>
@sougou sougou requested a review from demmer October 30, 2018 17:48
@sougou
Copy link
Copy Markdown
Contributor Author

sougou commented Oct 30, 2018

@slanning you may also review this.

Copy link
Copy Markdown
Contributor

@slanning slanning left a comment

Choose a reason for hiding this comment

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

I didn't manage to break it yet, so looks good to me.

deepthi
deepthi previously requested changes Nov 1, 2018
@sougou
Copy link
Copy Markdown
Contributor Author

sougou commented Nov 1, 2018

These JSONs are not for ast.DDL. They're for planbuilder.DDLPlan: https://github.com/vitessio/vitess/blob/master/go/vt/vttablet/tabletserver/planbuilder/ddl.go#L24.

Basically, DDLPlan used to have TableName and NewTable, but they were unused. So, I removed them. That leaves it with Action as the only member. In a previous life, vttablet used to conditionally load/unload schema info for those tables. But now, it just passes the DDL through. So, it doesn't need to know the table names any more.

In a way, even Action is mostly ignored, but there's one flow where an empty action is treated as an error: https://github.com/vitessio/vitess/blob/master/go/vt/vttablet/tabletserver/query_executor.go#L394.

As to why it accepts "XYZ": "b": it's because JSON is permissive. It just ignores unmatched fields.

@deepthi deepthi dismissed their stale review November 1, 2018 20:16

No changes needed

@sougou sougou merged commit bde5ab2 into vitessio:master Nov 4, 2018
@slanning slanning mentioned this pull request Nov 9, 2018
@sougou sougou deleted the ss-multi-ddl branch November 18, 2018 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants