{"action":"created","comment":{"url":"https://api.github.com/repos/percona/percona-server/pulls/comments/168706434","pull_request_review_id":97118271,"id":168706434,"diff_hunk":"@@ -0,0 +1,73 @@\n+/* Copyright (c) 2018 Percona LLC and/or its affiliates. All rights reserved.\n+\n+   This program is free software; you can redistribute it and/or\n+   modify it under the terms of the GNU General Public License\n+   as published by the Free Software Foundation; version 2 of\n+   the License.\n+\n+   This program is distributed in the hope that it will be useful,\n+   but WITHOUT ANY WARRANTY; without even the implied warranty of\n+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n+   GNU General Public License for more details.\n+\n+   You should have received a copy of the GNU General Public License\n+   along with this program; if not, write to the Free Software\n+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */\n+\n+#include <my_global.h>\n+#include \"item_keyring_func.h\"\n+#include <mysql/service_mysql_keyring.h>\n+#include <algorithm>\n+#include <cstring>\n+#include \"sql_class.h\"           // THD\n+#include \"system_key.h\"\n+\n+bool Item_func_rotate_system_key::itemize(Parse_context *pc, Item **res)\n+{\n+  if (skip_itemize(res))\n+    return false;\n+  if (Item_bool_func::itemize(pc, res))\n+    return true;\n+  pc->thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);\n+  pc->thd->lex->safe_to_cache_query= false;\n+  return false;\n+}\n+\n+longlong Item_func_rotate_system_key::val_int()\n+{\n+  DBUG_ASSERT(fixed);\n+\n+  if (args[0]->result_type() != STRING_RESULT) // String argument expected\n+    return 0;\n+\n+  String buffer;\n+  String *arg_str= args[0]->val_str(&buffer);\n+\n+  if (!arg_str) // Out-of memory happened. The error has been reported.\n+    return 0;   // Or: the underlying field is NULL\n+\n+  return calc_value(arg_str) ? 1 : 0;\n+}\n+\n+bool Item_func_rotate_system_key::calc_value(const String *arg)\n+{\n+  std::sort(valid_percona_system_keys,","path":"sql/item_keyring_func.cc","position":54,"original_position":54,"commit_id":"c643ef75a13063c18b8b5d6c57a0be59fa11f984","original_commit_id":"c643ef75a13063c18b8b5d6c57a0be59fa11f984","user":{"login":"robgolebiowski","id":13623486,"avatar_url":"https://avatars2.githubusercontent.com/u/13623486?v=4","gravatar_id":"","url":"https://api.github.com/users/robgolebiowski","html_url":"https://github.com/robgolebiowski","followers_url":"https://api.github.com/users/robgolebiowski/followers","following_url":"https://api.github.com/users/robgolebiowski/following{/other_user}","gists_url":"https://api.github.com/users/robgolebiowski/gists{/gist_id}","starred_url":"https://api.github.com/users/robgolebiowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robgolebiowski/subscriptions","organizations_url":"https://api.github.com/users/robgolebiowski/orgs","repos_url":"https://api.github.com/users/robgolebiowski/repos","events_url":"https://api.github.com/users/robgolebiowski/events{/privacy}","received_events_url":"https://api.github.com/users/robgolebiowski/received_events","type":"User","site_admin":false},"body":"It cannot be declared as c++ std::set, as this needs to stay a c file. I have changed it to plain table and since this is really small table it does not make much sense in forcing binary search on it. Thus I have changed this to one by one array scan.","created_at":"2018-02-16T09:24:21Z","updated_at":"2018-02-16T09:24:22Z","html_url":"https://github.com/percona/percona-server/pull/2122#discussion_r168706434","pull_request_url":"https://api.github.com/repos/percona/percona-server/pulls/2122","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/percona/percona-server/pulls/comments/168706434"},"html":{"href":"https://github.com/percona/percona-server/pull/2122#discussion_r168706434"},"pull_request":{"href":"https://api.github.com/repos/percona/percona-server/pulls/2122"}},"in_reply_to_id":168166111},"pull_request":{"url":"https://api.github.com/repos/percona/percona-server/pulls/2122","id":166203364,"html_url":"https://github.com/percona/percona-server/pull/2122","diff_url":"https://github.com/percona/percona-server/pull/2122.diff","patch_url":"https://github.com/percona/percona-server/pull/2122.patch","issue_url":"https://api.github.com/repos/percona/percona-server/issues/2122","number":2122,"state":"open","locked":false,"title":"PS-3779: System key rotation support in keyring framework","user":{"login":"robgolebiowski","id":13623486,"avatar_url":"https://avatars2.githubusercontent.com/u/13623486?v=4","gravatar_id":"","url":"https://api.github.com/users/robgolebiowski","html_url":"https://github.com/robgolebiowski","followers_url":"https://api.github.com/users/robgolebiowski/followers","following_url":"https://api.github.com/users/robgolebiowski/following{/other_user}","gists_url":"https://api.github.com/users/robgolebiowski/gists{/gist_id}","starred_url":"https://api.github.com/users/robgolebiowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robgolebiowski/subscriptions","organizations_url":"https://api.github.com/users/robgolebiowski/orgs","repos_url":"https://api.github.com/users/robgolebiowski/repos","events_url":"https://api.github.com/users/robgolebiowski/events{/privacy}","received_events_url":"https://api.github.com/users/robgolebiowski/received_events","type":"User","site_admin":false},"body":"Keyring framework should be capable of rotating system keys. This\r\nfeature is needed by different encryption components (binlog encryption,\r\nrotation-enabled tablespaces). Please note, that by system key we mean\r\nall system keys that starts with a prefix percona_ , for instance:\r\npercona_binlog). This feature does not extend keyring framework API, but\r\nadds new functionalities to existing API functions:\r\n\r\n - calling my_key_generate or my_key_store with system key id will\r\n   create rotation-enabled system key in keyring. (For instance calling\r\n   my_key_generate(\"percona_binlog\", \"AES\", NULL, 16) will add key\r\n   percona_binlog:0 to keyring. The ':0' part of the system key id is the\r\n   version assigned to the key).\r\n - calling my_key_generate or my_key_store with existing system key id\r\n   will rotate the key to a new version. (for instance percona_binlog:0\r\n   exist in keyring, calling my_key_generate(\"percona_binlog\", \"AES\", NULL,\r\n   16) will add key percona_binlog:1 to the keyring)\r\n - calling my_key_fetch with system key id will fetch the latest\r\n   version of the system key. For instance if there are two keys in the\r\n   keyring percona_binlog:0 and percona_binlog:1 -\r\n   my_key_fetch(\"percona_binlog\" (...)) will fetch percona_binlog:1\r\n - calling my_key_remove on system key will result in error - as it is\r\n   not possible to remove system key from keyring (at least not from\r\n   keyring API)\r\n\r\nImplementation of this feature needs to support binlog key rotation.\r\nThis, apart from extending the keyring framework also includes providing:\r\n - rotate_system_key function. With this function super users will be\r\n   capable of rotating binlog key, by calling\r\n   rotate_system_key(\"percona_binlog\"). As mentioned, users will need to\r\n   have super privilege to be able to rotate the key.\r\n - binlog encryption should be extended - so it would be capable of\r\n   working with different versions of percona_binlog system key\r\n\r\nImplementation of this feature also includes a convenience function\r\nparse_system_key that helps to separate key id and key version from\r\nsystem key data.","created_at":"2018-01-31T09:17:25Z","updated_at":"2018-02-16T09:24:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"43f892edb044757fb2e3cba5e46124a18c395b11","assignee":{"login":"robgolebiowski","id":13623486,"avatar_url":"https://avatars2.githubusercontent.com/u/13623486?v=4","gravatar_id":"","url":"https://api.github.com/users/robgolebiowski","html_url":"https://github.com/robgolebiowski","followers_url":"https://api.github.com/users/robgolebiowski/followers","following_url":"https://api.github.com/users/robgolebiowski/following{/other_user}","gists_url":"https://api.github.com/users/robgolebiowski/gists{/gist_id}","starred_url":"https://api.github.com/users/robgolebiowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robgolebiowski/subscriptions","organizations_url":"https://api.github.com/users/robgolebiowski/orgs","repos_url":"https://api.github.com/users/robgolebiowski/repos","events_url":"https://api.github.com/users/robgolebiowski/events{/privacy}","received_events_url":"https://api.github.com/users/robgolebiowski/received_events","type":"User","site_admin":false},"assignees":[{"login":"robgolebiowski","id":13623486,"avatar_url":"https://avatars2.githubusercontent.com/u/13623486?v=4","gravatar_id":"","url":"https://api.github.com/users/robgolebiowski","html_url":"https://github.com/robgolebiowski","followers_url":"https://api.github.com/users/robgolebiowski/followers","following_url":"https://api.github.com/users/robgolebiowski/following{/other_user}","gists_url":"https://api.github.com/users/robgolebiowski/gists{/gist_id}","starred_url":"https://api.github.com/users/robgolebiowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robgolebiowski/subscriptions","organizations_url":"https://api.github.com/users/robgolebiowski/orgs","repos_url":"https://api.github.com/users/robgolebiowski/repos","events_url":"https://api.github.com/users/robgolebiowski/events{/privacy}","received_events_url":"https://api.github.com/users/robgolebiowski/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/percona/percona-server/pulls/2122/commits","review_comments_url":"https://api.github.com/repos/percona/percona-server/pulls/2122/comments","review_comment_url":"https://api.github.com/repos/percona/percona-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/percona/percona-server/issues/2122/comments","statuses_url":"https://api.github.com/repos/percona/percona-server/statuses/c643ef75a13063c18b8b5d6c57a0be59fa11f984","head":{"label":"robgolebiowski:5.7_keyring_keys_versioning_squashed","ref":"5.7_keyring_keys_versioning_squashed","sha":"c643ef75a13063c18b8b5d6c57a0be59fa11f984","user":{"login":"robgolebiowski","id":13623486,"avatar_url":"https://avatars2.githubusercontent.com/u/13623486?v=4","gravatar_id":"","url":"https://api.github.com/users/robgolebiowski","html_url":"https://github.com/robgolebiowski","followers_url":"https://api.github.com/users/robgolebiowski/followers","following_url":"https://api.github.com/users/robgolebiowski/following{/other_user}","gists_url":"https://api.github.com/users/robgolebiowski/gists{/gist_id}","starred_url":"https://api.github.com/users/robgolebiowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robgolebiowski/subscriptions","organizations_url":"https://api.github.com/users/robgolebiowski/orgs","repos_url":"https://api.github.com/users/robgolebiowski/repos","events_url":"https://api.github.com/users/robgolebiowski/events{/privacy}","received_events_url":"https://api.github.com/users/robgolebiowski/received_events","type":"User","site_admin":false},"repo":{"id":78863750,"name":"percona-server","full_name":"robgolebiowski/percona-server","owner":{"login":"robgolebiowski","id":13623486,"avatar_url":"https://avatars2.githubusercontent.com/u/13623486?v=4","gravatar_id":"","url":"https://api.github.com/users/robgolebiowski","html_url":"https://github.com/robgolebiowski","followers_url":"https://api.github.com/users/robgolebiowski/followers","following_url":"https://api.github.com/users/robgolebiowski/following{/other_user}","gists_url":"https://api.github.com/users/robgolebiowski/gists{/gist_id}","starred_url":"https://api.github.com/users/robgolebiowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robgolebiowski/subscriptions","organizations_url":"https://api.github.com/users/robgolebiowski/orgs","repos_url":"https://api.github.com/users/robgolebiowski/repos","events_url":"https://api.github.com/users/robgolebiowski/events{/privacy}","received_events_url":"https://api.github.com/users/robgolebiowski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/robgolebiowski/percona-server","description":"Percona Server","fork":true,"url":"https://api.github.com/repos/robgolebiowski/percona-server","forks_url":"https://api.github.com/repos/robgolebiowski/percona-server/forks","keys_url":"https://api.github.com/repos/robgolebiowski/percona-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/robgolebiowski/percona-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/robgolebiowski/percona-server/teams","hooks_url":"https://api.github.com/repos/robgolebiowski/percona-server/hooks","issue_events_url":"https://api.github.com/repos/robgolebiowski/percona-server/issues/events{/number}","events_url":"https://api.github.com/repos/robgolebiowski/percona-server/events","assignees_url":"https://api.github.com/repos/robgolebiowski/percona-server/assignees{/user}","branches_url":"https://api.github.com/repos/robgolebiowski/percona-server/branches{/branch}","tags_url":"https://api.github.com/repos/robgolebiowski/percona-server/tags","blobs_url":"https://api.github.com/repos/robgolebiowski/percona-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/robgolebiowski/percona-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/robgolebiowski/percona-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/robgolebiowski/percona-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/robgolebiowski/percona-server/statuses/{sha}","languages_url":"https://api.github.com/repos/robgolebiowski/percona-server/languages","stargazers_url":"https://api.github.com/repos/robgolebiowski/percona-server/stargazers","contributors_url":"https://api.github.com/repos/robgolebiowski/percona-server/contributors","subscribers_url":"https://api.github.com/repos/robgolebiowski/percona-server/subscribers","subscription_url":"https://api.github.com/repos/robgolebiowski/percona-server/subscription","commits_url":"https://api.github.com/repos/robgolebiowski/percona-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/robgolebiowski/percona-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/robgolebiowski/percona-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/robgolebiowski/percona-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/robgolebiowski/percona-server/contents/{+path}","compare_url":"https://api.github.com/repos/robgolebiowski/percona-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/robgolebiowski/percona-server/merges","archive_url":"https://api.github.com/repos/robgolebiowski/percona-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/robgolebiowski/percona-server/downloads","issues_url":"https://api.github.com/repos/robgolebiowski/percona-server/issues{/number}","pulls_url":"https://api.github.com/repos/robgolebiowski/percona-server/pulls{/number}","milestones_url":"https://api.github.com/repos/robgolebiowski/percona-server/milestones{/number}","notifications_url":"https://api.github.com/repos/robgolebiowski/percona-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/robgolebiowski/percona-server/labels{/name}","releases_url":"https://api.github.com/repos/robgolebiowski/percona-server/releases{/id}","deployments_url":"https://api.github.com/repos/robgolebiowski/percona-server/deployments","created_at":"2017-01-13T15:57:37Z","updated_at":"2017-01-13T15:59:56Z","pushed_at":"2018-02-14T15:45:41Z","git_url":"git://github.com/robgolebiowski/percona-server.git","ssh_url":"git@github.com:robgolebiowski/percona-server.git","clone_url":"https://github.com/robgolebiowski/percona-server.git","svn_url":"https://github.com/robgolebiowski/percona-server","homepage":"https://www.percona.com/software/mysql-database/percona-server","size":1168993,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"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":"5.7"}},"base":{"label":"percona:5.7","ref":"5.7","sha":"4ff8e6a5888b9f491f1fab9ef0894d9307fbe625","user":{"login":"percona","id":1683025,"avatar_url":"https://avatars0.githubusercontent.com/u/1683025?v=4","gravatar_id":"","url":"https://api.github.com/users/percona","html_url":"https://github.com/percona","followers_url":"https://api.github.com/users/percona/followers","following_url":"https://api.github.com/users/percona/following{/other_user}","gists_url":"https://api.github.com/users/percona/gists{/gist_id}","starred_url":"https://api.github.com/users/percona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/percona/subscriptions","organizations_url":"https://api.github.com/users/percona/orgs","repos_url":"https://api.github.com/users/percona/repos","events_url":"https://api.github.com/users/percona/events{/privacy}","received_events_url":"https://api.github.com/users/percona/received_events","type":"Organization","site_admin":false},"repo":{"id":30753733,"name":"percona-server","full_name":"percona/percona-server","owner":{"login":"percona","id":1683025,"avatar_url":"https://avatars0.githubusercontent.com/u/1683025?v=4","gravatar_id":"","url":"https://api.github.com/users/percona","html_url":"https://github.com/percona","followers_url":"https://api.github.com/users/percona/followers","following_url":"https://api.github.com/users/percona/following{/other_user}","gists_url":"https://api.github.com/users/percona/gists{/gist_id}","starred_url":"https://api.github.com/users/percona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/percona/subscriptions","organizations_url":"https://api.github.com/users/percona/orgs","repos_url":"https://api.github.com/users/percona/repos","events_url":"https://api.github.com/users/percona/events{/privacy}","received_events_url":"https://api.github.com/users/percona/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/percona/percona-server","description":"Percona Server","fork":false,"url":"https://api.github.com/repos/percona/percona-server","forks_url":"https://api.github.com/repos/percona/percona-server/forks","keys_url":"https://api.github.com/repos/percona/percona-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/percona/percona-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/percona/percona-server/teams","hooks_url":"https://api.github.com/repos/percona/percona-server/hooks","issue_events_url":"https://api.github.com/repos/percona/percona-server/issues/events{/number}","events_url":"https://api.github.com/repos/percona/percona-server/events","assignees_url":"https://api.github.com/repos/percona/percona-server/assignees{/user}","branches_url":"https://api.github.com/repos/percona/percona-server/branches{/branch}","tags_url":"https://api.github.com/repos/percona/percona-server/tags","blobs_url":"https://api.github.com/repos/percona/percona-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/percona/percona-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/percona/percona-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/percona/percona-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/percona/percona-server/statuses/{sha}","languages_url":"https://api.github.com/repos/percona/percona-server/languages","stargazers_url":"https://api.github.com/repos/percona/percona-server/stargazers","contributors_url":"https://api.github.com/repos/percona/percona-server/contributors","subscribers_url":"https://api.github.com/repos/percona/percona-server/subscribers","subscription_url":"https://api.github.com/repos/percona/percona-server/subscription","commits_url":"https://api.github.com/repos/percona/percona-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/percona/percona-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/percona/percona-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/percona/percona-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/percona/percona-server/contents/{+path}","compare_url":"https://api.github.com/repos/percona/percona-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/percona/percona-server/merges","archive_url":"https://api.github.com/repos/percona/percona-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/percona/percona-server/downloads","issues_url":"https://api.github.com/repos/percona/percona-server/issues{/number}","pulls_url":"https://api.github.com/repos/percona/percona-server/pulls{/number}","milestones_url":"https://api.github.com/repos/percona/percona-server/milestones{/number}","notifications_url":"https://api.github.com/repos/percona/percona-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/percona/percona-server/labels{/name}","releases_url":"https://api.github.com/repos/percona/percona-server/releases{/id}","deployments_url":"https://api.github.com/repos/percona/percona-server/deployments","created_at":"2015-02-13T11:32:01Z","updated_at":"2018-02-14T03:04:21Z","pushed_at":"2018-02-16T07:57:39Z","git_url":"git://github.com/percona/percona-server.git","ssh_url":"git@github.com:percona/percona-server.git","clone_url":"https://github.com/percona/percona-server.git","svn_url":"https://github.com/percona/percona-server","homepage":"https://www.percona.com/software/mysql-database/percona-server","size":583270,"stargazers_count":395,"watchers_count":395,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":167,"mirror_url":null,"archived":false,"open_issues_count":51,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":167,"open_issues":51,"watchers":395,"default_branch":"5.7"}},"_links":{"self":{"href":"https://api.github.com/repos/percona/percona-server/pulls/2122"},"html":{"href":"https://github.com/percona/percona-server/pull/2122"},"issue":{"href":"https://api.github.com/repos/percona/percona-server/issues/2122"},"comments":{"href":"https://api.github.com/repos/percona/percona-server/issues/2122/comments"},"review_comments":{"href":"https://api.github.com/repos/percona/percona-server/pulls/2122/comments"},"review_comment":{"href":"https://api.github.com/repos/percona/percona-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/percona/percona-server/pulls/2122/commits"},"statuses":{"href":"https://api.github.com/repos/percona/percona-server/statuses/c643ef75a13063c18b8b5d6c57a0be59fa11f984"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"robgolebiowski"}}