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

Initial implementation of fulltext with indexes and DDL #136

Merged
merged 3 commits into from
Mar 15, 2022
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
25 changes: 15 additions & 10 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ func (*Use) iStatement() {}
func (*Begin) iStatement() {}
func (*Commit) iStatement() {}
func (*Rollback) iStatement() {}
func (*Flush) iStatement() {}
func (*Flush) iStatement() {}
func (*OtherRead) iStatement() {}
func (*OtherAdmin) iStatement() {}
func (*BeginEndBlock) iStatement() {}
Expand Down Expand Up @@ -2094,6 +2094,9 @@ func (ct *ColumnType) Format(buf *TrackedBuffer) {
if ct.KeyOpt == colKey {
opts = append(opts, keywordStrings[KEY])
}
if ct.KeyOpt == colKeyFulltextKey {
opts = append(opts, keywordStrings[FULLTEXT])
}

if len(opts) != 0 {
buf.Myprintf(" %s", strings.Join(opts, " "))
Expand Down Expand Up @@ -2368,11 +2371,12 @@ func (idx *IndexDefinition) walkSubtree(visit Visit) error {

// IndexInfo describes the name and type of an index in a CREATE TABLE statement
type IndexInfo struct {
Type string
Name ColIdent
Primary bool
Spatial bool
Unique bool
Type string
Name ColIdent
Primary bool
Spatial bool
Unique bool
Fulltext bool
}

// Format formats the node.
Expand Down Expand Up @@ -2423,6 +2427,7 @@ const (
colKeyUnique
colKeyUniqueKey
colKey
colKeyFulltextKey
)

// AutoIncSpec defines an autoincrement value for a ADD AUTO_INCREMENT statement
Expand Down Expand Up @@ -2821,13 +2826,13 @@ func (node *Rollback) Format(buf *TrackedBuffer) {

// FlushOption is used for trailing options for flush statement
type FlushOption struct {
Name string
Name string
Channel string
}

// Flush represents a Flush statement.
type Flush struct{
Type string
type Flush struct {
Type string
Option *FlushOption
}

Expand All @@ -2839,7 +2844,7 @@ func (node *Flush) Format(buf *TrackedBuffer) {
buf.Myprintf(" %s", strings.ToLower(node.Type))
}

if node.Option.Name == "RELAY LOGS" && node.Option.Channel != ""{
if node.Option.Name == "RELAY LOGS" && node.Option.Channel != "" {
buf.Myprintf(" %s for channel %s", strings.ToLower(node.Option.Name), strings.ToLower(node.Option.Channel))
} else {
buf.Myprintf(" %s", strings.ToLower(node.Option.Name))
Expand Down
22 changes: 11 additions & 11 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2304,25 +2304,25 @@ var (
input: "REVOKE PROXY ON UserName FROM Role1, Role2",
output: "revoke proxy on `UserName`@`%` from `Role1`@`%`, `Role2`@`%`",
}, {
input: "FLUSH PRIVILEGES",
input: "FLUSH PRIVILEGES",
output: "flush privileges",
}, {
input: "FLUSH BINARY LOGS",
input: "FLUSH BINARY LOGS",
output: "flush binary logs",
}, {
input: "FLUSH USER_RESOURCES",
input: "FLUSH USER_RESOURCES",
output: "flush user_resources",
}, {
input: "FLUSH RELAY LOGS",
input: "FLUSH RELAY LOGS",
output: "flush relay logs",
}, {
input: "FLUSH LOCAL RELAY LOGS FOR CHANNEL 'connections'",
input: "FLUSH LOCAL RELAY LOGS FOR CHANNEL 'connections'",
output: "flush local relay logs for channel connections",
}, {
input: "FLUSH LOCAL OPTIMIZER_COSTS",
input: "FLUSH LOCAL OPTIMIZER_COSTS",
output: "flush local optimizer_costs",
}, {
input: "FLUSH NO_WRITE_TO_BINLOG HOSTS",
input: "FLUSH NO_WRITE_TO_BINLOG HOSTS",
output: "flush no_write_to_binlog hosts",
}, {
input: "SHOW GRANTS",
Expand All @@ -2348,8 +2348,8 @@ var (
}, {
input: "kill connection 423",
output: "kill connection 423",
},{
input: "SELECT * FROM information_schema.processlist",
}, {
input: "SELECT * FROM information_schema.processlist",
output: "select * from information_schema.`processlist`",
},
}
Expand Down Expand Up @@ -3369,6 +3369,7 @@ func TestCreateTable(t *testing.T) {
" status_nonkeyword varchar,\n" +
" primary key (id),\n" +
" spatial key geom (geom),\n" +
" fulltext key fts (full_name),\n" +
" unique key by_username (username),\n" +
" unique by_username2 (username),\n" +
" unique index by_username3 (username),\n" +
Expand Down Expand Up @@ -4414,7 +4415,6 @@ func TestParseDjangoQueries(t *testing.T) {
}
}


// not reserved in mysql
var correctlyDoParse = []string{
"account",
Expand Down Expand Up @@ -5138,7 +5138,7 @@ var incorrectlyParse = []string{
// reserved in mysql
// TODO: these parse in dolt but not in mysql (without backquotes)
// removing them from non_reserved_keyword in sql.y fixes it (without causing any shift/reduce conflicts but might cause other other problems; need tests)
var incorrectlyParse2 = []string {
var incorrectlyParse2 = []string{
"before",
"bigint",
"blob",
Expand Down
Loading