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

add support for USING <identifier> to CREATE TABLE #3633

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,7 @@ func (ct *ColumnType) WalkSubtree(visit Visit) error {
type IndexDefinition struct {
Info *IndexInfo
Columns []*IndexColumn
Using ColIdent
}

// Format formats the node.
Expand All @@ -998,6 +999,9 @@ func (idx *IndexDefinition) Format(buf *TrackedBuffer) {
}
}
buf.Myprintf(")")
if !idx.Using.IsEmpty() {
buf.Myprintf(" USING %v", idx.Using)
}
}

// WalkSubtree walks the nodes of the subtree.
Expand Down
15 changes: 15 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,21 @@ func TestCreateTable(t *testing.T) {
" key by_full_name (full_name)\n" +
")",

// test that indexes support USING <id>
"create table t (\n" +
" id int auto_increment,\n" +
" username varchar,\n" +
" email varchar,\n" +
" full_name varchar,\n" +
" status_nonkeyword varchar,\n" +
" primary key (id) USING BTREE,\n" +
" unique key by_username (username) USING HASH,\n" +
" unique by_username2 (username) USING OTHER,\n" +
" unique index by_username3 (username) USING XYZ,\n" +
" index by_status (status_nonkeyword) USING PDQ,\n" +
" key by_full_name (full_name) USING OTHER\n" +
")",

// multi-column indexes
"create table t (\n" +
" id int auto_increment,\n" +
Expand Down
Loading