{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/comments/43976189","id":43976189,"diff_hunk":"@@ -0,0 +1,173 @@\n+// Copyright 2015 PingCAP, Inc.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//     http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package ast\n+\n+import \"fmt\"\n+\n+// Cloner is an ast visitor that clones a node.\n+type Cloner struct {\n+}\n+\n+// Enter implements Visitor Enter interface.\n+func (c *Cloner) Enter(node Node) (Node, bool) {\n+\treturn cloneStruct(node), false\n+}\n+\n+// Leave implements Visitor Leave interface.\n+func (c *Cloner) Leave(in Node) (out Node, ok bool) {\n+\treturn in, true\n+}\n+\n+// cloneStruct clone a node's struct value, if the struct has slice\n+// the cloned value should make a new slice and copy old slice to new slice.\n+func cloneStruct(in Node) (out Node) {\n+\tswitch v := in.(type) {\n+\tcase *ValueExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *BetweenExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *BinaryOperationExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *WhenClause:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *CaseExpr:\n+\t\tnv := *v\n+\t\tnv.WhenClauses = make([]*WhenClause, len(v.WhenClauses))\n+\t\tcopy(nv.WhenClauses, v.WhenClauses)\n+\t\tout = &nv\n+\tcase *SubqueryExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *CompareSubqueryExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *ColumnName:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *ColumnNameExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *DefaultExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *IdentifierExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *ExistsSubqueryExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *PatternInExpr:\n+\t\tnv := *v\n+\t\tnv.List = make([]ExprNode, len(v.List))\n+\t\tcopy(nv.List, v.List)\n+\t\tout = &nv\n+\tcase *IsNullExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *IsTruthExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *PatternLikeExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *ParamMarkerExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *ParenthesesExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *PositionExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *PatternRegexpExpr:\n+\t\tnv := *v\n+\t\tout = &nv\n+\tcase *RowExpr:\n+\t\tnv := *v\n+\t\tnv.Values = make([]ExprNode, len(v.Values))\n+\t\tcopy(nv.Values, v.Values)","path":"ast/cloner.go","position":103,"original_position":103,"commit_id":"524e18dff1adb8a0cc4af1479f9bd94bfa6376d5","original_commit_id":"524e18dff1adb8a0cc4af1479f9bd94bfa6376d5","user":{"login":"coocood","id":891222,"avatar_url":"https://avatars.githubusercontent.com/u/891222?v=3","gravatar_id":"","url":"https://api.github.com/users/coocood","html_url":"https://github.com/coocood","followers_url":"https://api.github.com/users/coocood/followers","following_url":"https://api.github.com/users/coocood/following{/other_user}","gists_url":"https://api.github.com/users/coocood/gists{/gist_id}","starred_url":"https://api.github.com/users/coocood/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coocood/subscriptions","organizations_url":"https://api.github.com/users/coocood/orgs","repos_url":"https://api.github.com/users/coocood/repos","events_url":"https://api.github.com/users/coocood/events{/privacy}","received_events_url":"https://api.github.com/users/coocood/received_events","type":"User","site_admin":false},"body":"No, just copy the pointer.","created_at":"2015-11-05T04:48:53Z","updated_at":"2015-11-05T04:48:53Z","html_url":"https://github.com/pingcap/tidb/pull/491#discussion_r43976189","pull_request_url":"https://api.github.com/repos/pingcap/tidb/pulls/491","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments/43976189"},"html":{"href":"https://github.com/pingcap/tidb/pull/491#discussion_r43976189"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/491"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/491","id":49340580,"html_url":"https://github.com/pingcap/tidb/pull/491","diff_url":"https://github.com/pingcap/tidb/pull/491.diff","patch_url":"https://github.com/pingcap/tidb/pull/491.patch","issue_url":"https://api.github.com/repos/pingcap/tidb/issues/491","number":491,"state":"open","locked":false,"title":"ast,optimizer: switch to use new parser, and convert ast.Node to old statements.","user":{"login":"shenli","id":1192573,"avatar_url":"https://avatars.githubusercontent.com/u/1192573?v=3","gravatar_id":"","url":"https://api.github.com/users/shenli","html_url":"https://github.com/shenli","followers_url":"https://api.github.com/users/shenli/followers","following_url":"https://api.github.com/users/shenli/following{/other_user}","gists_url":"https://api.github.com/users/shenli/gists{/gist_id}","starred_url":"https://api.github.com/users/shenli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shenli/subscriptions","organizations_url":"https://api.github.com/users/shenli/orgs","repos_url":"https://api.github.com/users/shenli/repos","events_url":"https://api.github.com/users/shenli/events{/privacy}","received_events_url":"https://api.github.com/users/shenli/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-31T03:25:06Z","updated_at":"2015-11-05T04:48:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d7f1428ad92980fb5437957a21434910b2f3a895","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tidb/pulls/491/commits","review_comments_url":"https://api.github.com/repos/pingcap/tidb/pulls/491/comments","review_comment_url":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tidb/issues/491/comments","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/524e18dff1adb8a0cc4af1479f9bd94bfa6376d5","head":{"label":"pingcap:coocood/binder","ref":"coocood/binder","sha":"524e18dff1adb8a0cc4af1479f9bd94bfa6376d5","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":41986369,"name":"tidb","full_name":"pingcap/tidb","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/tidb","description":"TiDB is a distributed SQL database compatible with MySQL protocol.","fork":false,"url":"https://api.github.com/repos/pingcap/tidb","forks_url":"https://api.github.com/repos/pingcap/tidb/forks","keys_url":"https://api.github.com/repos/pingcap/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tidb/teams","hooks_url":"https://api.github.com/repos/pingcap/tidb/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tidb/events","assignees_url":"https://api.github.com/repos/pingcap/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tidb/tags","blobs_url":"https://api.github.com/repos/pingcap/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tidb/languages","stargazers_url":"https://api.github.com/repos/pingcap/tidb/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tidb/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tidb/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tidb/subscription","commits_url":"https://api.github.com/repos/pingcap/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tidb/merges","archive_url":"https://api.github.com/repos/pingcap/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tidb/downloads","issues_url":"https://api.github.com/repos/pingcap/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tidb/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tidb/releases{/id}","created_at":"2015-09-06T04:01:52Z","updated_at":"2015-11-05T03:25:46Z","pushed_at":"2015-11-05T04:27:05Z","git_url":"git://github.com/pingcap/tidb.git","ssh_url":"git@github.com:pingcap/tidb.git","clone_url":"https://github.com/pingcap/tidb.git","svn_url":"https://github.com/pingcap/tidb","homepage":"","size":13752,"stargazers_count":2761,"watchers_count":2761,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":267,"mirror_url":null,"open_issues_count":56,"forks":267,"open_issues":56,"watchers":2761,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"c49df394e110d3ce6708fcb470fec44de1fbc8fe","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"repo":{"id":41986369,"name":"tidb","full_name":"pingcap/tidb","owner":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars.githubusercontent.com/u/11855343?v=3","gravatar_id":"","url":"https://api.github.com/users/pingcap","html_url":"https://github.com/pingcap","followers_url":"https://api.github.com/users/pingcap/followers","following_url":"https://api.github.com/users/pingcap/following{/other_user}","gists_url":"https://api.github.com/users/pingcap/gists{/gist_id}","starred_url":"https://api.github.com/users/pingcap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pingcap/subscriptions","organizations_url":"https://api.github.com/users/pingcap/orgs","repos_url":"https://api.github.com/users/pingcap/repos","events_url":"https://api.github.com/users/pingcap/events{/privacy}","received_events_url":"https://api.github.com/users/pingcap/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pingcap/tidb","description":"TiDB is a distributed SQL database compatible with MySQL protocol.","fork":false,"url":"https://api.github.com/repos/pingcap/tidb","forks_url":"https://api.github.com/repos/pingcap/tidb/forks","keys_url":"https://api.github.com/repos/pingcap/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pingcap/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pingcap/tidb/teams","hooks_url":"https://api.github.com/repos/pingcap/tidb/hooks","issue_events_url":"https://api.github.com/repos/pingcap/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/pingcap/tidb/events","assignees_url":"https://api.github.com/repos/pingcap/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/pingcap/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/pingcap/tidb/tags","blobs_url":"https://api.github.com/repos/pingcap/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pingcap/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pingcap/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/pingcap/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/pingcap/tidb/languages","stargazers_url":"https://api.github.com/repos/pingcap/tidb/stargazers","contributors_url":"https://api.github.com/repos/pingcap/tidb/contributors","subscribers_url":"https://api.github.com/repos/pingcap/tidb/subscribers","subscription_url":"https://api.github.com/repos/pingcap/tidb/subscription","commits_url":"https://api.github.com/repos/pingcap/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/pingcap/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/pingcap/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/pingcap/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/pingcap/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/pingcap/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pingcap/tidb/merges","archive_url":"https://api.github.com/repos/pingcap/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pingcap/tidb/downloads","issues_url":"https://api.github.com/repos/pingcap/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/pingcap/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/pingcap/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/pingcap/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pingcap/tidb/labels{/name}","releases_url":"https://api.github.com/repos/pingcap/tidb/releases{/id}","created_at":"2015-09-06T04:01:52Z","updated_at":"2015-11-05T03:25:46Z","pushed_at":"2015-11-05T04:27:05Z","git_url":"git://github.com/pingcap/tidb.git","ssh_url":"git@github.com:pingcap/tidb.git","clone_url":"https://github.com/pingcap/tidb.git","svn_url":"https://github.com/pingcap/tidb","homepage":"","size":13752,"stargazers_count":2761,"watchers_count":2761,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":267,"mirror_url":null,"open_issues_count":56,"forks":267,"open_issues":56,"watchers":2761,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/491"},"html":{"href":"https://github.com/pingcap/tidb/pull/491"},"issue":{"href":"https://api.github.com/repos/pingcap/tidb/issues/491"},"comments":{"href":"https://api.github.com/repos/pingcap/tidb/issues/491/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/491/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/491/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tidb/statuses/524e18dff1adb8a0cc4af1479f9bd94bfa6376d5"}}}}