{"action":"created","issue":{"url":"https://api.github.com/repos/cockroachdb/cockroach/issues/5833","repository_url":"https://api.github.com/repos/cockroachdb/cockroach","labels_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/5833/labels{/name}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/5833/comments","events_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/5833/events","html_url":"https://github.com/cockroachdb/cockroach/issues/5833","id":145607519,"number":5833,"title":"sql: bad query puts connection in invalid state","user":{"login":"tschottdorf","id":5076964,"avatar_url":"https://avatars.githubusercontent.com/u/5076964?v=3","gravatar_id":"","url":"https://api.github.com/users/tschottdorf","html_url":"https://github.com/tschottdorf","followers_url":"https://api.github.com/users/tschottdorf/followers","following_url":"https://api.github.com/users/tschottdorf/following{/other_user}","gists_url":"https://api.github.com/users/tschottdorf/gists{/gist_id}","starred_url":"https://api.github.com/users/tschottdorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tschottdorf/subscriptions","organizations_url":"https://api.github.com/users/tschottdorf/orgs","repos_url":"https://api.github.com/users/tschottdorf/repos","events_url":"https://api.github.com/users/tschottdorf/events{/privacy}","received_events_url":"https://api.github.com/users/tschottdorf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"RaduBerinde","id":16544120,"avatar_url":"https://avatars.githubusercontent.com/u/16544120?v=3","gravatar_id":"","url":"https://api.github.com/users/RaduBerinde","html_url":"https://github.com/RaduBerinde","followers_url":"https://api.github.com/users/RaduBerinde/followers","following_url":"https://api.github.com/users/RaduBerinde/following{/other_user}","gists_url":"https://api.github.com/users/RaduBerinde/gists{/gist_id}","starred_url":"https://api.github.com/users/RaduBerinde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RaduBerinde/subscriptions","organizations_url":"https://api.github.com/users/RaduBerinde/orgs","repos_url":"https://api.github.com/users/RaduBerinde/repos","events_url":"https://api.github.com/users/RaduBerinde/events{/privacy}","received_events_url":"https://api.github.com/users/RaduBerinde/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2016-04-04T07:30:27Z","updated_at":"2016-04-04T12:50:03Z","closed_at":null,"body":"`master` at time of writing, with standard `(id, balance)` bank table.\r\n\r\n```\r\nroot@:26257> set database = bank;\r\nSET\r\nroot@:26257> select * from (select balance from accounts where id = 3 union values(0)) as f;\r\n+---------+\r\n| balance |\r\n+---------+\r\n|       0 |\r\n+---------+\r\nroot@:26257> select from (select balance from accounts where id = 3 union values(0)) as f;\r\npq: unexpected DataRow in simple query execution\r\nroot@:26257> select * from (select balance from accounts where id = 3 union values(0)) as f;\r\ndriver: bad connection\r\nroot@:26257>\r\n```\r\n\r\nI just checked and `select from accounts` already causes the same behavior. Continuing after `bad connection` works again, but the connection loses its database setting."},"comment":{"url":"https://api.github.com/repos/cockroachdb/cockroach/issues/comments/205283272","html_url":"https://github.com/cockroachdb/cockroach/issues/5833#issuecomment-205283272","issue_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/5833","id":205283272,"user":{"login":"petermattis","id":6201335,"avatar_url":"https://avatars.githubusercontent.com/u/6201335?v=3","gravatar_id":"","url":"https://api.github.com/users/petermattis","html_url":"https://github.com/petermattis","followers_url":"https://api.github.com/users/petermattis/followers","following_url":"https://api.github.com/users/petermattis/following{/other_user}","gists_url":"https://api.github.com/users/petermattis/gists{/gist_id}","starred_url":"https://api.github.com/users/petermattis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petermattis/subscriptions","organizations_url":"https://api.github.com/users/petermattis/orgs","repos_url":"https://api.github.com/users/petermattis/repos","events_url":"https://api.github.com/users/petermattis/events{/privacy}","received_events_url":"https://api.github.com/users/petermattis/received_events","type":"User","site_admin":false},"created_at":"2016-04-04T12:50:03Z","updated_at":"2016-04-04T12:50:03Z","body":"The connection is reopened after it becomes bad, which is why the database setting is lost."}}