{"action":"created","comment":{"url":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments/32161991","id":32161991,"diff_hunk":"@@ -202,5 +202,34 @@ template<> inline NValue NValue::call<FUNC_POWER>(const std::vector<NValue>& arg\n }\n \n \n+template<> inline NValue NValue::call<FUNC_MOD>(const std::vector<NValue>& arguments) {\n+    assert(arguments.size() == 2);\n+    const NValue& base = arguments[0];\n+    const NValue& divisor = arguments[1];\n+\n+    const ValueType baseType = base.getValueType();\n+    const ValueType divisorType = divisor.getValueType();\n+\n+    // planner should guard against any invalid number type\n+    if (!isNumeric(baseType) || !isNumeric(divisorType)) {\n+        throw SQLException(SQLException::dynamic_sql_error, \"unsupported non-numeric type for SQL MOD function\");\n+    }\n+\n+    bool areAllIntegralType = isIntegralType(baseType) && isIntegralType(divisorType);\n+\n+    if (! areAllIntegralType) {\n+        throw SQLException(SQLException::dynamic_sql_error, \"unsupported non-integral type for SQL MOD function\");\n+    }\n+    if (base.isNull() || divisor.isNull()) {\n+        return getNullValue(VALUE_TYPE_BIGINT);\n+    } else if (divisor.castAsBigIntAndGetValue() == 0) {\n+        throw SQLException(SQLException::data_exception_division_by_zero, \"division by zero\");\n+    }\n+\n+    NValue retval(divisorType);\n+    int64_t baseValue = base.castAsBigIntAndGetValue();\n+    int64_t divisorValue = divisor.castAsBigIntAndGetValue();\n+    return getBigIntValue(baseValue % divisorValue);","path":"src/ee/expressions/numericfunctions.h","position":31,"original_position":31,"commit_id":"4128cfc72ec52a617c27d8a702de2f6da33e606e","original_commit_id":"4128cfc72ec52a617c27d8a702de2f6da33e606e","user":{"login":"wolffcm","id":7902964,"avatar_url":"https://avatars.githubusercontent.com/u/7902964?v=3","gravatar_id":"","url":"https://api.github.com/users/wolffcm","html_url":"https://github.com/wolffcm","followers_url":"https://api.github.com/users/wolffcm/followers","following_url":"https://api.github.com/users/wolffcm/following{/other_user}","gists_url":"https://api.github.com/users/wolffcm/gists{/gist_id}","starred_url":"https://api.github.com/users/wolffcm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolffcm/subscriptions","organizations_url":"https://api.github.com/users/wolffcm/orgs","repos_url":"https://api.github.com/users/wolffcm/repos","events_url":"https://api.github.com/users/wolffcm/events{/privacy}","received_events_url":"https://api.github.com/users/wolffcm/received_events","type":"User","site_admin":false},"body":"What are the undefined behaviors in C/C++ regarding `%`?  We don't want to inherit them in our implementation of SQL.  Also, does the SQL standard specify the behavior for interesting cases?\r\n\r\nConsider explicitly defining behavior for the following:\r\n- divisor equal to zero\r\n- either operand negative","created_at":"2015-06-10T20:24:31Z","updated_at":"2015-06-10T20:24:31Z","html_url":"https://github.com/VoltDB/voltdb/pull/2416#discussion_r32161991","pull_request_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/2416","_links":{"self":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments/32161991"},"html":{"href":"https://github.com/VoltDB/voltdb/pull/2416#discussion_r32161991"},"pull_request":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/2416"}}},"pull_request":{"url":"https://api.github.com/repos/VoltDB/voltdb/pulls/2416","id":37391917,"html_url":"https://github.com/VoltDB/voltdb/pull/2416","diff_url":"https://github.com/VoltDB/voltdb/pull/2416.diff","patch_url":"https://github.com/VoltDB/voltdb/pull/2416.patch","issue_url":"https://api.github.com/repos/VoltDB/voltdb/issues/2416","number":2416,"state":"open","locked":false,"title":"cherry pick Tong's contribution and add guards to fix various stuffs","user":{"login":"jxchinaren","id":1305380,"avatar_url":"https://avatars.githubusercontent.com/u/1305380?v=3","gravatar_id":"","url":"https://api.github.com/users/jxchinaren","html_url":"https://github.com/jxchinaren","followers_url":"https://api.github.com/users/jxchinaren/followers","following_url":"https://api.github.com/users/jxchinaren/following{/other_user}","gists_url":"https://api.github.com/users/jxchinaren/gists{/gist_id}","starred_url":"https://api.github.com/users/jxchinaren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jxchinaren/subscriptions","organizations_url":"https://api.github.com/users/jxchinaren/orgs","repos_url":"https://api.github.com/users/jxchinaren/repos","events_url":"https://api.github.com/users/jxchinaren/events{/privacy}","received_events_url":"https://api.github.com/users/jxchinaren/received_events","type":"User","site_admin":false},"body":"SQL MOD function, for initial support of Integral types ONLY.","created_at":"2015-06-10T18:56:58Z","updated_at":"2015-06-10T20:24:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bd49c8006a7a7e7912471aca481f8e60cf1db0e7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/2416/commits","review_comments_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/2416/comments","review_comment_url":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/issues/2416/comments","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/4128cfc72ec52a617c27d8a702de2f6da33e606e","head":{"label":"VoltDB:ENG-3010-mod-integral","ref":"ENG-3010-mod-integral","sha":"4128cfc72ec52a617c27d8a702de2f6da33e606e","user":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"repo":{"id":2445970,"name":"voltdb","full_name":"VoltDB/voltdb","owner":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VoltDB/voltdb","description":"VoltDB","fork":false,"url":"https://api.github.com/repos/VoltDB/voltdb","forks_url":"https://api.github.com/repos/VoltDB/voltdb/forks","keys_url":"https://api.github.com/repos/VoltDB/voltdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VoltDB/voltdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VoltDB/voltdb/teams","hooks_url":"https://api.github.com/repos/VoltDB/voltdb/hooks","issue_events_url":"https://api.github.com/repos/VoltDB/voltdb/issues/events{/number}","events_url":"https://api.github.com/repos/VoltDB/voltdb/events","assignees_url":"https://api.github.com/repos/VoltDB/voltdb/assignees{/user}","branches_url":"https://api.github.com/repos/VoltDB/voltdb/branches{/branch}","tags_url":"https://api.github.com/repos/VoltDB/voltdb/tags","blobs_url":"https://api.github.com/repos/VoltDB/voltdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VoltDB/voltdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VoltDB/voltdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/VoltDB/voltdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/{sha}","languages_url":"https://api.github.com/repos/VoltDB/voltdb/languages","stargazers_url":"https://api.github.com/repos/VoltDB/voltdb/stargazers","contributors_url":"https://api.github.com/repos/VoltDB/voltdb/contributors","subscribers_url":"https://api.github.com/repos/VoltDB/voltdb/subscribers","subscription_url":"https://api.github.com/repos/VoltDB/voltdb/subscription","commits_url":"https://api.github.com/repos/VoltDB/voltdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/VoltDB/voltdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/VoltDB/voltdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/VoltDB/voltdb/contents/{+path}","compare_url":"https://api.github.com/repos/VoltDB/voltdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VoltDB/voltdb/merges","archive_url":"https://api.github.com/repos/VoltDB/voltdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VoltDB/voltdb/downloads","issues_url":"https://api.github.com/repos/VoltDB/voltdb/issues{/number}","pulls_url":"https://api.github.com/repos/VoltDB/voltdb/pulls{/number}","milestones_url":"https://api.github.com/repos/VoltDB/voltdb/milestones{/number}","notifications_url":"https://api.github.com/repos/VoltDB/voltdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VoltDB/voltdb/labels{/name}","releases_url":"https://api.github.com/repos/VoltDB/voltdb/releases{/id}","created_at":"2011-09-23T18:46:12Z","updated_at":"2015-06-09T02:57:40Z","pushed_at":"2015-06-10T19:30:24Z","git_url":"git://github.com/VoltDB/voltdb.git","ssh_url":"git@github.com:VoltDB/voltdb.git","clone_url":"https://github.com/VoltDB/voltdb.git","svn_url":"https://github.com/VoltDB/voltdb","homepage":"http://community.voltdb.com/","size":668984,"stargazers_count":567,"watchers_count":567,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":163,"mirror_url":null,"open_issues_count":29,"forks":163,"open_issues":29,"watchers":567,"default_branch":"master"}},"base":{"label":"VoltDB:master","ref":"master","sha":"cf2b14913ba9501afaef7670699ef6db8670c145","user":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"repo":{"id":2445970,"name":"voltdb","full_name":"VoltDB/voltdb","owner":{"login":"VoltDB","id":703910,"avatar_url":"https://avatars.githubusercontent.com/u/703910?v=3","gravatar_id":"","url":"https://api.github.com/users/VoltDB","html_url":"https://github.com/VoltDB","followers_url":"https://api.github.com/users/VoltDB/followers","following_url":"https://api.github.com/users/VoltDB/following{/other_user}","gists_url":"https://api.github.com/users/VoltDB/gists{/gist_id}","starred_url":"https://api.github.com/users/VoltDB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoltDB/subscriptions","organizations_url":"https://api.github.com/users/VoltDB/orgs","repos_url":"https://api.github.com/users/VoltDB/repos","events_url":"https://api.github.com/users/VoltDB/events{/privacy}","received_events_url":"https://api.github.com/users/VoltDB/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/VoltDB/voltdb","description":"VoltDB","fork":false,"url":"https://api.github.com/repos/VoltDB/voltdb","forks_url":"https://api.github.com/repos/VoltDB/voltdb/forks","keys_url":"https://api.github.com/repos/VoltDB/voltdb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VoltDB/voltdb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VoltDB/voltdb/teams","hooks_url":"https://api.github.com/repos/VoltDB/voltdb/hooks","issue_events_url":"https://api.github.com/repos/VoltDB/voltdb/issues/events{/number}","events_url":"https://api.github.com/repos/VoltDB/voltdb/events","assignees_url":"https://api.github.com/repos/VoltDB/voltdb/assignees{/user}","branches_url":"https://api.github.com/repos/VoltDB/voltdb/branches{/branch}","tags_url":"https://api.github.com/repos/VoltDB/voltdb/tags","blobs_url":"https://api.github.com/repos/VoltDB/voltdb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VoltDB/voltdb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VoltDB/voltdb/git/refs{/sha}","trees_url":"https://api.github.com/repos/VoltDB/voltdb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VoltDB/voltdb/statuses/{sha}","languages_url":"https://api.github.com/repos/VoltDB/voltdb/languages","stargazers_url":"https://api.github.com/repos/VoltDB/voltdb/stargazers","contributors_url":"https://api.github.com/repos/VoltDB/voltdb/contributors","subscribers_url":"https://api.github.com/repos/VoltDB/voltdb/subscribers","subscription_url":"https://api.github.com/repos/VoltDB/voltdb/subscription","commits_url":"https://api.github.com/repos/VoltDB/voltdb/commits{/sha}","git_commits_url":"https://api.github.com/repos/VoltDB/voltdb/git/commits{/sha}","comments_url":"https://api.github.com/repos/VoltDB/voltdb/comments{/number}","issue_comment_url":"https://api.github.com/repos/VoltDB/voltdb/issues/comments{/number}","contents_url":"https://api.github.com/repos/VoltDB/voltdb/contents/{+path}","compare_url":"https://api.github.com/repos/VoltDB/voltdb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VoltDB/voltdb/merges","archive_url":"https://api.github.com/repos/VoltDB/voltdb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VoltDB/voltdb/downloads","issues_url":"https://api.github.com/repos/VoltDB/voltdb/issues{/number}","pulls_url":"https://api.github.com/repos/VoltDB/voltdb/pulls{/number}","milestones_url":"https://api.github.com/repos/VoltDB/voltdb/milestones{/number}","notifications_url":"https://api.github.com/repos/VoltDB/voltdb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VoltDB/voltdb/labels{/name}","releases_url":"https://api.github.com/repos/VoltDB/voltdb/releases{/id}","created_at":"2011-09-23T18:46:12Z","updated_at":"2015-06-09T02:57:40Z","pushed_at":"2015-06-10T19:30:24Z","git_url":"git://github.com/VoltDB/voltdb.git","ssh_url":"git@github.com:VoltDB/voltdb.git","clone_url":"https://github.com/VoltDB/voltdb.git","svn_url":"https://github.com/VoltDB/voltdb","homepage":"http://community.voltdb.com/","size":668984,"stargazers_count":567,"watchers_count":567,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":163,"mirror_url":null,"open_issues_count":29,"forks":163,"open_issues":29,"watchers":567,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/2416"},"html":{"href":"https://github.com/VoltDB/voltdb/pull/2416"},"issue":{"href":"https://api.github.com/repos/VoltDB/voltdb/issues/2416"},"comments":{"href":"https://api.github.com/repos/VoltDB/voltdb/issues/2416/comments"},"review_comments":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/2416/comments"},"review_comment":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/VoltDB/voltdb/pulls/2416/commits"},"statuses":{"href":"https://api.github.com/repos/VoltDB/voltdb/statuses/4128cfc72ec52a617c27d8a702de2f6da33e606e"}}}}