{"action":"created","comment":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/comments/206005787","pull_request_review_id":141379667,"id":206005787,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNjAwNTc4Nw==","diff_hunk":"@@ -280,3 +281,97 @@ func getPartitionIDs(table *model.TableInfo) []int64 {\n \t}\n \treturn partitionIDs\n }\n+\n+// checkRangePartitioningKeysConstraints checks that the range partitioning key is included in the table constraint.\n+func checkRangePartitioningKeysConstraints(ctx sessionctx.Context, expr ast.ExprNode, tblInfo *model.TableInfo, constraints []*ast.Constraint) error {\n+\t// Returns directly if there is no constraint in the partition table.\n+\tif len(constraints) == 0 {\n+\t\treturn nil\n+\t}\n+\n+\t// Save the column names in the table constraint in slice.\n+\tuniKeys, multipleKeys, priKeys := saveConstraintsColumnNames(tblInfo, constraints)\n+\n+\t// Parse partitioning key, save the column names in the partitioning key to slice.\n+\tbuf := new(bytes.Buffer)\n+\texpr.Format(buf)\n+\tvar partkeys []string\n+\te, err := expression.ParseSimpleExpr(ctx, buf.String(), tblInfo)\n+\tif err != nil {\n+\t\treturn errors.Trace(err)\n+\t}\n+\tcols := expression.ExtractColumns(e)\n+\tfor _, col := range cols {\n+\t\tpartkeys = append(partkeys, col.ColName.L)\n+\t}\n+\n+\tswitch expr.(type) {\n+\tcase *ast.ColumnNameExpr, *ast.FuncCallExpr:\n+\t\t// Only one column name expression.\n+\t\tif checkConstraintIncludePartKey(partkeys, priKeys, false) || checkConstraintIncludePartKey(partkeys, multipleKeys, false) {","path":"ddl/partition.go","position":39,"original_position":39,"commit_id":"f02e767759a68647c6acaecc1f2310a7747ce646","original_commit_id":"f02e767759a68647c6acaecc1f2310a7747ce646","user":{"login":"tiancaiamao","id":1420062,"node_id":"MDQ6VXNlcjE0MjAwNjI=","avatar_url":"https://avatars2.githubusercontent.com/u/1420062?v=4","gravatar_id":"","url":"https://api.github.com/users/tiancaiamao","html_url":"https://github.com/tiancaiamao","followers_url":"https://api.github.com/users/tiancaiamao/followers","following_url":"https://api.github.com/users/tiancaiamao/following{/other_user}","gists_url":"https://api.github.com/users/tiancaiamao/gists{/gist_id}","starred_url":"https://api.github.com/users/tiancaiamao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tiancaiamao/subscriptions","organizations_url":"https://api.github.com/users/tiancaiamao/orgs","repos_url":"https://api.github.com/users/tiancaiamao/repos","events_url":"https://api.github.com/users/tiancaiamao/events{/privacy}","received_events_url":"https://api.github.com/users/tiancaiamao/received_events","type":"User","site_admin":false},"body":"partition by range (year(col1) + year(col2))\r\n\r\nIs it `*ast.FuncCallExpr` and is there \"only one column name expression\" ?","created_at":"2018-07-30T03:12:09Z","updated_at":"2018-07-30T03:38:37Z","html_url":"https://github.com/pingcap/tidb/pull/7164#discussion_r206005787","pull_request_url":"https://api.github.com/repos/pingcap/tidb/pulls/7164","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments/206005787"},"html":{"href":"https://github.com/pingcap/tidb/pull/7164#discussion_r206005787"},"pull_request":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/7164"}}},"pull_request":{"url":"https://api.github.com/repos/pingcap/tidb/pulls/7164","id":204080400,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA0MDgwNDAw","html_url":"https://github.com/pingcap/tidb/pull/7164","diff_url":"https://github.com/pingcap/tidb/pull/7164.diff","patch_url":"https://github.com/pingcap/tidb/pull/7164.patch","issue_url":"https://api.github.com/repos/pingcap/tidb/issues/7164","number":7164,"state":"open","locked":false,"title":"ddl:add constraints check when creating table partition","user":{"login":"ciscoxll","id":20379978,"node_id":"MDQ6VXNlcjIwMzc5OTc4","avatar_url":"https://avatars0.githubusercontent.com/u/20379978?v=4","gravatar_id":"","url":"https://api.github.com/users/ciscoxll","html_url":"https://github.com/ciscoxll","followers_url":"https://api.github.com/users/ciscoxll/followers","following_url":"https://api.github.com/users/ciscoxll/following{/other_user}","gists_url":"https://api.github.com/users/ciscoxll/gists{/gist_id}","starred_url":"https://api.github.com/users/ciscoxll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ciscoxll/subscriptions","organizations_url":"https://api.github.com/users/ciscoxll/orgs","repos_url":"https://api.github.com/users/ciscoxll/repos","events_url":"https://api.github.com/users/ciscoxll/events{/privacy}","received_events_url":"https://api.github.com/users/ciscoxll/received_events","type":"User","site_admin":false},"body":"## What have you changed? (mandatory)\r\n\r\nThis PR mainly solves when creating table partition, checks that the range partitioning key is included in the table constraint.\r\n1. Returns directly if there is no constraint in the partition table.\r\n2. Save the column names in the constraint and the column names in the partitioning key into slice.\r\n3. Checks that the partitioning key is included in the constraint.\r\n\r\n## What is the type of the changes? (mandatory)\r\n\r\nNew feature\r\n- New feature (non-breaking change which adds functionality)\r\n- Improvement (non-breaking change which is an improvement to an existing feature)\r\n- Bug fix (non-breaking change which fixes an issue)\r\n- Breaking change (fix or feature that would cause existing functionality to not work as expected)\r\n\r\n## How has this PR been tested? (mandatory)\r\n No\r\n\r\n## Does this PR affect documentation (docs/docs-cn) update? (mandatory)\r\n\r\nNo\r\n\r\n## Does this PR affect tidb-ansible update? (mandatory)\r\n\r\nNo\r\n\r\n## Does this PR need to be added to the release notes? (mandatory)\r\nNo\r\n\r\n\r\n\r\n","created_at":"2018-07-26T09:27:11Z","updated_at":"2018-07-30T03:38:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9c6a2a8f26861edab9b8c782fd60e527f00f6c97","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":745133021,"node_id":"MDU6TGFiZWw3NDUxMzMwMjE=","url":"https://api.github.com/repos/pingcap/tidb/labels/component/DDL-need-LGT3","name":"component/DDL-need-LGT3","color":"00bff4","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/pingcap/tidb/pulls/7164/commits","review_comments_url":"https://api.github.com/repos/pingcap/tidb/pulls/7164/comments","review_comment_url":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pingcap/tidb/issues/7164/comments","statuses_url":"https://api.github.com/repos/pingcap/tidb/statuses/f02e767759a68647c6acaecc1f2310a7747ce646","head":{"label":"ciscoxll:check-partition-unique-keys","ref":"check-partition-unique-keys","sha":"f02e767759a68647c6acaecc1f2310a7747ce646","user":{"login":"ciscoxll","id":20379978,"node_id":"MDQ6VXNlcjIwMzc5OTc4","avatar_url":"https://avatars0.githubusercontent.com/u/20379978?v=4","gravatar_id":"","url":"https://api.github.com/users/ciscoxll","html_url":"https://github.com/ciscoxll","followers_url":"https://api.github.com/users/ciscoxll/followers","following_url":"https://api.github.com/users/ciscoxll/following{/other_user}","gists_url":"https://api.github.com/users/ciscoxll/gists{/gist_id}","starred_url":"https://api.github.com/users/ciscoxll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ciscoxll/subscriptions","organizations_url":"https://api.github.com/users/ciscoxll/orgs","repos_url":"https://api.github.com/users/ciscoxll/repos","events_url":"https://api.github.com/users/ciscoxll/events{/privacy}","received_events_url":"https://api.github.com/users/ciscoxll/received_events","type":"User","site_admin":false},"repo":{"id":124212622,"node_id":"MDEwOlJlcG9zaXRvcnkxMjQyMTI2MjI=","name":"tidb","full_name":"ciscoxll/tidb","owner":{"login":"ciscoxll","id":20379978,"node_id":"MDQ6VXNlcjIwMzc5OTc4","avatar_url":"https://avatars0.githubusercontent.com/u/20379978?v=4","gravatar_id":"","url":"https://api.github.com/users/ciscoxll","html_url":"https://github.com/ciscoxll","followers_url":"https://api.github.com/users/ciscoxll/followers","following_url":"https://api.github.com/users/ciscoxll/following{/other_user}","gists_url":"https://api.github.com/users/ciscoxll/gists{/gist_id}","starred_url":"https://api.github.com/users/ciscoxll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ciscoxll/subscriptions","organizations_url":"https://api.github.com/users/ciscoxll/orgs","repos_url":"https://api.github.com/users/ciscoxll/repos","events_url":"https://api.github.com/users/ciscoxll/events{/privacy}","received_events_url":"https://api.github.com/users/ciscoxll/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ciscoxll/tidb","description":"TiDB is a distributed HTAP database compatible with the MySQL protocol ","fork":true,"url":"https://api.github.com/repos/ciscoxll/tidb","forks_url":"https://api.github.com/repos/ciscoxll/tidb/forks","keys_url":"https://api.github.com/repos/ciscoxll/tidb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ciscoxll/tidb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ciscoxll/tidb/teams","hooks_url":"https://api.github.com/repos/ciscoxll/tidb/hooks","issue_events_url":"https://api.github.com/repos/ciscoxll/tidb/issues/events{/number}","events_url":"https://api.github.com/repos/ciscoxll/tidb/events","assignees_url":"https://api.github.com/repos/ciscoxll/tidb/assignees{/user}","branches_url":"https://api.github.com/repos/ciscoxll/tidb/branches{/branch}","tags_url":"https://api.github.com/repos/ciscoxll/tidb/tags","blobs_url":"https://api.github.com/repos/ciscoxll/tidb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ciscoxll/tidb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ciscoxll/tidb/git/refs{/sha}","trees_url":"https://api.github.com/repos/ciscoxll/tidb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ciscoxll/tidb/statuses/{sha}","languages_url":"https://api.github.com/repos/ciscoxll/tidb/languages","stargazers_url":"https://api.github.com/repos/ciscoxll/tidb/stargazers","contributors_url":"https://api.github.com/repos/ciscoxll/tidb/contributors","subscribers_url":"https://api.github.com/repos/ciscoxll/tidb/subscribers","subscription_url":"https://api.github.com/repos/ciscoxll/tidb/subscription","commits_url":"https://api.github.com/repos/ciscoxll/tidb/commits{/sha}","git_commits_url":"https://api.github.com/repos/ciscoxll/tidb/git/commits{/sha}","comments_url":"https://api.github.com/repos/ciscoxll/tidb/comments{/number}","issue_comment_url":"https://api.github.com/repos/ciscoxll/tidb/issues/comments{/number}","contents_url":"https://api.github.com/repos/ciscoxll/tidb/contents/{+path}","compare_url":"https://api.github.com/repos/ciscoxll/tidb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ciscoxll/tidb/merges","archive_url":"https://api.github.com/repos/ciscoxll/tidb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ciscoxll/tidb/downloads","issues_url":"https://api.github.com/repos/ciscoxll/tidb/issues{/number}","pulls_url":"https://api.github.com/repos/ciscoxll/tidb/pulls{/number}","milestones_url":"https://api.github.com/repos/ciscoxll/tidb/milestones{/number}","notifications_url":"https://api.github.com/repos/ciscoxll/tidb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ciscoxll/tidb/labels{/name}","releases_url":"https://api.github.com/repos/ciscoxll/tidb/releases{/id}","deployments_url":"https://api.github.com/repos/ciscoxll/tidb/deployments","created_at":"2018-03-07T09:33:48Z","updated_at":"2018-04-12T04:00:34Z","pushed_at":"2018-07-30T02:40:09Z","git_url":"git://github.com/ciscoxll/tidb.git","ssh_url":"git@github.com:ciscoxll/tidb.git","clone_url":"https://github.com/ciscoxll/tidb.git","svn_url":"https://github.com/ciscoxll/tidb","homepage":"https://pingcap.com","size":52163,"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":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pingcap:master","ref":"master","sha":"4a203fd5254ca32c22f3bbeedc4a22aabacaf957","user":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","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,"node_id":"MDEwOlJlcG9zaXRvcnk0MTk4NjM2OQ==","name":"tidb","full_name":"pingcap/tidb","owner":{"login":"pingcap","id":11855343,"node_id":"MDEyOk9yZ2FuaXphdGlvbjExODU1MzQz","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 HTAP database compatible with the 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":"2018-07-30T03:36:39Z","pushed_at":"2018-07-30T03:36:33Z","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":77884,"stargazers_count":14181,"watchers_count":14181,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1951,"mirror_url":null,"archived":false,"open_issues_count":464,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1951,"open_issues":464,"watchers":14181,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/7164"},"html":{"href":"https://github.com/pingcap/tidb/pull/7164"},"issue":{"href":"https://api.github.com/repos/pingcap/tidb/issues/7164"},"comments":{"href":"https://api.github.com/repos/pingcap/tidb/issues/7164/comments"},"review_comments":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/7164/comments"},"review_comment":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pingcap/tidb/pulls/7164/commits"},"statuses":{"href":"https://api.github.com/repos/pingcap/tidb/statuses/f02e767759a68647c6acaecc1f2310a7747ce646"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"tiancaiamao"}}