Skip to content

Commit

Permalink
Adding parser support for VISIBLE and INVISIBLE modifiers for indexes.
Browse files Browse the repository at this point in the history
  • Loading branch information
fulghum committed Sep 20, 2023
1 parent 648c869 commit 86aca08
Show file tree
Hide file tree
Showing 5 changed files with 6,952 additions and 6,922 deletions.
4 changes: 2 additions & 2 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -3094,7 +3094,7 @@ func (idx *IndexSpec) Format(buf *TrackedBuffer) {
buf.Myprintf(" %s", opt.Name)
if opt.Using != "" {
buf.Myprintf(" %s", opt.Using)
} else {
} else if opt.Value != nil {
buf.Myprintf(" %v", opt.Value)
}
}
Expand Down Expand Up @@ -3152,7 +3152,7 @@ func (idx *IndexDefinition) Format(buf *TrackedBuffer) {
buf.Myprintf(" %s", opt.Name)
if opt.Using != "" {
buf.Myprintf(" %s", opt.Using)
} else {
} else if opt.Value != nil {
buf.Myprintf(" %v", opt.Value)
}
}
Expand Down
1 change: 1 addition & 0 deletions go/vt/sqlparser/keywords.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ var keywords = map[string]int{
"version_token_admin": VERSION_TOKEN_ADMIN,
"view": VIEW,
"virtual": VIRTUAL,
"visible": VISIBLE,
"warnings": WARNINGS,
"week": WEEK,
"when": WHEN,
Expand Down
12 changes: 12 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1543,6 +1543,12 @@ var (
}, {
input: "create table a (b1 bool not null primary key, b2 boolean not null)",
output: "create table a (\n\tb1 bool not null primary key,\n\tb2 boolean not null\n)",
}, {
input: "CREATE TABLE `dolt_test`.`a` (`id` INT, `b` DOUBLE, PRIMARY KEY (`id`), INDEX `c` (`b` ASC) INVISIBLE)",
output: "create table dolt_test.a (\n\tid INT,\n\tb DOUBLE,\n\tPRIMARY KEY (id),\n\tINDEX c (b) INVISIBLE\n)",
}, {
input: "CREATE TABLE `dolt_test`.`a` (`id` INT, `b` DOUBLE, PRIMARY KEY (`id`), INDEX `c` (`b` ASC) VISIBLE)",
output: "create table dolt_test.a (\n\tid INT,\n\tb DOUBLE,\n\tPRIMARY KEY (id),\n\tINDEX c (b) VISIBLE\n)",
}, {
input: "create temporary table a (b1 bool not null primary key, b2 boolean not null)",
output: "create temporary table a (\n\tb1 bool not null primary key,\n\tb2 boolean not null\n)",
Expand All @@ -1558,6 +1564,12 @@ var (
}, {
input: "create index a on b (foo(6) desc, foo asc)",
output: "alter table b add index a (foo(6) desc, foo)",
}, {
input: "CREATE INDEX `c` on `dolt_test`.`a`(`b` ASC) INVISIBLE",
output: "alter table dolt_test.a add index c (b) INVISIBLE",
}, {
input: "CREATE INDEX `c` on `dolt_test`.`a`(`b` ASC) VISIBLE",
output: "alter table dolt_test.a add index c (b) VISIBLE",
}, {
input: "create unique index a on b (id)",
output: "alter table b add unique index a (id)",
Expand Down
Loading

0 comments on commit 86aca08

Please sign in to comment.