{"action":"closed","number":19306,"pull_request":{"url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/19306","id":146998496,"html_url":"https://github.com/cockroachdb/cockroach/pull/19306","diff_url":"https://github.com/cockroachdb/cockroach/pull/19306.diff","patch_url":"https://github.com/cockroachdb/cockroach/pull/19306.patch","issue_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/19306","number":19306,"state":"closed","locked":false,"title":"cli: fix broken output of special characters in queries","user":{"login":"knz","id":642886,"avatar_url":"https://avatars3.githubusercontent.com/u/642886?v=4","gravatar_id":"","url":"https://api.github.com/users/knz","html_url":"https://github.com/knz","followers_url":"https://api.github.com/users/knz/followers","following_url":"https://api.github.com/users/knz/following{/other_user}","gists_url":"https://api.github.com/users/knz/gists{/gist_id}","starred_url":"https://api.github.com/users/knz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knz/subscriptions","organizations_url":"https://api.github.com/users/knz/orgs","repos_url":"https://api.github.com/users/knz/repos","events_url":"https://api.github.com/users/knz/events{/privacy}","received_events_url":"https://api.github.com/users/knz/received_events","type":"User","site_admin":false},"body":"(This is the bug fix prefix to #18576. Pulling as separate PR since the other PR is likely to iterate longer.)\r\n\r\nFixes #19307.\r\nFixes #20848.\r\n\r\nPrior to this patch, the CLI tools that display SQL rows (namely,\r\n`sql`, `user`, `zone`) would make an effort to display anything with\r\nthe Unicode graphical property, and all whitespace, unchanged.\r\n\r\nAs this is the most common case, a bug slipped through: when a\r\ncharacter is neither graphical nor whitespace, it would erroneously\r\nget processed two times for escape: a first one by the low-level value\r\nformatter, and a second time by the table formatter.\r\n\r\nFor example:\r\n\r\n```\r\n> cockroach sql -e \"select e'\\x01' as x\"\r\nx\r\n\"\"\"\\x01\"\"\"\r\n(1 row)\r\n```\r\n\r\nThe triple quotes in the output were because first the ASCII 1 byte\r\nwould be escaped to the string `\"\\x01\"` (first layer of quoting), then\r\nthe TSV formatter would introduce the additional necessary CSV escapes\r\nby tripling them.\r\n\r\nThe error was that although the content of the string must be escaped\r\nby the first-level formatter, that formatter should not introduce\r\nboundary quotes -- the boundary quoting is under the responsibility of\r\nthe table formatter.\r\n\r\nWith this patch   :\r\n\r\n```\r\n> cockroach sql -e \"select e'\\x01' as x\"\r\nx\r\n\\x01\r\n(1 row)\r\n```\r\n\r\nNote that although this patch addresses the most egregious\r\nconsequences of the original bug, the approach is arguably not yet\r\ncomplete: we probably would like the SQL formatter to insert values\r\nthat are *equivalent* to those received from the server; this means\r\nthat *whether to quote or not should be decided by the formatter*.\r\nNote that only the `raw` and `sql` formatters may be interested in\r\nthis change; the more common `pretty`, `tsv`, `csv` and `records`\r\nformatter are fine as-is. A subsequent commit can introduce the\r\ncorresponding necessary plumbing.","created_at":"2017-10-17T10:21:09Z","updated_at":"2018-02-01T16:57:24Z","closed_at":"2018-02-01T16:57:24Z","merged_at":"2018-02-01T16:57:23Z","merge_commit_sha":"9d4ab74e20db542c421ad43ef03a557484f974a4","assignee":null,"assignees":[],"requested_reviewers":[{"login":"bdarnell","id":160562,"avatar_url":"https://avatars1.githubusercontent.com/u/160562?v=4","gravatar_id":"","url":"https://api.github.com/users/bdarnell","html_url":"https://github.com/bdarnell","followers_url":"https://api.github.com/users/bdarnell/followers","following_url":"https://api.github.com/users/bdarnell/following{/other_user}","gists_url":"https://api.github.com/users/bdarnell/gists{/gist_id}","starred_url":"https://api.github.com/users/bdarnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdarnell/subscriptions","organizations_url":"https://api.github.com/users/bdarnell/orgs","repos_url":"https://api.github.com/users/bdarnell/repos","events_url":"https://api.github.com/users/bdarnell/events{/privacy}","received_events_url":"https://api.github.com/users/bdarnell/received_events","type":"User","site_admin":false},{"login":"justinj","id":409075,"avatar_url":"https://avatars2.githubusercontent.com/u/409075?v=4","gravatar_id":"","url":"https://api.github.com/users/justinj","html_url":"https://github.com/justinj","followers_url":"https://api.github.com/users/justinj/followers","following_url":"https://api.github.com/users/justinj/following{/other_user}","gists_url":"https://api.github.com/users/justinj/gists{/gist_id}","starred_url":"https://api.github.com/users/justinj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinj/subscriptions","organizations_url":"https://api.github.com/users/justinj/orgs","repos_url":"https://api.github.com/users/justinj/repos","events_url":"https://api.github.com/users/justinj/events{/privacy}","received_events_url":"https://api.github.com/users/justinj/received_events","type":"User","site_admin":false}],"requested_teams":[{"name":"cli-prs","id":2437980,"slug":"cli-prs","description":"Join this team for notifications about CLI PRs","privacy":"closed","url":"https://api.github.com/teams/2437980","members_url":"https://api.github.com/teams/2437980/members{/member}","repositories_url":"https://api.github.com/teams/2437980/repos","permission":"pull"},{"name":"sql-ui-prs","id":2437981,"slug":"sql-ui-prs","description":"Join this team for notifications about SQL UI PRs","privacy":"closed","url":"https://api.github.com/teams/2437981","members_url":"https://api.github.com/teams/2437981/members{/member}","repositories_url":"https://api.github.com/teams/2437981/repos","permission":"pull"},{"name":"build-prs","id":2437990,"slug":"build-prs","description":"Join this team for notifications about build-related PRs","privacy":"closed","url":"https://api.github.com/teams/2437990","members_url":"https://api.github.com/teams/2437990/members{/member}","repositories_url":"https://api.github.com/teams/2437990/repos","permission":"pull"}],"milestone":null,"commits_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/19306/commits","review_comments_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/19306/comments","review_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/19306/comments","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/ca1eca9082c87c54b169ece1fc392f4218214545","head":{"label":"knz:20171017-fix-cli-escapes","ref":"20171017-fix-cli-escapes","sha":"ca1eca9082c87c54b169ece1fc392f4218214545","user":{"login":"knz","id":642886,"avatar_url":"https://avatars3.githubusercontent.com/u/642886?v=4","gravatar_id":"","url":"https://api.github.com/users/knz","html_url":"https://github.com/knz","followers_url":"https://api.github.com/users/knz/followers","following_url":"https://api.github.com/users/knz/following{/other_user}","gists_url":"https://api.github.com/users/knz/gists{/gist_id}","starred_url":"https://api.github.com/users/knz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knz/subscriptions","organizations_url":"https://api.github.com/users/knz/orgs","repos_url":"https://api.github.com/users/knz/repos","events_url":"https://api.github.com/users/knz/events{/privacy}","received_events_url":"https://api.github.com/users/knz/received_events","type":"User","site_admin":false},"repo":{"id":49441405,"name":"cockroach","full_name":"knz/cockroach","owner":{"login":"knz","id":642886,"avatar_url":"https://avatars3.githubusercontent.com/u/642886?v=4","gravatar_id":"","url":"https://api.github.com/users/knz","html_url":"https://github.com/knz","followers_url":"https://api.github.com/users/knz/followers","following_url":"https://api.github.com/users/knz/following{/other_user}","gists_url":"https://api.github.com/users/knz/gists{/gist_id}","starred_url":"https://api.github.com/users/knz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knz/subscriptions","organizations_url":"https://api.github.com/users/knz/orgs","repos_url":"https://api.github.com/users/knz/repos","events_url":"https://api.github.com/users/knz/events{/privacy}","received_events_url":"https://api.github.com/users/knz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/knz/cockroach","description":"A Scalable, Survivable, Strongly-Consistent SQL Database","fork":true,"url":"https://api.github.com/repos/knz/cockroach","forks_url":"https://api.github.com/repos/knz/cockroach/forks","keys_url":"https://api.github.com/repos/knz/cockroach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/knz/cockroach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/knz/cockroach/teams","hooks_url":"https://api.github.com/repos/knz/cockroach/hooks","issue_events_url":"https://api.github.com/repos/knz/cockroach/issues/events{/number}","events_url":"https://api.github.com/repos/knz/cockroach/events","assignees_url":"https://api.github.com/repos/knz/cockroach/assignees{/user}","branches_url":"https://api.github.com/repos/knz/cockroach/branches{/branch}","tags_url":"https://api.github.com/repos/knz/cockroach/tags","blobs_url":"https://api.github.com/repos/knz/cockroach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/knz/cockroach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/knz/cockroach/git/refs{/sha}","trees_url":"https://api.github.com/repos/knz/cockroach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/knz/cockroach/statuses/{sha}","languages_url":"https://api.github.com/repos/knz/cockroach/languages","stargazers_url":"https://api.github.com/repos/knz/cockroach/stargazers","contributors_url":"https://api.github.com/repos/knz/cockroach/contributors","subscribers_url":"https://api.github.com/repos/knz/cockroach/subscribers","subscription_url":"https://api.github.com/repos/knz/cockroach/subscription","commits_url":"https://api.github.com/repos/knz/cockroach/commits{/sha}","git_commits_url":"https://api.github.com/repos/knz/cockroach/git/commits{/sha}","comments_url":"https://api.github.com/repos/knz/cockroach/comments{/number}","issue_comment_url":"https://api.github.com/repos/knz/cockroach/issues/comments{/number}","contents_url":"https://api.github.com/repos/knz/cockroach/contents/{+path}","compare_url":"https://api.github.com/repos/knz/cockroach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/knz/cockroach/merges","archive_url":"https://api.github.com/repos/knz/cockroach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/knz/cockroach/downloads","issues_url":"https://api.github.com/repos/knz/cockroach/issues{/number}","pulls_url":"https://api.github.com/repos/knz/cockroach/pulls{/number}","milestones_url":"https://api.github.com/repos/knz/cockroach/milestones{/number}","notifications_url":"https://api.github.com/repos/knz/cockroach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/knz/cockroach/labels{/name}","releases_url":"https://api.github.com/repos/knz/cockroach/releases{/id}","deployments_url":"https://api.github.com/repos/knz/cockroach/deployments","created_at":"2016-01-11T17:11:07Z","updated_at":"2016-11-02T17:51:09Z","pushed_at":"2018-01-31T22:07:53Z","git_url":"git://github.com/knz/cockroach.git","ssh_url":"git@github.com:knz/cockroach.git","clone_url":"https://github.com/knz/cockroach.git","svn_url":"https://github.com/knz/cockroach","homepage":"http://www.cockroachlabs.com","size":512076,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cockroachdb:master","ref":"master","sha":"5d187ba3db3945b5cf6f358d2dab1e6b4a49bf42","user":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars3.githubusercontent.com/u/6748139?v=4","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"repo":{"id":16563587,"name":"cockroach","full_name":"cockroachdb/cockroach","owner":{"login":"cockroachdb","id":6748139,"avatar_url":"https://avatars3.githubusercontent.com/u/6748139?v=4","gravatar_id":"","url":"https://api.github.com/users/cockroachdb","html_url":"https://github.com/cockroachdb","followers_url":"https://api.github.com/users/cockroachdb/followers","following_url":"https://api.github.com/users/cockroachdb/following{/other_user}","gists_url":"https://api.github.com/users/cockroachdb/gists{/gist_id}","starred_url":"https://api.github.com/users/cockroachdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cockroachdb/subscriptions","organizations_url":"https://api.github.com/users/cockroachdb/orgs","repos_url":"https://api.github.com/users/cockroachdb/repos","events_url":"https://api.github.com/users/cockroachdb/events{/privacy}","received_events_url":"https://api.github.com/users/cockroachdb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cockroachdb/cockroach","description":"CockroachDB - the open source, cloud-native SQL database.","fork":false,"url":"https://api.github.com/repos/cockroachdb/cockroach","forks_url":"https://api.github.com/repos/cockroachdb/cockroach/forks","keys_url":"https://api.github.com/repos/cockroachdb/cockroach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cockroachdb/cockroach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cockroachdb/cockroach/teams","hooks_url":"https://api.github.com/repos/cockroachdb/cockroach/hooks","issue_events_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/events{/number}","events_url":"https://api.github.com/repos/cockroachdb/cockroach/events","assignees_url":"https://api.github.com/repos/cockroachdb/cockroach/assignees{/user}","branches_url":"https://api.github.com/repos/cockroachdb/cockroach/branches{/branch}","tags_url":"https://api.github.com/repos/cockroachdb/cockroach/tags","blobs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cockroachdb/cockroach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cockroachdb/cockroach/git/refs{/sha}","trees_url":"https://api.github.com/repos/cockroachdb/cockroach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cockroachdb/cockroach/statuses/{sha}","languages_url":"https://api.github.com/repos/cockroachdb/cockroach/languages","stargazers_url":"https://api.github.com/repos/cockroachdb/cockroach/stargazers","contributors_url":"https://api.github.com/repos/cockroachdb/cockroach/contributors","subscribers_url":"https://api.github.com/repos/cockroachdb/cockroach/subscribers","subscription_url":"https://api.github.com/repos/cockroachdb/cockroach/subscription","commits_url":"https://api.github.com/repos/cockroachdb/cockroach/commits{/sha}","git_commits_url":"https://api.github.com/repos/cockroachdb/cockroach/git/commits{/sha}","comments_url":"https://api.github.com/repos/cockroachdb/cockroach/comments{/number}","issue_comment_url":"https://api.github.com/repos/cockroachdb/cockroach/issues/comments{/number}","contents_url":"https://api.github.com/repos/cockroachdb/cockroach/contents/{+path}","compare_url":"https://api.github.com/repos/cockroachdb/cockroach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cockroachdb/cockroach/merges","archive_url":"https://api.github.com/repos/cockroachdb/cockroach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cockroachdb/cockroach/downloads","issues_url":"https://api.github.com/repos/cockroachdb/cockroach/issues{/number}","pulls_url":"https://api.github.com/repos/cockroachdb/cockroach/pulls{/number}","milestones_url":"https://api.github.com/repos/cockroachdb/cockroach/milestones{/number}","notifications_url":"https://api.github.com/repos/cockroachdb/cockroach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cockroachdb/cockroach/labels{/name}","releases_url":"https://api.github.com/repos/cockroachdb/cockroach/releases{/id}","deployments_url":"https://api.github.com/repos/cockroachdb/cockroach/deployments","created_at":"2014-02-06T00:18:47Z","updated_at":"2018-02-01T12:36:30Z","pushed_at":"2018-02-01T16:57:23Z","git_url":"git://github.com/cockroachdb/cockroach.git","ssh_url":"git@github.com:cockroachdb/cockroach.git","clone_url":"https://github.com/cockroachdb/cockroach.git","svn_url":"https://github.com/cockroachdb/cockroach","homepage":"https://www.cockroachlabs.com","size":955259,"stargazers_count":12404,"watchers_count":12404,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1275,"mirror_url":null,"archived":false,"open_issues_count":1591,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":1275,"open_issues":1591,"watchers":12404,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/19306"},"html":{"href":"https://github.com/cockroachdb/cockroach/pull/19306"},"issue":{"href":"https://api.github.com/repos/cockroachdb/cockroach/issues/19306"},"comments":{"href":"https://api.github.com/repos/cockroachdb/cockroach/issues/19306/comments"},"review_comments":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/19306/comments"},"review_comment":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cockroachdb/cockroach/pulls/19306/commits"},"statuses":{"href":"https://api.github.com/repos/cockroachdb/cockroach/statuses/ca1eca9082c87c54b169ece1fc392f4218214545"}},"author_association":"OWNER","merged":true,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":{"login":"knz","id":642886,"avatar_url":"https://avatars3.githubusercontent.com/u/642886?v=4","gravatar_id":"","url":"https://api.github.com/users/knz","html_url":"https://github.com/knz","followers_url":"https://api.github.com/users/knz/followers","following_url":"https://api.github.com/users/knz/following{/other_user}","gists_url":"https://api.github.com/users/knz/gists{/gist_id}","starred_url":"https://api.github.com/users/knz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knz/subscriptions","organizations_url":"https://api.github.com/users/knz/orgs","repos_url":"https://api.github.com/users/knz/repos","events_url":"https://api.github.com/users/knz/events{/privacy}","received_events_url":"https://api.github.com/users/knz/received_events","type":"User","site_admin":false},"comments":10,"review_comments":0,"maintainer_can_modify":false,"commits":3,"additions":473,"deletions":165,"changed_files":7}}
{"actor":{"display_login":"knz"}}