diff --git a/README.md b/README.md
index 96ee393..91331cb 100644
--- a/README.md
+++ b/README.md
@@ -166,6 +166,10 @@ and `{}` for a mutually exclusive keyword.
| Truncate table | `TRUNCATE TABLE
;` | Only rows are deleted. Note: Non-atomically because executed as a [partitioned DML statement](https://cloud.google.com/spanner/docs/dml-partitioned?hl=en). |
| Create index | `CREATE INDEX ...;` | |
| Delete index | `DROP INDEX ...;` | |
+| Create role | `CREATE ROLE ...;` | |
+| Drop role | `DROP ROLE ...;` | |
+| Grant | `GRANT ...;` | |
+| Revoke | `REVOKE ...;` | |
| Query | `SELECT ...;` | |
| DML | `{INSERT\|UPDATE\|DELETE} ...;` | |
| Partitioned DML | `PARTITIONED {UPDATE\|DELETE} ...;` | |
diff --git a/statement.go b/statement.go
index 927dd75..2cec7ef 100644
--- a/statement.go
+++ b/statement.go
@@ -89,6 +89,8 @@ var (
dropDatabaseRe = regexp.MustCompile(`(?is)^DROP\s+DATABASE\s+(.+)$`)
createRe = regexp.MustCompile(`(?is)^CREATE\s.+$`)
dropRe = regexp.MustCompile(`(?is)^DROP\s.+$`)
+ grantRe = regexp.MustCompile(`(?is)^GRANT\s.+$`)
+ revokeRe = regexp.MustCompile(`(?is)^REVOKE\s.+$`)
alterRe = regexp.MustCompile(`(?is)^ALTER\s.+$`)
truncateTableRe = regexp.MustCompile(`(?is)^TRUNCATE\s+TABLE\s+(.+)$`)
@@ -143,6 +145,10 @@ func BuildStatement(input string) (Statement, error) {
return &DdlStatement{Ddl: input}, nil
case alterRe.MatchString(input):
return &DdlStatement{Ddl: input}, nil
+ case grantRe.MatchString(input):
+ return &DdlStatement{Ddl: input}, nil
+ case revokeRe.MatchString(input):
+ return &DdlStatement{Ddl: input}, nil
case truncateTableRe.MatchString(input):
matched := truncateTableRe.FindStringSubmatch(input)
return &TruncateTableStatement{Table: unquoteIdentifier(matched[1])}, nil
diff --git a/statement_test.go b/statement_test.go
index 0d8ce4d..31475ac 100644
--- a/statement_test.go
+++ b/statement_test.go
@@ -156,6 +156,16 @@ func TestBuildStatement(t *testing.T) {
input: "DROP CHANGE STREAM NamesAndAlbums",
want: &DdlStatement{Ddl: "DROP CHANGE STREAM NamesAndAlbums"},
},
+ {
+ desc: "GRANT statement",
+ input: "GRANT SELECT ON TABLE employees TO ROLE hr_rep",
+ want: &DdlStatement{Ddl: "GRANT SELECT ON TABLE employees TO ROLE hr_rep"},
+ },
+ {
+ desc: "REVOKE statement",
+ input: "REVOKE SELECT ON TABLE employees FROM ROLE hr_rep",
+ want: &DdlStatement{Ddl: "REVOKE SELECT ON TABLE employees FROM ROLE hr_rep"},
+ },
{
desc: "ALTER STATISTICS statement",
input: "ALTER STATISTICS package SET OPTIONS (allow_gc = false)",