Skip to content

Commit

Permalink
Add support for TRUNCATE as DDL statement
Browse files Browse the repository at this point in the history
  • Loading branch information
rafael committed Oct 23, 2017
1 parent cdb860e commit 083454b
Show file tree
Hide file tree
Showing 5 changed files with 1,997 additions and 1,955 deletions.
4 changes: 2 additions & 2 deletions data/test/tabletserver/exec_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1195,8 +1195,8 @@
# truncate
"truncate a"
{
"PlanID": "OTHER_ADMIN",
"TableName": ""
"PlanID": "DDL",
"TableName": "a"
}

# table not found select
Expand Down
13 changes: 7 additions & 6 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,8 @@ func (node *Set) WalkSubtree(visit Visit) error {
)
}

// DDL represents a CREATE, ALTER, DROP or RENAME statement.
// Table is set for AlterStr, DropStr, RenameStr
// DDL represents a CREATE, ALTER, DROP, RENAME or TRUNCATE statement.
// Table is set for AlterStr, DropStr, RenameStr, TruncateStr
// NewName is set for AlterStr, CreateStr, RenameStr.
type DDL struct {
Action string
Expand All @@ -548,10 +548,11 @@ type DDL struct {

// DDL strings.
const (
CreateStr = "create"
AlterStr = "alter"
DropStr = "drop"
RenameStr = "rename"
CreateStr = "create"
AlterStr = "alter"
DropStr = "drop"
RenameStr = "rename"
TruncateStr = "truncate"
)

// Format formats the node.
Expand Down
5 changes: 4 additions & 1 deletion go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,12 @@ var (
}, {
input: "explain foobar",
output: "otherread",
}, {
input: "truncate table foo",
output: "truncate table foo",
}, {
input: "truncate foo",
output: "otheradmin",
output: "truncate table foo",
}, {
input: "repair foo",
output: "otheradmin",
Expand Down
Loading

0 comments on commit 083454b

Please sign in to comment.