diff --git a/README.md b/README.md index 91331cb..50d6e90 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,7 @@ and `{}` for a mutually exclusive keyword. | Show DML Execution Plan | `EXPLAIN {INSERT\|UPDATE\|DELETE} ...;` | | | Show Query Execution Plan with Stats | `EXPLAIN ANALYZE SELECT ...;` | | | Show DML Execution Plan with Stats | `EXPLAIN ANALYZE {INSERT\|UPDATE\|DELETE} ...;` | | +| Start a new query optimizer statistics package construction | `ANALYZE;` | | | Start Read-Write Transaction | `BEGIN [RW] [PRIORITY {HIGH\|MEDIUM\|LOW}] [TAG ];` | See [Request Priority](#request-priority) for details on the priority. The tag you set is used as both transaction tag and request tag. See also [Transaction Tags and Request Tags](#transaction-tags-and-request-tags).| | Commit Read-Write Transaction | `COMMIT;` | | | Rollback Read-Write Transaction | `ROLLBACK;` | | diff --git a/statement.go b/statement.go index 2cec7ef..2df98d3 100644 --- a/statement.go +++ b/statement.go @@ -93,6 +93,7 @@ var ( revokeRe = regexp.MustCompile(`(?is)^REVOKE\s.+$`) alterRe = regexp.MustCompile(`(?is)^ALTER\s.+$`) truncateTableRe = regexp.MustCompile(`(?is)^TRUNCATE\s+TABLE\s+(.+)$`) + analyzeRe = regexp.MustCompile(`(?is)^ANALYZE$`) // DML dmlRe = regexp.MustCompile(`(?is)^(INSERT|UPDATE|DELETE)\s+.+$`) @@ -152,6 +153,8 @@ func BuildStatement(input string) (Statement, error) { case truncateTableRe.MatchString(input): matched := truncateTableRe.FindStringSubmatch(input) return &TruncateTableStatement{Table: unquoteIdentifier(matched[1])}, nil + case analyzeRe.MatchString(input): + return &DdlStatement{Ddl: input}, nil case showDatabasesRe.MatchString(input): return &ShowDatabasesStatement{}, nil case showCreateTableRe.MatchString(input): diff --git a/statement_test.go b/statement_test.go index 31475ac..6f0c7f1 100644 --- a/statement_test.go +++ b/statement_test.go @@ -171,6 +171,11 @@ func TestBuildStatement(t *testing.T) { input: "ALTER STATISTICS package SET OPTIONS (allow_gc = false)", want: &DdlStatement{Ddl: "ALTER STATISTICS package SET OPTIONS (allow_gc = false)"}, }, + { + desc: "ANALYZE statement", + input: "ANALYZE", + want: &DdlStatement{Ddl: "ANALYZE"}, + }, { desc: "INSERT statement", input: "INSERT INTO t1 (id, name) VALUES (1, 'yuki')",