{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/comments/141238883","pull_request_review_id":65420813,"id":141238883,"diff_hunk":"@@ -886,15 +886,60 @@ func (e *InsertValues) getRows(cols []*table.Column, ignoreErr bool) (rows [][]t\n }\n \n func (e *InsertValues) getRow(cols []*table.Column, list []expression.Expression, ignoreErr bool) ([]types.Datum, error) {\n-\tvals := make([]types.Datum, len(list))\n+\t// row is a eval context, so `insert t set b = 1, a = b + 1` can eval correctly.\n+\trow := make([]types.Datum, len(e.Table.Cols()))\n+\thasValue := make([]bool, len(e.Table.Cols()))\n+\n+\t// Use fillDefaultValues init this row for eval.\n+\t// So `insert t set b = a + 1` can use the correct value of a.\n+\tif err := e.fillDefaultValues(row, hasValue, ignoreErr); err != nil {\n+\t\treturn nil, errors.Trace(err)\n+\t}\n+\n \tfor i, expr := range list {\n-\t\tval, err := expr.Eval(nil)\n-\t\tvals[i] = val\n+\t\tval, err := expr.Eval(row)\n+\t\terr = e.filterErr(err, ignoreErr)\n+\t\tif err != nil {\n+\t\t\treturn nil, errors.Trace(err)\n+\t\t}\n+\t\tval, err = table.CastValue(e.ctx, val, cols[i].ToInfo())\n+\t\terr = e.filterErr(err, ignoreErr)","path":"executor/write.go","position":24,"original_position":24,"commit_id":"13e93b9de05daf7f7ed6ed0df88ea07cd71b7dc2","original_commit_id":"13e93b9de05daf7f7ed6ed0df88ea07cd71b7dc2","user":{"login":"winkyao","id":6949944,"avatar_url":"https://avatars0.githubusercontent.com/u/6949944?v=4","gravatar_id":"","url":"https://api.github.com/users/winkyao","html_url":"https://github.com/winkyao","followers_url":"https://api.github.com/users/winkyao/followers","following_url":"https://api.github.com/users/winkyao/following{/other_user}","gists_url":"https://api.github.com/users/winkyao/gists{/gist_id}","starred_url":"https://api.github.com/users/winkyao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/winkyao/subscriptions","organizations_url":"https://api.github.com/users/winkyao/orgs","repos_url":"https://api.github.com/users/winkyao/repos","events_url":"https://api.github.com/users/winkyao/events{/privacy}","received_events_url":"https://api.github.com/users/winkyao/received_events","type":"User","site_admin":false},"body":"ditto","created_at":"2017-09-27T03:48:06Z","updated_at":"2017-09-27T03:55:08Z","html_url":"https://github.com/pingcap/tidb/pull/4603#discussion_r141238883","pull_request_url":"https://api.github.com/repos/pingcap/tidb/pulls/4603","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments/141238883"},"html":{"href":"https://github.com/pingcap/tidb/pull/4603#discussion_r141238883"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/4603"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/4603","id":142497450,"html_url":"https://github.com/pingcap/tidb/pull/4603","diff_url":"https://github.com/pingcap/tidb/pull/4603.diff","patch_url":"https://github.com/pingcap/tidb/pull/4603.patch","issue_url":"https://api.github.com/repos/pingcap/tidb/issues/4603","number":4603,"state":"open","locked":false,"title":"*: make insert with calculated value behave the same as MySQL.","user":{"login":"bobotu","id":15031522,"avatar_url":"https://avatars2.githubusercontent.com/u/15031522?v=4","gravatar_id":"","url":"https://api.github.com/users/bobotu","html_url":"https://github.com/bobotu","followers_url":"https://api.github.com/users/bobotu/followers","following_url":"https://api.github.com/users/bobotu/following{/other_user}","gists_url":"https://api.github.com/users/bobotu/gists{/gist_id}","starred_url":"https://api.github.com/users/bobotu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobotu/subscriptions","organizations_url":"https://api.github.com/users/bobotu/orgs","repos_url":"https://api.github.com/users/bobotu/repos","events_url":"https://api.github.com/users/bobotu/events{/privacy}","received_events_url":"https://api.github.com/users/bobotu/received_events","type":"User","site_admin":false},"body":"This PR try to fix most cases of #4488.\r\nNow `insert` can correctly handle calculated value based on other columns, \r\nsuch as `insert into t1 set b=a+1` and `insert into t1 (b) value (a)`.\r\nLast, as mentioned in issue, make the error message more readable.","created_at":"2017-09-22T05:01:40Z","updated_at":"2017-09-27T03:55:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"94da7b6ed18e3dd5b74a650646ccab16fbd8a5a2","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tidb/pulls/4603/commits","review_comments_url":"https://api.github.com/repos/pingcap/tidb/pulls/4603/comments","review_comment_url":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tidb/issues/4603/comments","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/13e93b9de05daf7f7ed6ed0df88ea07cd71b7dc2","head":{"label":"bobotu:iss4488","ref":"iss4488","sha":"13e93b9de05daf7f7ed6ed0df88ea07cd71b7dc2","user":{"login":"bobotu","id":15031522,"avatar_url":"https://avatars2.githubusercontent.com/u/15031522?v=4","gravatar_id":"","url":"https://api.github.com/users/bobotu","html_url":"https://github.com/bobotu","followers_url":"https://api.github.com/users/bobotu/followers","following_url":"https://api.github.com/users/bobotu/following{/other_user}","gists_url":"https://api.github.com/users/bobotu/gists{/gist_id}","starred_url":"https://api.github.com/users/bobotu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobotu/subscriptions","organizations_url":"https://api.github.com/users/bobotu/orgs","repos_url":"https://api.github.com/users/bobotu/repos","events_url":"https://api.github.com/users/bobotu/events{/privacy}","received_events_url":"https://api.github.com/users/bobotu/received_events","type":"User","site_admin":false},"repo":{"id":87924220,"name":"tidb","full_name":"bobotu/tidb","owner":{"login":"bobotu","id":15031522,"avatar_url":"https://avatars2.githubusercontent.com/u/15031522?v=4","gravatar_id":"","url":"https://api.github.com/users/bobotu","html_url":"https://github.com/bobotu","followers_url":"https://api.github.com/users/bobotu/followers","following_url":"https://api.github.com/users/bobotu/following{/other_user}","gists_url":"https://api.github.com/users/bobotu/gists{/gist_id}","starred_url":"https://api.github.com/users/bobotu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bobotu/subscriptions","organizations_url":"https://api.github.com/users/bobotu/orgs","repos_url":"https://api.github.com/users/bobotu/repos","events_url":"https://api.github.com/users/bobotu/events{/privacy}","received_events_url":"https://api.github.com/users/bobotu/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bobotu/tidb","description":"TiDB is a distributed NewSQL database compatible with MySQL protocol ","fork":true,"url":"https://api.github.com/repos/bobotu/tidb","forks_url":"https://api.github.com/repos/bobotu/tidb/forks","keys_url":"https://api.github.com/repos/bobotu/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bobotu/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bobotu/tidb/teams","hooks_url":"https://api.github.com/repos/bobotu/tidb/hooks","issue_events_url":"https://api.github.com/repos/bobotu/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/bobotu/tidb/events","assignees_url":"https://api.github.com/repos/bobotu/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/bobotu/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/bobotu/tidb/tags","blobs_url":"https://api.github.com/repos/bobotu/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bobotu/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bobotu/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/bobotu/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bobotu/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/bobotu/tidb/languages","stargazers_url":"https://api.github.com/repos/bobotu/tidb/stargazers","contributors_url":"https://api.github.com/repos/bobotu/tidb/contributors","subscribers_url":"https://api.github.com/repos/bobotu/tidb/subscribers","subscription_url":"https://api.github.com/repos/bobotu/tidb/subscription","commits_url":"https://api.github.com/repos/bobotu/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/bobotu/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/bobotu/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/bobotu/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/bobotu/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/bobotu/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bobotu/tidb/merges","archive_url":"https://api.github.com/repos/bobotu/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bobotu/tidb/downloads","issues_url":"https://api.github.com/repos/bobotu/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/bobotu/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/bobotu/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/bobotu/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bobotu/tidb/labels{/name}","releases_url":"https://api.github.com/repos/bobotu/tidb/releases{/id}","deployments_url":"https://api.github.com/repos/bobotu/tidb/deployments","created_at":"2017-04-11T11:03:29Z","updated_at":"2017-04-11T11:03:32Z","pushed_at":"2017-09-26T13:16:00Z","git_url":"git://github.com/bobotu/tidb.git","ssh_url":"git@github.com:bobotu/tidb.git","clone_url":"https://github.com/bobotu/tidb.git","svn_url":"https://github.com/bobotu/tidb","homepage":"","size":33352,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"d2d14d8c48647436b3b71af16aacb63942976797","user":{"login":"pingcap","id":11855343,"avatar_url":"https://avatars3.githubusercontent.com/u/11855343?v=4","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://avatars3.githubusercontent.com/u/11855343?v=4","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 NewSQL 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}","deployments_url":"https://api.github.com/repos/pingcap/tidb/deployments","created_at":"2015-09-06T04:01:52Z","updated_at":"2017-09-27T02:29:14Z","pushed_at":"2017-09-27T03:39:36Z","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":"https://pingcap.com","size":35630,"stargazers_count":9594,"watchers_count":9594,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1310,"mirror_url":null,"open_issues_count":318,"forks":1310,"open_issues":318,"watchers":9594,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/4603"},"html":{"href":"https://github.com/pingcap/tidb/pull/4603"},"issue":{"href":"https://api.github.com/repos/pingcap/tidb/issues/4603"},"comments":{"href":"https://api.github.com/repos/pingcap/tidb/issues/4603/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/4603/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/4603/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tidb/statuses/13e93b9de05daf7f7ed6ed0df88ea07cd71b7dc2"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"winkyao"}}