{"action":"created","issue":{"url":"https://api.github.com/repos/influxdata/influxdb/issues/6004","repository_url":"https://api.github.com/repos/influxdata/influxdb","labels_url":"https://api.github.com/repos/influxdata/influxdb/issues/6004/labels{/name}","comments_url":"https://api.github.com/repos/influxdata/influxdb/issues/6004/comments","events_url":"https://api.github.com/repos/influxdata/influxdb/issues/6004/events","html_url":"https://github.com/influxdata/influxdb/pull/6004","id":140713660,"number":6004,"title":"Properly handle semi-colons as part of the main query loop","user":{"login":"jsternberg","id":1212129,"avatar_url":"https://avatars.githubusercontent.com/u/1212129?v=3","gravatar_id":"","url":"https://api.github.com/users/jsternberg","html_url":"https://github.com/jsternberg","followers_url":"https://api.github.com/users/jsternberg/followers","following_url":"https://api.github.com/users/jsternberg/following{/other_user}","gists_url":"https://api.github.com/users/jsternberg/gists{/gist_id}","starred_url":"https://api.github.com/users/jsternberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsternberg/subscriptions","organizations_url":"https://api.github.com/users/jsternberg/orgs","repos_url":"https://api.github.com/users/jsternberg/repos","events_url":"https://api.github.com/users/jsternberg/events{/privacy}","received_events_url":"https://api.github.com/users/jsternberg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/influxdata/influxdb/milestones/47","html_url":"https://github.com/influxdata/influxdb/milestones/0.12.0","labels_url":"https://api.github.com/repos/influxdata/influxdb/milestones/47/labels","id":1586959,"number":47,"title":"0.12.0","description":null,"creator":{"login":"jsternberg","id":1212129,"avatar_url":"https://avatars.githubusercontent.com/u/1212129?v=3","gravatar_id":"","url":"https://api.github.com/users/jsternberg","html_url":"https://github.com/jsternberg","followers_url":"https://api.github.com/users/jsternberg/followers","following_url":"https://api.github.com/users/jsternberg/following{/other_user}","gists_url":"https://api.github.com/users/jsternberg/gists{/gist_id}","starred_url":"https://api.github.com/users/jsternberg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsternberg/subscriptions","organizations_url":"https://api.github.com/users/jsternberg/orgs","repos_url":"https://api.github.com/users/jsternberg/repos","events_url":"https://api.github.com/users/jsternberg/events{/privacy}","received_events_url":"https://api.github.com/users/jsternberg/received_events","type":"User","site_admin":false},"open_issues":23,"closed_issues":16,"state":"open","created_at":"2016-02-16T21:27:28Z","updated_at":"2016-03-22T18:31:22Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-03-14T15:49:51Z","updated_at":"2016-03-22T19:11:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/influxdata/influxdb/pulls/6004","html_url":"https://github.com/influxdata/influxdb/pull/6004","diff_url":"https://github.com/influxdata/influxdb/pull/6004.diff","patch_url":"https://github.com/influxdata/influxdb/pull/6004.patch"},"body":"Semi-colons are now processed correctly as part of the grammar and newlines,\nwhen used at the end of a command, will be treated as a semi-colon.\n\nFixes #5728."},"comment":{"url":"https://api.github.com/repos/influxdata/influxdb/issues/comments/199969280","html_url":"https://github.com/influxdata/influxdb/pull/6004#issuecomment-199969280","issue_url":"https://api.github.com/repos/influxdata/influxdb/issues/6004","id":199969280,"user":{"login":"dgnorton","id":209347,"avatar_url":"https://avatars.githubusercontent.com/u/209347?v=3","gravatar_id":"","url":"https://api.github.com/users/dgnorton","html_url":"https://github.com/dgnorton","followers_url":"https://api.github.com/users/dgnorton/followers","following_url":"https://api.github.com/users/dgnorton/following{/other_user}","gists_url":"https://api.github.com/users/dgnorton/gists{/gist_id}","starred_url":"https://api.github.com/users/dgnorton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgnorton/subscriptions","organizations_url":"https://api.github.com/users/dgnorton/orgs","repos_url":"https://api.github.com/users/dgnorton/repos","events_url":"https://api.github.com/users/dgnorton/events{/privacy}","received_events_url":"https://api.github.com/users/dgnorton/received_events","type":"User","site_admin":false},"created_at":"2016-03-22T19:11:28Z","updated_at":"2016-03-22T19:11:28Z","body":"I think most other SQL DBs require `;` between statements even if separated by `\\n`. Interpreting `\\n` as `;` prevents files like:\r\n```\r\nSELECT count(value) FROM cpu\r\n   WHERE time > now() - 1h\r\n   GROUP BY time(1m);\r\n\r\nSELECT...\r\n```\r\nHow about refactoring the main loop like this?:\r\n\r\n```\r\n    var expectSemi bool\r\n\r\n\tfor {\r\n\t\ttok, pos, lit := p.scanIgnoreWhitespace()\r\n\t\tswitch tok {\r\n\t\tcase EOF:\r\n\t\t\treturn &Query{Statements: statements}, nil\r\n\t\tcase SEMICOLON:\r\n\t\t\tif !expectSemi {\r\n\t\t\t\treturn nil, newParseError(tokstr(tok, lit), []string{\"SELECT\", \"DELETE\", \"SHOW\", \"CREATE\", \"DROP\", \"GRANT\", \"REVOKE\", \"ALTER\", \"SET\", \"KILL\"}, pos)\r\n\t\t\t}\r\n\t\t\texpectSemi = false\r\n\t\tdefault:\r\n\t\t\tif expectSemi {\r\n\t\t\t\treturn nil, newParseError(tokstr(tok, lit), []string{\";\"}, pos)\r\n\t\t\t}\r\n\t\t\tp.unscan()\r\n\t\t\ts, err := p.ParseStatement()\r\n\t\t\tif err != nil {\r\n\t\t\t\treturn nil, err\r\n\t\t\t}\r\n\t\t\tstatements = append(statements, s)\r\n\t\t\texpectSemi = true\r\n\t\t}\r\n\t}\r\n```"}}