commit
735378842e
64
QUERIES.md
64
QUERIES.md
|
@ -73,57 +73,57 @@ DROP MEASUREMENT cpu WHERE region = 'uswest'
|
|||
List series queries are for pulling out individual series from measurement names and tag data. They're useful for discovery.
|
||||
|
||||
```sql
|
||||
-- list all databases
|
||||
LIST DATABASES
|
||||
-- show all databases
|
||||
SHOW DATABASES
|
||||
|
||||
-- list measurement names
|
||||
LIST MEASUREMENTS
|
||||
LIST MEASUREMENTS LIMIT 15
|
||||
LIST MEASUREMENTS LIMIT 10 OFFSET 40
|
||||
LIST MEASUREMENTS WHERE service = 'redis'
|
||||
-- LIMIT and OFFSET can be applied to any of the LIST type queries
|
||||
-- show measurement names
|
||||
SHOW MEASUREMENTS
|
||||
SHOW MEASUREMENTS LIMIT 15
|
||||
SHOW MEASUREMENTS LIMIT 10 OFFSET 40
|
||||
SHOW MEASUREMENTS WHERE service = 'redis'
|
||||
-- LIMIT and OFFSET can be applied to any of the SHOW type queries
|
||||
|
||||
-- list all series across all measurements/tagsets
|
||||
LIST SERIES
|
||||
-- show all series across all measurements/tagsets
|
||||
SHOW SERIES
|
||||
|
||||
-- get a list of all series for any measurements where tag key region = tak value 'uswest'
|
||||
LIST SERIES WHERE region = 'uswest'
|
||||
-- get a show of all series for any measurements where tag key region = tak value 'uswest'
|
||||
SHOW SERIES WHERE region = 'uswest'
|
||||
|
||||
LIST SERIES FROM cpu_load WHERE region = 'uswest' LIMIT 10
|
||||
SHOW SERIES FROM cpu_load WHERE region = 'uswest' LIMIT 10
|
||||
|
||||
-- returns the 100 - 109 rows in the result. In the case of LIST SERIES, which returns
|
||||
-- returns the 100 - 109 rows in the result. In the case of SHOW SERIES, which returns
|
||||
-- series split into measurements. Each series counts as a row. So you could see only a
|
||||
-- single measurement returned, but 10 series within it.
|
||||
LIST SERIES FROM cpu_load WHERE region = 'uswest' LIMIT 10 OFFSET 100
|
||||
SHOW SERIES FROM cpu_load WHERE region = 'uswest' LIMIT 10 OFFSET 100
|
||||
|
||||
-- list all retention policies on a database
|
||||
LIST RETENTION POLICIES mydb
|
||||
-- show all retention policies on a database
|
||||
SHOW RETENTION POLICIES mydb
|
||||
|
||||
-- get a list of all tag keys across all measurements
|
||||
LIST TAG KEYS
|
||||
-- get a show of all tag keys across all measurements
|
||||
SHOW TAG KEYS
|
||||
|
||||
-- list all the tag keys for a given measurement
|
||||
LIST TAG KEYS FROM cpu
|
||||
LIST TAG KEYS FROM temperature, wind_speed
|
||||
-- show all the tag keys for a given measurement
|
||||
SHOW TAG KEYS FROM cpu
|
||||
SHOW TAG KEYS FROM temperature, wind_speed
|
||||
|
||||
-- list all the tag values. note that a single WHERE TAG KEY = '...' clause is required
|
||||
LIST TAG VALUES WHERE TAG KEY = 'region'
|
||||
LIST TAG VALUES FROM cpu WHERE region = 'uswest' and TAG KEY = 'host'
|
||||
-- show all the tag values. note that a single WHERE TAG KEY = '...' clause is required
|
||||
SHOW TAG VALUES WHERE TAG KEY = 'region'
|
||||
SHOW TAG VALUES FROM cpu WHERE region = 'uswest' and TAG KEY = 'host'
|
||||
|
||||
-- and you can do stuff against fields
|
||||
LIST FIELD KEYS FROM cpu
|
||||
SHOW FIELD KEYS FROM cpu
|
||||
|
||||
-- but you can't do this
|
||||
LIST FIELD VALUES
|
||||
SHOW FIELD VALUES
|
||||
-- we don't index field values, so this query should be invalid.
|
||||
|
||||
-- list all users
|
||||
LIST USERS
|
||||
-- show all users
|
||||
SHOW USERS
|
||||
```
|
||||
|
||||
Note that `FROM` and `WHERE` are optional clauses in all of the list series queries.
|
||||
Note that `FROM` and `WHERE` are optional clauses in most of the show series queries.
|
||||
|
||||
And the list series output looks like this:
|
||||
And the show series output looks like this:
|
||||
|
||||
```json
|
||||
[
|
||||
|
@ -164,4 +164,4 @@ particularly in the case where creation is scripted.
|
|||
|
||||
## List
|
||||
|
||||
LIST CONTINUOUS QUERIES
|
||||
SHOW CONTINUOUS QUERIES
|
||||
|
|
|
@ -63,7 +63,7 @@ ALL ALTER AS ASC BEGIN BY
|
|||
CREATE CONTINUOUS DATABASE DATABASES DEFAULT DELETE
|
||||
DESC DROP DURATION END EXISTS EXPLAIN
|
||||
FIELD FROM GRANT GROUP IF INNER
|
||||
INSERT INTO KEYS LIMIT LIST MEASUREMENT
|
||||
INSERT INTO KEYS LIMIT SHOW MEASUREMENT
|
||||
MEASUREMENTS OFFSET ON ORDER PASSWORD POLICY
|
||||
POLICIES PRIVILEGES QUERIES QUERY READ REPLICATION
|
||||
RETENTION REVOKE SELECT SERIES TAG TO
|
||||
|
@ -113,16 +113,16 @@ statement = alter_retention_policy_stmt |
|
|||
drop_series_stmt |
|
||||
drop_user_stmt |
|
||||
grant_stmt |
|
||||
list_continuous_queries_stmt |
|
||||
list_databases_stmt |
|
||||
list_field_key_stmt |
|
||||
list_field_value_stmt |
|
||||
list_measurements_stmt |
|
||||
list_retention_policies |
|
||||
list_series_stmt |
|
||||
list_tag_key_stmt |
|
||||
list_tag_value_stmt |
|
||||
list_users_stmt |
|
||||
show_continuous_queries_stmt |
|
||||
show_databases_stmt |
|
||||
show_field_key_stmt |
|
||||
show_field_value_stmt |
|
||||
show_measurements_stmt |
|
||||
show_retention_policies |
|
||||
show_series_stmt |
|
||||
show_tag_key_stmt |
|
||||
show_tag_value_stmt |
|
||||
show_users_stmt |
|
||||
revoke_stmt |
|
||||
select_stmt .
|
||||
```
|
||||
|
@ -281,43 +281,43 @@ GRANT ALL TO jdoe;
|
|||
GRANT READ ON mydb TO jdoe;
|
||||
```
|
||||
|
||||
### LIST DATABASES
|
||||
### SHOW DATABASES
|
||||
|
||||
```
|
||||
list_databases_stmt = "LIST DATABASES" .
|
||||
show_databases_stmt = "SHOW DATABASES" .
|
||||
```
|
||||
|
||||
#### Example:
|
||||
|
||||
```sql
|
||||
-- list all databases
|
||||
LIST DATABASES;
|
||||
-- show all databases
|
||||
SHOW DATABASES;
|
||||
```
|
||||
|
||||
### LIST RETENTION POLICIES
|
||||
### SHOW RETENTION POLICIES
|
||||
|
||||
```
|
||||
list_retention_policies = "LIST RETENTION POLICIES" db_name .
|
||||
show_retention_policies = "SHOW RETENTION POLICIES" db_name .
|
||||
```
|
||||
|
||||
#### Example:
|
||||
|
||||
```sql
|
||||
-- list all retention policies on a database
|
||||
LIST RETENTION POLICIES mydb;
|
||||
-- show all retention policies on a database
|
||||
SHOW RETENTION POLICIES mydb;
|
||||
```
|
||||
|
||||
### LIST USERS
|
||||
### SHOW USERS
|
||||
|
||||
```
|
||||
list_users_stmt = "LIST USERS" .
|
||||
show_users_stmt = "SHOW USERS" .
|
||||
```
|
||||
|
||||
#### Example:
|
||||
|
||||
```sql
|
||||
-- list all users
|
||||
LIST USERS;
|
||||
-- show all users
|
||||
SHOW USERS;
|
||||
```
|
||||
|
||||
## Clauses
|
||||
|
|
160
influxql/ast.go
160
influxql/ast.go
|
@ -59,16 +59,16 @@ func (_ *DropRetentionPolicyStatement) node() {}
|
|||
func (_ *DropSeriesStatement) node() {}
|
||||
func (_ *DropUserStatement) node() {}
|
||||
func (_ *GrantStatement) node() {}
|
||||
func (_ *ListContinuousQueriesStatement) node() {}
|
||||
func (_ *ListDatabasesStatement) node() {}
|
||||
func (_ *ListFieldKeysStatement) node() {}
|
||||
func (_ *ListFieldValuesStatement) node() {}
|
||||
func (_ *ListRetentionPoliciesStatement) node() {}
|
||||
func (_ *ListMeasurementsStatement) node() {}
|
||||
func (_ *ListSeriesStatement) node() {}
|
||||
func (_ *ListTagKeysStatement) node() {}
|
||||
func (_ *ListTagValuesStatement) node() {}
|
||||
func (_ *ListUsersStatement) node() {}
|
||||
func (_ *ShowContinuousQueriesStatement) node() {}
|
||||
func (_ *ShowDatabasesStatement) node() {}
|
||||
func (_ *ShowFieldKeysStatement) node() {}
|
||||
func (_ *ShowFieldValuesStatement) node() {}
|
||||
func (_ *ShowRetentionPoliciesStatement) node() {}
|
||||
func (_ *ShowMeasurementsStatement) node() {}
|
||||
func (_ *ShowSeriesStatement) node() {}
|
||||
func (_ *ShowTagKeysStatement) node() {}
|
||||
func (_ *ShowTagValuesStatement) node() {}
|
||||
func (_ *ShowUsersStatement) node() {}
|
||||
func (_ *RevokeStatement) node() {}
|
||||
func (_ *SelectStatement) node() {}
|
||||
|
||||
|
@ -147,16 +147,16 @@ func (_ *DropRetentionPolicyStatement) stmt() {}
|
|||
func (_ *DropSeriesStatement) stmt() {}
|
||||
func (_ *DropUserStatement) stmt() {}
|
||||
func (_ *GrantStatement) stmt() {}
|
||||
func (_ *ListContinuousQueriesStatement) stmt() {}
|
||||
func (_ *ListDatabasesStatement) stmt() {}
|
||||
func (_ *ListFieldKeysStatement) stmt() {}
|
||||
func (_ *ListFieldValuesStatement) stmt() {}
|
||||
func (_ *ListMeasurementsStatement) stmt() {}
|
||||
func (_ *ListRetentionPoliciesStatement) stmt() {}
|
||||
func (_ *ListSeriesStatement) stmt() {}
|
||||
func (_ *ListTagKeysStatement) stmt() {}
|
||||
func (_ *ListTagValuesStatement) stmt() {}
|
||||
func (_ *ListUsersStatement) stmt() {}
|
||||
func (_ *ShowContinuousQueriesStatement) stmt() {}
|
||||
func (_ *ShowDatabasesStatement) stmt() {}
|
||||
func (_ *ShowFieldKeysStatement) stmt() {}
|
||||
func (_ *ShowFieldValuesStatement) stmt() {}
|
||||
func (_ *ShowMeasurementsStatement) stmt() {}
|
||||
func (_ *ShowRetentionPoliciesStatement) stmt() {}
|
||||
func (_ *ShowSeriesStatement) stmt() {}
|
||||
func (_ *ShowTagKeysStatement) stmt() {}
|
||||
func (_ *ShowTagValuesStatement) stmt() {}
|
||||
func (_ *ShowUsersStatement) stmt() {}
|
||||
func (_ *RevokeStatement) stmt() {}
|
||||
func (_ *SelectStatement) stmt() {}
|
||||
|
||||
|
@ -769,8 +769,8 @@ func (s *DeleteStatement) RequiredPrivileges() ExecutionPrivileges {
|
|||
return ExecutionPrivileges{{Name: "", Privilege: WritePrivilege}}
|
||||
}
|
||||
|
||||
// ListSeriesStatement represents a command for listing series in the database.
|
||||
type ListSeriesStatement struct {
|
||||
// ShowSeriesStatement represents a command for listing series in the database.
|
||||
type ShowSeriesStatement struct {
|
||||
// An expression evaluated on a series name or tag.
|
||||
Condition Expr
|
||||
|
||||
|
@ -786,9 +786,9 @@ type ListSeriesStatement struct {
|
|||
}
|
||||
|
||||
// String returns a string representation of the list series statement.
|
||||
func (s *ListSeriesStatement) String() string {
|
||||
func (s *ShowSeriesStatement) String() string {
|
||||
var buf bytes.Buffer
|
||||
_, _ = buf.WriteString("LIST SERIES")
|
||||
_, _ = buf.WriteString("SHOW SERIES")
|
||||
|
||||
if s.Condition != nil {
|
||||
_, _ = buf.WriteString(" WHERE ")
|
||||
|
@ -809,8 +809,8 @@ func (s *ListSeriesStatement) String() string {
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
// RequiredPrivilege returns the privilege required to execute a ListSeriesStatement.
|
||||
func (s *ListSeriesStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
// RequiredPrivilege returns the privilege required to execute a ShowSeriesStatement.
|
||||
func (s *ShowSeriesStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
return ExecutionPrivileges{{Name: "", Privilege: ReadPrivilege}}
|
||||
}
|
||||
|
||||
|
@ -827,25 +827,25 @@ func (s DropSeriesStatement) RequiredPrivileges() ExecutionPrivileges {
|
|||
return ExecutionPrivileges{{Name: "", Privilege: WritePrivilege}}
|
||||
}
|
||||
|
||||
// ListContinuousQueriesStatement represents a command for listing continuous queries.
|
||||
type ListContinuousQueriesStatement struct{}
|
||||
// ShowContinuousQueriesStatement represents a command for listing continuous queries.
|
||||
type ShowContinuousQueriesStatement struct{}
|
||||
|
||||
// String returns a string representation of the list continuous queries statement.
|
||||
func (s *ListContinuousQueriesStatement) String() string { return "LIST CONTINUOUS QUERIES" }
|
||||
func (s *ShowContinuousQueriesStatement) String() string { return "SHOW CONTINUOUS QUERIES" }
|
||||
|
||||
// RequiredPrivilege returns the privilege required to execute a ListContinuousQueriesStatement.
|
||||
func (s *ListContinuousQueriesStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
// RequiredPrivilege returns the privilege required to execute a ShowContinuousQueriesStatement.
|
||||
func (s *ShowContinuousQueriesStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
return ExecutionPrivileges{{Name: "", Privilege: ReadPrivilege}}
|
||||
}
|
||||
|
||||
// ListDatabasesStatement represents a command for listing all databases in the cluster.
|
||||
type ListDatabasesStatement struct{}
|
||||
// ShowDatabasesStatement represents a command for listing all databases in the cluster.
|
||||
type ShowDatabasesStatement struct{}
|
||||
|
||||
// String returns a string representation of the list databases command.
|
||||
func (s *ListDatabasesStatement) String() string { return "LIST DATABASES" }
|
||||
func (s *ShowDatabasesStatement) String() string { return "SHOW DATABASES" }
|
||||
|
||||
// RequiredPrivilege returns the privilege required to execute a ListDatabasesStatement
|
||||
func (s *ListDatabasesStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
// RequiredPrivilege returns the privilege required to execute a ShowDatabasesStatement
|
||||
func (s *ShowDatabasesStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
return ExecutionPrivileges{{Name: "", Privilege: AllPrivileges}}
|
||||
}
|
||||
|
||||
|
@ -901,8 +901,8 @@ func (s *DropContinuousQueryStatement) RequiredPrivileges() ExecutionPrivileges
|
|||
return ExecutionPrivileges{{Name: "", Privilege: WritePrivilege}}
|
||||
}
|
||||
|
||||
// ListMeasurementsStatement represents a command for listing measurements.
|
||||
type ListMeasurementsStatement struct {
|
||||
// ShowMeasurementsStatement represents a command for listing measurements.
|
||||
type ShowMeasurementsStatement struct {
|
||||
// An expression evaluated on data point.
|
||||
Condition Expr
|
||||
|
||||
|
@ -918,9 +918,9 @@ type ListMeasurementsStatement struct {
|
|||
}
|
||||
|
||||
// String returns a string representation of the statement.
|
||||
func (s *ListMeasurementsStatement) String() string {
|
||||
func (s *ShowMeasurementsStatement) String() string {
|
||||
var buf bytes.Buffer
|
||||
_, _ = buf.WriteString("LIST MEASUREMENTS")
|
||||
_, _ = buf.WriteString("SHOW MEASUREMENTS")
|
||||
|
||||
if s.Condition != nil {
|
||||
_, _ = buf.WriteString(" WHERE ")
|
||||
|
@ -941,32 +941,32 @@ func (s *ListMeasurementsStatement) String() string {
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
// RequiredPrivileges returns the privilege(s) required to execute a ListMeasurementsStatement
|
||||
func (s *ListMeasurementsStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
// RequiredPrivileges returns the privilege(s) required to execute a ShowMeasurementsStatement
|
||||
func (s *ShowMeasurementsStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
return ExecutionPrivileges{{Name: "", Privilege: ReadPrivilege}}
|
||||
}
|
||||
|
||||
// ListRetentionPoliciesStatement represents a command for listing retention policies.
|
||||
type ListRetentionPoliciesStatement struct {
|
||||
// ShowRetentionPoliciesStatement represents a command for listing retention policies.
|
||||
type ShowRetentionPoliciesStatement struct {
|
||||
// Name of the database to list policies for.
|
||||
Database string
|
||||
}
|
||||
|
||||
// String returns a string representation of a ListRetentionPoliciesStatement.
|
||||
func (s *ListRetentionPoliciesStatement) String() string {
|
||||
// String returns a string representation of a ShowRetentionPoliciesStatement.
|
||||
func (s *ShowRetentionPoliciesStatement) String() string {
|
||||
var buf bytes.Buffer
|
||||
_, _ = buf.WriteString("LIST RETENTION POLICIES ")
|
||||
_, _ = buf.WriteString("SHOW RETENTION POLICIES ")
|
||||
_, _ = buf.WriteString(s.Database)
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// RequiredPrivileges returns the privilege(s) required to execute a ListRetentionPoliciesStatement
|
||||
func (s *ListRetentionPoliciesStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
// RequiredPrivileges returns the privilege(s) required to execute a ShowRetentionPoliciesStatement
|
||||
func (s *ShowRetentionPoliciesStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
return ExecutionPrivileges{{Name: "", Privilege: ReadPrivilege}}
|
||||
}
|
||||
|
||||
// ListTagKeysStatement represents a command for listing tag keys.
|
||||
type ListTagKeysStatement struct {
|
||||
// ShowTagKeysStatement represents a command for listing tag keys.
|
||||
type ShowTagKeysStatement struct {
|
||||
// Data source that fields are extracted from.
|
||||
Source Source
|
||||
|
||||
|
@ -985,9 +985,9 @@ type ListTagKeysStatement struct {
|
|||
}
|
||||
|
||||
// String returns a string representation of the statement.
|
||||
func (s *ListTagKeysStatement) String() string {
|
||||
func (s *ShowTagKeysStatement) String() string {
|
||||
var buf bytes.Buffer
|
||||
_, _ = buf.WriteString("LIST TAG KEYS")
|
||||
_, _ = buf.WriteString("SHOW TAG KEYS")
|
||||
|
||||
if s.Source != nil {
|
||||
_, _ = buf.WriteString(" FROM ")
|
||||
|
@ -1012,13 +1012,13 @@ func (s *ListTagKeysStatement) String() string {
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
// RequiredPrivileges returns the privilege(s) required to execute a ListTagKeysStatement
|
||||
func (s *ListTagKeysStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
// RequiredPrivileges returns the privilege(s) required to execute a ShowTagKeysStatement
|
||||
func (s *ShowTagKeysStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
return ExecutionPrivileges{{Name: "", Privilege: ReadPrivilege}}
|
||||
}
|
||||
|
||||
// ListTagValuesStatement represents a command for listing tag values.
|
||||
type ListTagValuesStatement struct {
|
||||
// ShowTagValuesStatement represents a command for listing tag values.
|
||||
type ShowTagValuesStatement struct {
|
||||
// Data source that fields are extracted from.
|
||||
Source Source
|
||||
|
||||
|
@ -1037,9 +1037,9 @@ type ListTagValuesStatement struct {
|
|||
}
|
||||
|
||||
// String returns a string representation of the statement.
|
||||
func (s *ListTagValuesStatement) String() string {
|
||||
func (s *ShowTagValuesStatement) String() string {
|
||||
var buf bytes.Buffer
|
||||
_, _ = buf.WriteString("LIST TAG VALUES")
|
||||
_, _ = buf.WriteString("SHOW TAG VALUES")
|
||||
|
||||
if s.Source != nil {
|
||||
_, _ = buf.WriteString(" FROM ")
|
||||
|
@ -1064,26 +1064,26 @@ func (s *ListTagValuesStatement) String() string {
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
// RequiredPrivileges returns the privilege(s) required to execute a ListTagValuesStatement
|
||||
func (s *ListTagValuesStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
// RequiredPrivileges returns the privilege(s) required to execute a ShowTagValuesStatement
|
||||
func (s *ShowTagValuesStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
return ExecutionPrivileges{{Name: "", Privilege: ReadPrivilege}}
|
||||
}
|
||||
|
||||
// ListUsersStatement represents a command for listing users.
|
||||
type ListUsersStatement struct{}
|
||||
// ShowUsersStatement represents a command for listing users.
|
||||
type ShowUsersStatement struct{}
|
||||
|
||||
// String retuns a string representation of the ListUsersStatement.
|
||||
func (s *ListUsersStatement) String() string {
|
||||
return "LIST USERS"
|
||||
// String retuns a string representation of the ShowUsersStatement.
|
||||
func (s *ShowUsersStatement) String() string {
|
||||
return "SHOW USERS"
|
||||
}
|
||||
|
||||
// RequiredPrivileges returns the privilege(s) required to execute a ListUsersStatement
|
||||
func (s *ListUsersStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
// RequiredPrivileges returns the privilege(s) required to execute a ShowUsersStatement
|
||||
func (s *ShowUsersStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
return ExecutionPrivileges{{Name: "", Privilege: AllPrivileges}}
|
||||
}
|
||||
|
||||
// ListFieldKeyStatement represents a command for listing field keys.
|
||||
type ListFieldKeysStatement struct {
|
||||
// ShowFieldKeyStatement represents a command for listing field keys.
|
||||
type ShowFieldKeysStatement struct {
|
||||
// Data source that fields are extracted from.
|
||||
Source Source
|
||||
|
||||
|
@ -1102,9 +1102,9 @@ type ListFieldKeysStatement struct {
|
|||
}
|
||||
|
||||
// String returns a string representation of the statement.
|
||||
func (s *ListFieldKeysStatement) String() string {
|
||||
func (s *ShowFieldKeysStatement) String() string {
|
||||
var buf bytes.Buffer
|
||||
_, _ = buf.WriteString("LIST FIELD KEYS")
|
||||
_, _ = buf.WriteString("SHOW FIELD KEYS")
|
||||
|
||||
if s.Source != nil {
|
||||
_, _ = buf.WriteString(" FROM ")
|
||||
|
@ -1129,13 +1129,13 @@ func (s *ListFieldKeysStatement) String() string {
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
// RequiredPrivileges returns the privilege(s) required to execute a ListFieldKeysStatement
|
||||
func (s *ListFieldKeysStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
// RequiredPrivileges returns the privilege(s) required to execute a ShowFieldKeysStatement
|
||||
func (s *ShowFieldKeysStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
return ExecutionPrivileges{{Name: "", Privilege: ReadPrivilege}}
|
||||
}
|
||||
|
||||
// ListFieldValuesStatement represents a command for listing field values.
|
||||
type ListFieldValuesStatement struct {
|
||||
// ShowFieldValuesStatement represents a command for listing field values.
|
||||
type ShowFieldValuesStatement struct {
|
||||
// Data source that fields are extracted from.
|
||||
Source Source
|
||||
|
||||
|
@ -1154,9 +1154,9 @@ type ListFieldValuesStatement struct {
|
|||
}
|
||||
|
||||
// String returns a string representation of the statement.
|
||||
func (s *ListFieldValuesStatement) String() string {
|
||||
func (s *ShowFieldValuesStatement) String() string {
|
||||
var buf bytes.Buffer
|
||||
_, _ = buf.WriteString("LIST FIELD VALUES")
|
||||
_, _ = buf.WriteString("SHOW FIELD VALUES")
|
||||
|
||||
if s.Source != nil {
|
||||
_, _ = buf.WriteString(" FROM ")
|
||||
|
@ -1181,8 +1181,8 @@ func (s *ListFieldValuesStatement) String() string {
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
// RequiredPrivileges returns the privilege(s) required to execute a ListFieldValuesStatement
|
||||
func (s *ListFieldValuesStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
// RequiredPrivileges returns the privilege(s) required to execute a ShowFieldValuesStatement
|
||||
func (s *ShowFieldValuesStatement) RequiredPrivileges() ExecutionPrivileges {
|
||||
return ExecutionPrivileges{{Name: "", Privilege: ReadPrivilege}}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@ func (p *Parser) ParseStatement() (Statement, error) {
|
|||
return p.parseSelectStatement(targetNotRequired)
|
||||
case DELETE:
|
||||
return p.parseDeleteStatement()
|
||||
case LIST:
|
||||
return p.parseListStatement()
|
||||
case SHOW:
|
||||
return p.parseShowStatement()
|
||||
case CREATE:
|
||||
return p.parseCreateStatement()
|
||||
case DROP:
|
||||
|
@ -86,43 +86,43 @@ func (p *Parser) ParseStatement() (Statement, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// parseListStatement parses a string and returns a list statement.
|
||||
// This function assumes the LIST token has already been consumed.
|
||||
func (p *Parser) parseListStatement() (Statement, error) {
|
||||
// parseShowStatement parses a string and returns a list statement.
|
||||
// This function assumes the SHOW token has already been consumed.
|
||||
func (p *Parser) parseShowStatement() (Statement, error) {
|
||||
tok, pos, lit := p.scanIgnoreWhitespace()
|
||||
switch tok {
|
||||
case CONTINUOUS:
|
||||
return p.parseListContinuousQueriesStatement()
|
||||
return p.parseShowContinuousQueriesStatement()
|
||||
case DATABASES:
|
||||
return p.parseListDatabasesStatement()
|
||||
return p.parseShowDatabasesStatement()
|
||||
case FIELD:
|
||||
tok, pos, lit := p.scanIgnoreWhitespace()
|
||||
if tok == KEYS {
|
||||
return p.parseListFieldKeysStatement()
|
||||
return p.parseShowFieldKeysStatement()
|
||||
} else if tok == VALUES {
|
||||
return p.parseListFieldValuesStatement()
|
||||
return p.parseShowFieldValuesStatement()
|
||||
}
|
||||
return nil, newParseError(tokstr(tok, lit), []string{"KEYS", "VALUES"}, pos)
|
||||
case MEASUREMENTS:
|
||||
return p.parseListMeasurementsStatement()
|
||||
return p.parseShowMeasurementsStatement()
|
||||
case RETENTION:
|
||||
tok, pos, lit := p.scanIgnoreWhitespace()
|
||||
if tok == POLICIES {
|
||||
return p.parseListRetentionPoliciesStatement()
|
||||
return p.parseShowRetentionPoliciesStatement()
|
||||
}
|
||||
return nil, newParseError(tokstr(tok, lit), []string{"POLICIES"}, pos)
|
||||
case SERIES:
|
||||
return p.parseListSeriesStatement()
|
||||
return p.parseShowSeriesStatement()
|
||||
case TAG:
|
||||
tok, pos, lit := p.scanIgnoreWhitespace()
|
||||
if tok == KEYS {
|
||||
return p.parseListTagKeysStatement()
|
||||
return p.parseShowTagKeysStatement()
|
||||
} else if tok == VALUES {
|
||||
return p.parseListTagValuesStatement()
|
||||
return p.parseShowTagValuesStatement()
|
||||
}
|
||||
return nil, newParseError(tokstr(tok, lit), []string{"KEYS", "VALUES"}, pos)
|
||||
case USERS:
|
||||
return p.parseListUsersStatement()
|
||||
return p.parseShowUsersStatement()
|
||||
}
|
||||
|
||||
return nil, newParseError(tokstr(tok, lit), []string{"SERIES", "CONTINUOUS", "MEASUREMENTS", "TAG", "FIELD", "RETENTION"}, pos)
|
||||
|
@ -586,10 +586,10 @@ func (p *Parser) parseDeleteStatement() (*DeleteStatement, error) {
|
|||
return stmt, nil
|
||||
}
|
||||
|
||||
// parseListSeriesStatement parses a string and returns a ListSeriesStatement.
|
||||
// This function assumes the "LIST SERIES" tokens have already been consumed.
|
||||
func (p *Parser) parseListSeriesStatement() (*ListSeriesStatement, error) {
|
||||
stmt := &ListSeriesStatement{}
|
||||
// parseShowSeriesStatement parses a string and returns a ShowSeriesStatement.
|
||||
// This function assumes the "SHOW SERIES" tokens have already been consumed.
|
||||
func (p *Parser) parseShowSeriesStatement() (*ShowSeriesStatement, error) {
|
||||
stmt := &ShowSeriesStatement{}
|
||||
var err error
|
||||
|
||||
// Parse condition: "WHERE EXPR".
|
||||
|
@ -615,10 +615,10 @@ func (p *Parser) parseListSeriesStatement() (*ListSeriesStatement, error) {
|
|||
return stmt, nil
|
||||
}
|
||||
|
||||
// parseListMeasurementsStatement parses a string and returns a ListSeriesStatement.
|
||||
// This function assumes the "LIST MEASUREMENTS" tokens have already been consumed.
|
||||
func (p *Parser) parseListMeasurementsStatement() (*ListMeasurementsStatement, error) {
|
||||
stmt := &ListMeasurementsStatement{}
|
||||
// parseShowMeasurementsStatement parses a string and returns a ShowSeriesStatement.
|
||||
// This function assumes the "SHOW MEASUREMENTS" tokens have already been consumed.
|
||||
func (p *Parser) parseShowMeasurementsStatement() (*ShowMeasurementsStatement, error) {
|
||||
stmt := &ShowMeasurementsStatement{}
|
||||
var err error
|
||||
|
||||
// Parse condition: "WHERE EXPR".
|
||||
|
@ -644,10 +644,10 @@ func (p *Parser) parseListMeasurementsStatement() (*ListMeasurementsStatement, e
|
|||
return stmt, nil
|
||||
}
|
||||
|
||||
// parseListRetentionPoliciesStatement parses a string and returns a ListRetentionPoliciesStatement.
|
||||
// This function assumes the "LIST RETENTION POLICIES" tokens have been consumed.
|
||||
func (p *Parser) parseListRetentionPoliciesStatement() (*ListRetentionPoliciesStatement, error) {
|
||||
stmt := &ListRetentionPoliciesStatement{}
|
||||
// parseShowRetentionPoliciesStatement parses a string and returns a ShowRetentionPoliciesStatement.
|
||||
// This function assumes the "SHOW RETENTION POLICIES" tokens have been consumed.
|
||||
func (p *Parser) parseShowRetentionPoliciesStatement() (*ShowRetentionPoliciesStatement, error) {
|
||||
stmt := &ShowRetentionPoliciesStatement{}
|
||||
|
||||
ident, err := p.parseIdent()
|
||||
if err != nil {
|
||||
|
@ -658,10 +658,10 @@ func (p *Parser) parseListRetentionPoliciesStatement() (*ListRetentionPoliciesSt
|
|||
return stmt, nil
|
||||
}
|
||||
|
||||
// parseListTagKeysStatement parses a string and returns a ListSeriesStatement.
|
||||
// This function assumes the "LIST TAG KEYS" tokens have already been consumed.
|
||||
func (p *Parser) parseListTagKeysStatement() (*ListTagKeysStatement, error) {
|
||||
stmt := &ListTagKeysStatement{}
|
||||
// parseShowTagKeysStatement parses a string and returns a ShowSeriesStatement.
|
||||
// This function assumes the "SHOW TAG KEYS" tokens have already been consumed.
|
||||
func (p *Parser) parseShowTagKeysStatement() (*ShowTagKeysStatement, error) {
|
||||
stmt := &ShowTagKeysStatement{}
|
||||
var err error
|
||||
|
||||
// Parse source.
|
||||
|
@ -695,10 +695,10 @@ func (p *Parser) parseListTagKeysStatement() (*ListTagKeysStatement, error) {
|
|||
return stmt, nil
|
||||
}
|
||||
|
||||
// parseListTagValuesStatement parses a string and returns a ListSeriesStatement.
|
||||
// This function assumes the "LIST TAG VALUES" tokens have already been consumed.
|
||||
func (p *Parser) parseListTagValuesStatement() (*ListTagValuesStatement, error) {
|
||||
stmt := &ListTagValuesStatement{}
|
||||
// parseShowTagValuesStatement parses a string and returns a ShowSeriesStatement.
|
||||
// This function assumes the "SHOW TAG VALUES" tokens have already been consumed.
|
||||
func (p *Parser) parseShowTagValuesStatement() (*ShowTagValuesStatement, error) {
|
||||
stmt := &ShowTagValuesStatement{}
|
||||
var err error
|
||||
|
||||
// Parse source.
|
||||
|
@ -732,16 +732,16 @@ func (p *Parser) parseListTagValuesStatement() (*ListTagValuesStatement, error)
|
|||
return stmt, nil
|
||||
}
|
||||
|
||||
// parseListUsersStatement parses a string and returns a ListUsersStatement.
|
||||
// This function assumes the "LIST USERS" tokens have been consumed.
|
||||
func (p *Parser) parseListUsersStatement() (*ListUsersStatement, error) {
|
||||
return &ListUsersStatement{}, nil
|
||||
// parseShowUsersStatement parses a string and returns a ShowUsersStatement.
|
||||
// This function assumes the "SHOW USERS" tokens have been consumed.
|
||||
func (p *Parser) parseShowUsersStatement() (*ShowUsersStatement, error) {
|
||||
return &ShowUsersStatement{}, nil
|
||||
}
|
||||
|
||||
// parseListFieldKeysStatement parses a string and returns a ListSeriesStatement.
|
||||
// This function assumes the "LIST FIELD KEYS" tokens have already been consumed.
|
||||
func (p *Parser) parseListFieldKeysStatement() (*ListFieldKeysStatement, error) {
|
||||
stmt := &ListFieldKeysStatement{}
|
||||
// parseShowFieldKeysStatement parses a string and returns a ShowSeriesStatement.
|
||||
// This function assumes the "SHOW FIELD KEYS" tokens have already been consumed.
|
||||
func (p *Parser) parseShowFieldKeysStatement() (*ShowFieldKeysStatement, error) {
|
||||
stmt := &ShowFieldKeysStatement{}
|
||||
var err error
|
||||
|
||||
// Parse source.
|
||||
|
@ -775,10 +775,10 @@ func (p *Parser) parseListFieldKeysStatement() (*ListFieldKeysStatement, error)
|
|||
return stmt, nil
|
||||
}
|
||||
|
||||
// parseListFieldValuesStatement parses a string and returns a ListSeriesStatement.
|
||||
// This function assumes the "LIST FIELD VALUES" tokens have already been consumed.
|
||||
func (p *Parser) parseListFieldValuesStatement() (*ListFieldValuesStatement, error) {
|
||||
stmt := &ListFieldValuesStatement{}
|
||||
// parseShowFieldValuesStatement parses a string and returns a ShowSeriesStatement.
|
||||
// This function assumes the "SHOW FIELD VALUES" tokens have already been consumed.
|
||||
func (p *Parser) parseShowFieldValuesStatement() (*ShowFieldValuesStatement, error) {
|
||||
stmt := &ShowFieldValuesStatement{}
|
||||
var err error
|
||||
|
||||
// Parse source.
|
||||
|
@ -827,10 +827,10 @@ func (p *Parser) parseDropSeriesStatement() (*DropSeriesStatement, error) {
|
|||
return stmt, nil
|
||||
}
|
||||
|
||||
// parseListContinuousQueriesStatement parses a string and returns a ListContinuousQueriesStatement.
|
||||
// This function assumes the "LIST CONTINUOUS" tokens have already been consumed.
|
||||
func (p *Parser) parseListContinuousQueriesStatement() (*ListContinuousQueriesStatement, error) {
|
||||
stmt := &ListContinuousQueriesStatement{}
|
||||
// parseShowContinuousQueriesStatement parses a string and returns a ShowContinuousQueriesStatement.
|
||||
// This function assumes the "SHOW CONTINUOUS" tokens have already been consumed.
|
||||
func (p *Parser) parseShowContinuousQueriesStatement() (*ShowContinuousQueriesStatement, error) {
|
||||
stmt := &ShowContinuousQueriesStatement{}
|
||||
|
||||
// Expect a "QUERIES" token.
|
||||
if tok, pos, lit := p.scanIgnoreWhitespace(); tok != QUERIES {
|
||||
|
@ -840,10 +840,10 @@ func (p *Parser) parseListContinuousQueriesStatement() (*ListContinuousQueriesSt
|
|||
return stmt, nil
|
||||
}
|
||||
|
||||
// parseListDatabasesStatement parses a string and returns a ListDatabasesStatement.
|
||||
// This function assumes the "LIST DATABASE" tokens have already been consumed.
|
||||
func (p *Parser) parseListDatabasesStatement() (*ListDatabasesStatement, error) {
|
||||
stmt := &ListDatabasesStatement{}
|
||||
// parseShowDatabasesStatement parses a string and returns a ShowDatabasesStatement.
|
||||
// This function assumes the "SHOW DATABASE" tokens have already been consumed.
|
||||
func (p *Parser) parseShowDatabasesStatement() (*ShowDatabasesStatement, error) {
|
||||
stmt := &ShowDatabasesStatement{}
|
||||
return stmt, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -148,22 +148,22 @@ func TestParser_ParseStatement(t *testing.T) {
|
|||
},
|
||||
},
|
||||
|
||||
// LIST DATABASES
|
||||
// SHOW DATABASES
|
||||
{
|
||||
s: `LIST DATABASES`,
|
||||
stmt: &influxql.ListDatabasesStatement{},
|
||||
s: `SHOW DATABASES`,
|
||||
stmt: &influxql.ShowDatabasesStatement{},
|
||||
},
|
||||
|
||||
// LIST SERIES statement
|
||||
// SHOW SERIES statement
|
||||
{
|
||||
s: `LIST SERIES`,
|
||||
stmt: &influxql.ListSeriesStatement{},
|
||||
s: `SHOW SERIES`,
|
||||
stmt: &influxql.ShowSeriesStatement{},
|
||||
},
|
||||
|
||||
// LIST SERIES WHERE with ORDER BY and LIMIT
|
||||
// SHOW SERIES WHERE with ORDER BY and LIMIT
|
||||
{
|
||||
s: `LIST SERIES WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`,
|
||||
stmt: &influxql.ListSeriesStatement{
|
||||
s: `SHOW SERIES WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`,
|
||||
stmt: &influxql.ShowSeriesStatement{
|
||||
Condition: &influxql.BinaryExpr{
|
||||
Op: influxql.EQ,
|
||||
LHS: &influxql.VarRef{Val: "region"},
|
||||
|
@ -178,10 +178,10 @@ func TestParser_ParseStatement(t *testing.T) {
|
|||
},
|
||||
},
|
||||
|
||||
// LIST MEASUREMENTS WHERE with ORDER BY and LIMIT
|
||||
// SHOW MEASUREMENTS WHERE with ORDER BY and LIMIT
|
||||
{
|
||||
s: `LIST MEASUREMENTS WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`,
|
||||
stmt: &influxql.ListMeasurementsStatement{
|
||||
s: `SHOW MEASUREMENTS WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`,
|
||||
stmt: &influxql.ShowMeasurementsStatement{
|
||||
Condition: &influxql.BinaryExpr{
|
||||
Op: influxql.EQ,
|
||||
LHS: &influxql.VarRef{Val: "region"},
|
||||
|
@ -196,18 +196,18 @@ func TestParser_ParseStatement(t *testing.T) {
|
|||
},
|
||||
},
|
||||
|
||||
// LIST RETENTION POLICIES
|
||||
// SHOW RETENTION POLICIES
|
||||
{
|
||||
s: `LIST RETENTION POLICIES mydb`,
|
||||
stmt: &influxql.ListRetentionPoliciesStatement{
|
||||
s: `SHOW RETENTION POLICIES mydb`,
|
||||
stmt: &influxql.ShowRetentionPoliciesStatement{
|
||||
Database: "mydb",
|
||||
},
|
||||
},
|
||||
|
||||
// LIST TAG KEYS
|
||||
// SHOW TAG KEYS
|
||||
{
|
||||
s: `LIST TAG KEYS FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`,
|
||||
stmt: &influxql.ListTagKeysStatement{
|
||||
s: `SHOW TAG KEYS FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`,
|
||||
stmt: &influxql.ShowTagKeysStatement{
|
||||
Source: &influxql.Measurement{Name: "src"},
|
||||
Condition: &influxql.BinaryExpr{
|
||||
Op: influxql.EQ,
|
||||
|
@ -223,10 +223,10 @@ func TestParser_ParseStatement(t *testing.T) {
|
|||
},
|
||||
},
|
||||
|
||||
// LIST TAG VALUES
|
||||
// SHOW TAG VALUES
|
||||
{
|
||||
s: `LIST TAG VALUES FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`,
|
||||
stmt: &influxql.ListTagValuesStatement{
|
||||
s: `SHOW TAG VALUES FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`,
|
||||
stmt: &influxql.ShowTagValuesStatement{
|
||||
Source: &influxql.Measurement{Name: "src"},
|
||||
Condition: &influxql.BinaryExpr{
|
||||
Op: influxql.EQ,
|
||||
|
@ -242,16 +242,16 @@ func TestParser_ParseStatement(t *testing.T) {
|
|||
},
|
||||
},
|
||||
|
||||
// LIST USERS
|
||||
// SHOW USERS
|
||||
{
|
||||
s: `LIST USERS`,
|
||||
stmt: &influxql.ListUsersStatement{},
|
||||
s: `SHOW USERS`,
|
||||
stmt: &influxql.ShowUsersStatement{},
|
||||
},
|
||||
|
||||
// LIST FIELD KEYS
|
||||
// SHOW FIELD KEYS
|
||||
{
|
||||
s: `LIST FIELD KEYS FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`,
|
||||
stmt: &influxql.ListFieldKeysStatement{
|
||||
s: `SHOW FIELD KEYS FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`,
|
||||
stmt: &influxql.ShowFieldKeysStatement{
|
||||
Source: &influxql.Measurement{Name: "src"},
|
||||
Condition: &influxql.BinaryExpr{
|
||||
Op: influxql.EQ,
|
||||
|
@ -267,10 +267,10 @@ func TestParser_ParseStatement(t *testing.T) {
|
|||
},
|
||||
},
|
||||
|
||||
// LIST FIELD VALUES
|
||||
// SHOW FIELD VALUES
|
||||
{
|
||||
s: `LIST FIELD VALUES FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`,
|
||||
stmt: &influxql.ListFieldValuesStatement{
|
||||
s: `SHOW FIELD VALUES FROM src WHERE region = 'uswest' ORDER BY ASC, field1, field2 DESC LIMIT 10`,
|
||||
stmt: &influxql.ShowFieldValuesStatement{
|
||||
Source: &influxql.Measurement{Name: "src"},
|
||||
Condition: &influxql.BinaryExpr{
|
||||
Op: influxql.EQ,
|
||||
|
@ -292,10 +292,10 @@ func TestParser_ParseStatement(t *testing.T) {
|
|||
stmt: &influxql.DropSeriesStatement{Name: "myseries"},
|
||||
},
|
||||
|
||||
// LIST CONTINUOUS QUERIES statement
|
||||
// SHOW CONTINUOUS QUERIES statement
|
||||
{
|
||||
s: `LIST CONTINUOUS QUERIES`,
|
||||
stmt: &influxql.ListContinuousQueriesStatement{},
|
||||
s: `SHOW CONTINUOUS QUERIES`,
|
||||
stmt: &influxql.ShowContinuousQueriesStatement{},
|
||||
},
|
||||
|
||||
// CREATE CONTINUOUS QUERY ... INTO <measurement>
|
||||
|
@ -558,10 +558,10 @@ func TestParser_ParseStatement(t *testing.T) {
|
|||
{s: `DELETE FROM`, err: `found EOF, expected identifier at line 1, char 13`},
|
||||
{s: `DELETE FROM myseries WHERE`, err: `found EOF, expected identifier, string, number, bool at line 1, char 28`},
|
||||
{s: `DROP SERIES`, err: `found EOF, expected identifier at line 1, char 13`},
|
||||
{s: `LIST CONTINUOUS`, err: `found EOF, expected QUERIES at line 1, char 17`},
|
||||
{s: `LIST RETENTION`, err: `found EOF, expected POLICIES at line 1, char 16`},
|
||||
{s: `LIST RETENTION POLICIES`, err: `found EOF, expected identifier at line 1, char 25`},
|
||||
{s: `LIST FOO`, err: `found FOO, expected SERIES, CONTINUOUS, MEASUREMENTS, TAG, FIELD, RETENTION at line 1, char 6`},
|
||||
{s: `SHOW CONTINUOUS`, err: `found EOF, expected QUERIES at line 1, char 17`},
|
||||
{s: `SHOW RETENTION`, err: `found EOF, expected POLICIES at line 1, char 16`},
|
||||
{s: `SHOW RETENTION POLICIES`, err: `found EOF, expected identifier at line 1, char 25`},
|
||||
{s: `SHOW FOO`, err: `found FOO, expected SERIES, CONTINUOUS, MEASUREMENTS, TAG, FIELD, RETENTION at line 1, char 6`},
|
||||
{s: `DROP CONTINUOUS`, err: `found EOF, expected QUERY at line 1, char 17`},
|
||||
{s: `DROP CONTINUOUS QUERY`, err: `found EOF, expected identifier at line 1, char 23`},
|
||||
{s: `DROP FOO`, err: `found FOO, expected SERIES, CONTINUOUS at line 1, char 6`},
|
||||
|
|
|
@ -126,7 +126,7 @@ func TestScanner_Scan(t *testing.T) {
|
|||
{s: `INTO`, tok: influxql.INTO},
|
||||
{s: `KEYS`, tok: influxql.KEYS},
|
||||
{s: `LIMIT`, tok: influxql.LIMIT},
|
||||
{s: `LIST`, tok: influxql.LIST},
|
||||
{s: `SHOW`, tok: influxql.SHOW},
|
||||
{s: `MEASUREMENT`, tok: influxql.MEASUREMENT},
|
||||
{s: `MEASUREMENTS`, tok: influxql.MEASUREMENTS},
|
||||
{s: `OFFSET`, tok: influxql.OFFSET},
|
||||
|
|
|
@ -79,7 +79,7 @@ const (
|
|||
INTO
|
||||
KEYS
|
||||
LIMIT
|
||||
LIST
|
||||
SHOW
|
||||
MEASUREMENT
|
||||
MEASUREMENTS
|
||||
OFFSET
|
||||
|
@ -169,7 +169,7 @@ var tokens = [...]string{
|
|||
INTO: "INTO",
|
||||
KEYS: "KEYS",
|
||||
LIMIT: "LIMIT",
|
||||
LIST: "LIST",
|
||||
SHOW: "SHOW",
|
||||
MEASUREMENT: "MEASUREMENT",
|
||||
MEASUREMENTS: "MEASUREMENTS",
|
||||
OFFSET: "OFFSET",
|
||||
|
|
26
server.go
26
server.go
|
@ -1535,25 +1535,25 @@ func (s *Server) ExecuteQuery(q *influxql.Query, database string, user *User) Re
|
|||
res = s.executeCreateDatabaseStatement(stmt, user)
|
||||
case *influxql.DropDatabaseStatement:
|
||||
res = s.executeDropDatabaseStatement(stmt, user)
|
||||
case *influxql.ListDatabasesStatement:
|
||||
res = s.executeListDatabasesStatement(stmt, user)
|
||||
case *influxql.ShowDatabasesStatement:
|
||||
res = s.executeShowDatabasesStatement(stmt, user)
|
||||
case *influxql.CreateUserStatement:
|
||||
res = s.executeCreateUserStatement(stmt, user)
|
||||
case *influxql.DropUserStatement:
|
||||
res = s.executeDropUserStatement(stmt, user)
|
||||
case *influxql.DropSeriesStatement:
|
||||
continue
|
||||
case *influxql.ListSeriesStatement:
|
||||
case *influxql.ShowSeriesStatement:
|
||||
continue
|
||||
case *influxql.ListMeasurementsStatement:
|
||||
case *influxql.ShowMeasurementsStatement:
|
||||
continue
|
||||
case *influxql.ListTagKeysStatement:
|
||||
case *influxql.ShowTagKeysStatement:
|
||||
continue
|
||||
case *influxql.ListTagValuesStatement:
|
||||
case *influxql.ShowTagValuesStatement:
|
||||
continue
|
||||
case *influxql.ListFieldKeysStatement:
|
||||
case *influxql.ShowFieldKeysStatement:
|
||||
continue
|
||||
case *influxql.ListFieldValuesStatement:
|
||||
case *influxql.ShowFieldValuesStatement:
|
||||
continue
|
||||
case *influxql.GrantStatement:
|
||||
continue
|
||||
|
@ -1565,13 +1565,13 @@ func (s *Server) ExecuteQuery(q *influxql.Query, database string, user *User) Re
|
|||
res = s.executeAlterRetentionPolicyStatement(stmt, user)
|
||||
case *influxql.DropRetentionPolicyStatement:
|
||||
res = s.executeDropRetentionPolicyStatement(stmt, user)
|
||||
case *influxql.ListRetentionPoliciesStatement:
|
||||
res = s.executeListRetentionPoliciesStatement(stmt, user)
|
||||
case *influxql.ShowRetentionPoliciesStatement:
|
||||
res = s.executeShowRetentionPoliciesStatement(stmt, user)
|
||||
case *influxql.CreateContinuousQueryStatement:
|
||||
continue
|
||||
case *influxql.DropContinuousQueryStatement:
|
||||
continue
|
||||
case *influxql.ListContinuousQueriesStatement:
|
||||
case *influxql.ShowContinuousQueriesStatement:
|
||||
continue
|
||||
default:
|
||||
panic(fmt.Sprintf("unsupported statement type: %T", stmt))
|
||||
|
@ -1641,7 +1641,7 @@ func (s *Server) executeDropDatabaseStatement(q *influxql.DropDatabaseStatement,
|
|||
return &Result{Err: s.DeleteDatabase(q.Name)}
|
||||
}
|
||||
|
||||
func (s *Server) executeListDatabasesStatement(q *influxql.ListDatabasesStatement, user *User) *Result {
|
||||
func (s *Server) executeShowDatabasesStatement(q *influxql.ShowDatabasesStatement, user *User) *Result {
|
||||
row := &influxql.Row{Columns: []string{"Name"}}
|
||||
for _, name := range s.Databases() {
|
||||
row.Values = append(row.Values, []interface{}{name})
|
||||
|
@ -1683,7 +1683,7 @@ func (s *Server) executeDropRetentionPolicyStatement(q *influxql.DropRetentionPo
|
|||
return &Result{Err: s.DeleteRetentionPolicy(q.Database, q.Name)}
|
||||
}
|
||||
|
||||
func (s *Server) executeListRetentionPoliciesStatement(q *influxql.ListRetentionPoliciesStatement, user *User) *Result {
|
||||
func (s *Server) executeShowRetentionPoliciesStatement(q *influxql.ShowRetentionPoliciesStatement, user *User) *Result {
|
||||
a, err := s.RetentionPolicies(q.Database)
|
||||
if err != nil {
|
||||
return &Result{Err: err}
|
||||
|
|
Loading…
Reference in New Issue