Skip to content

Commit

Permalink
Renamed RetentionPolicyExists to RetentionPolicyCreate.
Browse files Browse the repository at this point in the history
  • Loading branch information
pires committed Nov 28, 2015
1 parent 8e2868e commit 30cc133
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions influxql/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ type CreateDatabaseStatement struct {
// already exists.
IfNotExists bool

// RetentionPolicyExists indicates whether the user explicitly wants to create a retention policy
RetentionPolicyExists bool
// RetentionPolicyCreate indicates whether the user explicitly wants to create a retention policy
RetentionPolicyCreate bool

// RetentionPolicyDuration indicates retention duration for the new database
RetentionPolicyDuration time.Duration
Expand All @@ -342,7 +342,7 @@ func (s *CreateDatabaseStatement) String() string {
_, _ = buf.WriteString("IF NOT EXISTS ")
}
_, _ = buf.WriteString(QuoteIdent(s.Name))
if s.RetentionPolicyExists {
if s.RetentionPolicyCreate {
_, _ = buf.WriteString("WITH DURATION ")
_, _ = buf.WriteString(s.RetentionPolicyDuration.String())
_, _ = buf.WriteString("REPLICATION ")
Expand Down
4 changes: 2 additions & 2 deletions influxql/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1467,8 +1467,8 @@ func (p *Parser) parseCreateDatabaseStatement() (*CreateDatabaseStatement, error
// rewind
p.unscan()

// mark statement as having a RetentionPolicyInfo define
stmt.RetentionPolicyExists = true
// mark statement as having a RetentionPolicyInfo defined
stmt.RetentionPolicyCreate = true

// Look for "DURATION"
var rpDuration time.Duration // default is forever
Expand Down
20 changes: 10 additions & 10 deletions influxql/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1178,23 +1178,23 @@ func TestParser_ParseStatement(t *testing.T) {
stmt: &influxql.CreateDatabaseStatement{
Name: "testdb",
IfNotExists: false,
RetentionPolicyExists: false,
RetentionPolicyCreate: false,
},
},
{
s: `CREATE DATABASE IF NOT EXISTS testdb`,
stmt: &influxql.CreateDatabaseStatement{
Name: "testdb",
IfNotExists: true,
RetentionPolicyExists: false,
RetentionPolicyCreate: false,
},
},
{
s: `CREATE DATABASE testdb WITH DURATION 24h`,
stmt: &influxql.CreateDatabaseStatement{
Name: "testdb",
IfNotExists: false,
RetentionPolicyExists: true,
RetentionPolicyCreate: true,
RetentionPolicyDuration: 24 * time.Hour,
RetentionPolicyReplication: 1,
RetentionPolicyName: "default",
Expand All @@ -1205,7 +1205,7 @@ func TestParser_ParseStatement(t *testing.T) {
stmt: &influxql.CreateDatabaseStatement{
Name: "testdb",
IfNotExists: true,
RetentionPolicyExists: true,
RetentionPolicyCreate: true,
RetentionPolicyDuration: 24 * time.Hour,
RetentionPolicyReplication: 1,
RetentionPolicyName: "default",
Expand All @@ -1216,7 +1216,7 @@ func TestParser_ParseStatement(t *testing.T) {
stmt: &influxql.CreateDatabaseStatement{
Name: "testdb",
IfNotExists: false,
RetentionPolicyExists: true,
RetentionPolicyCreate: true,
RetentionPolicyDuration: 0,
RetentionPolicyReplication: 2,
RetentionPolicyName: "default",
Expand All @@ -1227,7 +1227,7 @@ func TestParser_ParseStatement(t *testing.T) {
stmt: &influxql.CreateDatabaseStatement{
Name: "testdb",
IfNotExists: true,
RetentionPolicyExists: true,
RetentionPolicyCreate: true,
RetentionPolicyDuration: 0,
RetentionPolicyReplication: 2,
RetentionPolicyName: "default",
Expand All @@ -1238,7 +1238,7 @@ func TestParser_ParseStatement(t *testing.T) {
stmt: &influxql.CreateDatabaseStatement{
Name: "testdb",
IfNotExists: false,
RetentionPolicyExists: true,
RetentionPolicyCreate: true,
RetentionPolicyDuration: 0,
RetentionPolicyReplication: 1,
RetentionPolicyName: "test_name",
Expand All @@ -1249,7 +1249,7 @@ func TestParser_ParseStatement(t *testing.T) {
stmt: &influxql.CreateDatabaseStatement{
Name: "testdb",
IfNotExists: true,
RetentionPolicyExists: true,
RetentionPolicyCreate: true,
RetentionPolicyDuration: 0,
RetentionPolicyReplication: 1,
RetentionPolicyName: "test_name",
Expand All @@ -1260,7 +1260,7 @@ func TestParser_ParseStatement(t *testing.T) {
stmt: &influxql.CreateDatabaseStatement{
Name: "testdb",
IfNotExists: false,
RetentionPolicyExists: true,
RetentionPolicyCreate: true,
RetentionPolicyDuration: 24 * time.Hour,
RetentionPolicyReplication: 2,
RetentionPolicyName: "test_name",
Expand All @@ -1271,7 +1271,7 @@ func TestParser_ParseStatement(t *testing.T) {
stmt: &influxql.CreateDatabaseStatement{
Name: "testdb",
IfNotExists: true,
RetentionPolicyExists: true,
RetentionPolicyCreate: true,
RetentionPolicyDuration: 24 * time.Hour,
RetentionPolicyReplication: 2,
RetentionPolicyName: "test_name",
Expand Down
2 changes: 1 addition & 1 deletion meta/statement_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (e *StatementExecutor) ExecuteStatement(stmt influxql.Statement) *influxql.

func (e *StatementExecutor) executeCreateDatabaseStatement(q *influxql.CreateDatabaseStatement) *influxql.Result {
var err error
if q.RetentionPolicyExists {
if q.RetentionPolicyCreate {
rpi := NewRetentionPolicyInfo(q.RetentionPolicyName)
rpi.Duration = q.RetentionPolicyDuration
rpi.ReplicaN = q.RetentionPolicyReplication
Expand Down

0 comments on commit 30cc133

Please sign in to comment.