Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #5077 #5186

Merged
merged 1 commit into from
Jan 8, 2016
Merged

Fixes #5077 #5186

merged 1 commit into from
Jan 8, 2016

Conversation

pires
Copy link
Contributor

@pires pires commented Dec 21, 2015

Throw an error if NAME is not provided when creating a database with retention, but something else is.

  • CHANGELOG.md updated
  • Rebased/mergable
  • Tests pass
  • Sign CLA (if not already signed)

Fixes #5077

{s: `CREATE DATABASE "testdb" WITH`, err: `found EOF, expected DURATION, REPLICATION, NAME at line 1, char 31`},
{s: `CREATE DATABASE "testdb" WITH DURATION`, err: `found EOF, expected duration at line 1, char 40`},
{s: `CREATE DATABASE "testdb" WITH REPLICATION`, err: `found EOF, expected number at line 1, char 43`},
{s: `CREATE DATABASE "testdb" WITH NAME`, err: `found EOF, expected identifier at line 1, char 36`},
{s: `CREATE DATABASE "testdb" WITH DURATION 24h REPLICATION 1 "db2"`, err: `found db2, expected NAME at line 1, char 58`},
{s: `CREATE DATABASE "testdb" WITH DURATION 24h REPLICATION 1 NAME "testrpi" "db2"`, err: `found db2, expected EOF at line 1, char 73`},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have some tests that don't quote the names?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pires -- quoting handles some edge cases in our code, and I want to make sure it doesn't confuse anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@otoolep done.

@otoolep
Copy link
Contributor

otoolep commented Dec 21, 2015

+1, thanks @pires

@corylanou @dgnorton ?

@dgnorton
Copy link
Contributor

dgnorton commented Jan 7, 2016

@pires it's a little confusing but the way this is handled is that each statement parsing method only parses the tokens it needs and leaves everything after it. In the example you gave with REPLICATION 1 presents, The bug is that parseCreateDatabase checks for the NAME token and doesn't p.unscan() when the token is anything other than NAME. It should put the token back in the stream and let the outer parsing loop handle it. Should look like...

// Look for "NAME"
var rpName string = "default" // default is default
if err := p.parseTokens([]Token{NAME}); err == nil {
   rpName, err = p.parseIdent()
   if err != nil {
      return nil, err
   }
} else {
   p.unscan()
}

@pires
Copy link
Contributor Author

pires commented Jan 7, 2016

@dgnorton @jsternberg you are right regarding p.unscan(). I will fix this over the next couple days. Thank you!

@pires
Copy link
Contributor Author

pires commented Jan 7, 2016

@dgnorton @jsternberg so I push-forced a single commit. This is enough, right?

@dgnorton
Copy link
Contributor

dgnorton commented Jan 7, 2016

@pires that should fix it. Thanks!

+1 once the tests pass

@jsternberg
Copy link
Contributor

Perfect @pires!

Can you update the changelog with your contribution and the issue it fixes?

@pires
Copy link
Contributor Author

pires commented Jan 7, 2016

Thank you all for helping with this!

@jsternberg done.

@jsternberg
Copy link
Contributor

@pires you should give yourself credit in the changelog.

Can you also squash them into a single commit? Thanks.

@pires
Copy link
Contributor Author

pires commented Jan 7, 2016

@jsternberg done! 😂

@jsternberg
Copy link
Contributor

+1 I'll merge when the tests finish running.

jsternberg added a commit that referenced this pull request Jan 8, 2016
@jsternberg jsternberg merged commit 8fc4cbe into influxdata:master Jan 8, 2016
@pires pires deleted the 5077-throw_parse_error branch January 8, 2016 09:09
@jwilder jwilder added this to the 0.10.0 milestone Feb 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants