{"action":"created","comment":{"url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/comments/86404501","pull_request_review_id":7064427,"id":86404501,"diff_hunk":"@@ -7900,6 +7936,114 @@ ex_expr::exp_return_type ExFunctionInetNtoa::eval(char * op_data[],\n    return ex_expr::EXPR_OK;\n }\n \n+ex_expr::exp_return_type ExFunctionCrc32::eval(char * op_data[],\n+                                                        CollHeap *heap,\n+                                                        ComDiagsArea **diags)\n+{\n+  Attributes *resultAttr   = getOperand(0);\n+  Attributes *srcAttr   = getOperand(1);\n+\n+  Lng32 slen = srcAttr->getLength(op_data[-MAX_OPERANDS+1]);\n+  Lng32 rlen = resultAttr->getLength();\n+\n+  *(ULng32*)op_data[0] = 0; \n+  ULng32 crc = crc32(0L, Z_NULL, 0);\n+  crc = crc32 (crc, (const Bytef*)op_data[1], slen);\n+  *(ULng32*)op_data[0] = crc; \n+  return ex_expr::EXPR_OK;\n+}\n+\n+//only support SHA 256 for this version\n+//TBD: add 224 and 384, 512 in next version\n+ex_expr::exp_return_type ExFunctionSha2::eval(char * op_data[],\n+                                                        CollHeap *heap,\n+                                                        ComDiagsArea **diags)\n+{\n+\n+  unsigned char sha[SHA256_DIGEST_LENGTH+ 1]={0};  \n+\n+  Attributes *resultAttr   = getOperand(0);\n+  Attributes *srcAttr   = getOperand(1);\n+\n+  Lng32 slen = srcAttr->getLength(op_data[-MAX_OPERANDS+1]);\n+  Lng32 rlen = resultAttr->getLength();\n+\n+  memset(op_data[0], 0, rlen);\n+\n+  SHA256_CTX  sha_ctx;\n+\n+  SHA256_Init(&sha_ctx);  \n+  SHA256_Update(&sha_ctx, op_data[1], slen);\n+  SHA256_Final((unsigned char*) sha,&sha_ctx); \n+  char tmp[2];\n+  for(int i=0; i < SHA256_DIGEST_LENGTH; i++ )\n+  {\n+    tmp[0]=tmp[1]='0';\n+    sprintf(tmp, \"%.2x\", (int)sha[i]);\n+    memcpy(op_data[0]+i*2, tmp, 2);\n+  }\n+   \n+  return ex_expr::EXPR_OK;\n+}\n+\n+ex_expr::exp_return_type ExFunctionSha::eval(char * op_data[],\n+                                                        CollHeap *heap,\n+                                                        ComDiagsArea **diags)\n+{\n+\n+  unsigned char sha[SHA_DIGEST_LENGTH + 1]={0};  \n+\n+  Attributes *resultAttr   = getOperand(0);\n+  Attributes *srcAttr   = getOperand(1);\n+  Lng32 slen = srcAttr->getLength(op_data[-MAX_OPERANDS+1]);\n+  Lng32 rlen = resultAttr->getLength();\n+  memset(op_data[0], 0, rlen);\n+\n+  SHA_CTX  sha_ctx;\n+\n+  SHA1_Init(&sha_ctx);  \n+  SHA1_Update(&sha_ctx, op_data[1], slen);\n+  SHA1_Final((unsigned char*) sha,&sha_ctx); \n+  char tmp[2];\n+  for(int i=0; i < SHA_DIGEST_LENGTH ; i++ )\n+  {\n+    tmp[0]=tmp[1]='0';\n+    sprintf(tmp, \"%.2x\", (int)sha[i]);\n+    memcpy(op_data[0]+i*2, tmp, 2);\n+  }\n+   \n+  return ex_expr::EXPR_OK;\n+}\n+\n+ex_expr::exp_return_type ExFunctionMd5::eval(char * op_data[],\n+                                                        CollHeap *heap,\n+                                                        ComDiagsArea **diags)\n+{\n+  unsigned char md5[17]={0};  \n+\n+  Attributes *resultAttr   = getOperand(0);\n+  Attributes *srcAttr   = getOperand(1);\n+\n+  Lng32 slen = srcAttr->getLength(op_data[-MAX_OPERANDS+1]);\n+  Lng32 rlen = resultAttr->getLength();\n+\n+  memset(op_data[0], 0, rlen);\n+  MD5_CTX  md5_ctx;\n+\n+  MD5_Init(&md5_ctx);  \n+  MD5_Update(&md5_ctx, op_data[1], slen);\n+  MD5_Final((unsigned char*) md5,&md5_ctx); \n+  char tmp[2];","path":"core/sql/exp/exp_function.cpp","position":158,"original_position":158,"commit_id":"ece38ae9b9b17384457adbd9af5d235fe6f24f59","original_commit_id":"ece38ae9b9b17384457adbd9af5d235fe6f24f59","user":{"login":"DaveBirdsall","id":5659628,"avatar_url":"https://avatars.githubusercontent.com/u/5659628?v=3","gravatar_id":"","url":"https://api.github.com/users/DaveBirdsall","html_url":"https://github.com/DaveBirdsall","followers_url":"https://api.github.com/users/DaveBirdsall/followers","following_url":"https://api.github.com/users/DaveBirdsall/following{/other_user}","gists_url":"https://api.github.com/users/DaveBirdsall/gists{/gist_id}","starred_url":"https://api.github.com/users/DaveBirdsall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaveBirdsall/subscriptions","organizations_url":"https://api.github.com/users/DaveBirdsall/orgs","repos_url":"https://api.github.com/users/DaveBirdsall/repos","events_url":"https://api.github.com/users/DaveBirdsall/events{/privacy}","received_events_url":"https://api.github.com/users/DaveBirdsall/received_events","type":"User","site_admin":false},"body":"This buffer is too short.","created_at":"2016-11-03T17:54:01Z","updated_at":"2016-11-03T17:57:24Z","html_url":"https://github.com/apache/incubator-trafodion/pull/813#discussion_r86404501","pull_request_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/813","_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/comments/86404501"},"html":{"href":"https://github.com/apache/incubator-trafodion/pull/813#discussion_r86404501"},"pull_request":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/813"}}},"pull_request":{"url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/813","id":92126388,"html_url":"https://github.com/apache/incubator-trafodion/pull/813","diff_url":"https://github.com/apache/incubator-trafodion/pull/813.diff","patch_url":"https://github.com/apache/incubator-trafodion/pull/813.patch","issue_url":"https://api.github.com/repos/apache/incubator-trafodion/issues/813","number":813,"state":"open","locked":false,"title":"[TRAFODION-2229] add Hashing functions to Trafodion","user":{"login":"traflm","id":12948514,"avatar_url":"https://avatars.githubusercontent.com/u/12948514?v=3","gravatar_id":"","url":"https://api.github.com/users/traflm","html_url":"https://github.com/traflm","followers_url":"https://api.github.com/users/traflm/followers","following_url":"https://api.github.com/users/traflm/following{/other_user}","gists_url":"https://api.github.com/users/traflm/gists{/gist_id}","starred_url":"https://api.github.com/users/traflm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/traflm/subscriptions","organizations_url":"https://api.github.com/users/traflm/orgs","repos_url":"https://api.github.com/users/traflm/repos","events_url":"https://api.github.com/users/traflm/events{/privacy}","received_events_url":"https://api.github.com/users/traflm/received_events","type":"User","site_admin":false},"body":"Compatibility enhancement \r\nadd new functions for MySQL:\r\nCRC32()\tCompute a cyclic redundancy check value\r\nMD5()\tCalculate MD5 checksum\r\nSHA1(), SHA()\tCalculate an SHA-1 160-bit checksum\r\nSHA2()\tCalculate an SHA-2 checksum\r\n\r\nUnit test is to test several input value, and invoke same query in MySQL, and compare the result. Pass the test since results are same.\r\n","created_at":"2016-11-03T10:30:09Z","updated_at":"2016-11-03T17:57:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9657b7f7b4cb8b338395e731f7bc30d02cc64618","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/813/commits","review_comments_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/813/comments","review_comment_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/incubator-trafodion/issues/813/comments","statuses_url":"https://api.github.com/repos/apache/incubator-trafodion/statuses/ece38ae9b9b17384457adbd9af5d235fe6f24f59","head":{"label":"traflm:TRAFODION-2229","ref":"TRAFODION-2229","sha":"ece38ae9b9b17384457adbd9af5d235fe6f24f59","user":{"login":"traflm","id":12948514,"avatar_url":"https://avatars.githubusercontent.com/u/12948514?v=3","gravatar_id":"","url":"https://api.github.com/users/traflm","html_url":"https://github.com/traflm","followers_url":"https://api.github.com/users/traflm/followers","following_url":"https://api.github.com/users/traflm/following{/other_user}","gists_url":"https://api.github.com/users/traflm/gists{/gist_id}","starred_url":"https://api.github.com/users/traflm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/traflm/subscriptions","organizations_url":"https://api.github.com/users/traflm/orgs","repos_url":"https://api.github.com/users/traflm/repos","events_url":"https://api.github.com/users/traflm/events{/privacy}","received_events_url":"https://api.github.com/users/traflm/received_events","type":"User","site_admin":false},"repo":{"id":38096376,"name":"incubator-trafodion","full_name":"traflm/incubator-trafodion","owner":{"login":"traflm","id":12948514,"avatar_url":"https://avatars.githubusercontent.com/u/12948514?v=3","gravatar_id":"","url":"https://api.github.com/users/traflm","html_url":"https://github.com/traflm","followers_url":"https://api.github.com/users/traflm/followers","following_url":"https://api.github.com/users/traflm/following{/other_user}","gists_url":"https://api.github.com/users/traflm/gists{/gist_id}","starred_url":"https://api.github.com/users/traflm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/traflm/subscriptions","organizations_url":"https://api.github.com/users/traflm/orgs","repos_url":"https://api.github.com/users/traflm/repos","events_url":"https://api.github.com/users/traflm/events{/privacy}","received_events_url":"https://api.github.com/users/traflm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/traflm/incubator-trafodion","description":"Mirror of Apache Trafodion (Incubating)","fork":true,"url":"https://api.github.com/repos/traflm/incubator-trafodion","forks_url":"https://api.github.com/repos/traflm/incubator-trafodion/forks","keys_url":"https://api.github.com/repos/traflm/incubator-trafodion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/traflm/incubator-trafodion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/traflm/incubator-trafodion/teams","hooks_url":"https://api.github.com/repos/traflm/incubator-trafodion/hooks","issue_events_url":"https://api.github.com/repos/traflm/incubator-trafodion/issues/events{/number}","events_url":"https://api.github.com/repos/traflm/incubator-trafodion/events","assignees_url":"https://api.github.com/repos/traflm/incubator-trafodion/assignees{/user}","branches_url":"https://api.github.com/repos/traflm/incubator-trafodion/branches{/branch}","tags_url":"https://api.github.com/repos/traflm/incubator-trafodion/tags","blobs_url":"https://api.github.com/repos/traflm/incubator-trafodion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/traflm/incubator-trafodion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/traflm/incubator-trafodion/git/refs{/sha}","trees_url":"https://api.github.com/repos/traflm/incubator-trafodion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/traflm/incubator-trafodion/statuses/{sha}","languages_url":"https://api.github.com/repos/traflm/incubator-trafodion/languages","stargazers_url":"https://api.github.com/repos/traflm/incubator-trafodion/stargazers","contributors_url":"https://api.github.com/repos/traflm/incubator-trafodion/contributors","subscribers_url":"https://api.github.com/repos/traflm/incubator-trafodion/subscribers","subscription_url":"https://api.github.com/repos/traflm/incubator-trafodion/subscription","commits_url":"https://api.github.com/repos/traflm/incubator-trafodion/commits{/sha}","git_commits_url":"https://api.github.com/repos/traflm/incubator-trafodion/git/commits{/sha}","comments_url":"https://api.github.com/repos/traflm/incubator-trafodion/comments{/number}","issue_comment_url":"https://api.github.com/repos/traflm/incubator-trafodion/issues/comments{/number}","contents_url":"https://api.github.com/repos/traflm/incubator-trafodion/contents/{+path}","compare_url":"https://api.github.com/repos/traflm/incubator-trafodion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/traflm/incubator-trafodion/merges","archive_url":"https://api.github.com/repos/traflm/incubator-trafodion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/traflm/incubator-trafodion/downloads","issues_url":"https://api.github.com/repos/traflm/incubator-trafodion/issues{/number}","pulls_url":"https://api.github.com/repos/traflm/incubator-trafodion/pulls{/number}","milestones_url":"https://api.github.com/repos/traflm/incubator-trafodion/milestones{/number}","notifications_url":"https://api.github.com/repos/traflm/incubator-trafodion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/traflm/incubator-trafodion/labels{/name}","releases_url":"https://api.github.com/repos/traflm/incubator-trafodion/releases{/id}","deployments_url":"https://api.github.com/repos/traflm/incubator-trafodion/deployments","created_at":"2015-06-26T07:07:16Z","updated_at":"2015-06-26T07:07:55Z","pushed_at":"2016-11-03T10:26:34Z","git_url":"git://github.com/traflm/incubator-trafodion.git","ssh_url":"git@github.com:traflm/incubator-trafodion.git","clone_url":"https://github.com/traflm/incubator-trafodion.git","svn_url":"https://github.com/traflm/incubator-trafodion","homepage":null,"size":74765,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"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":"apache:master","ref":"master","sha":"e26b20601134e99bbb4a0986e8ec43153260c632","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":36349344,"name":"incubator-trafodion","full_name":"apache/incubator-trafodion","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/incubator-trafodion","description":"Mirror of Apache Trafodion (Incubating)","fork":false,"url":"https://api.github.com/repos/apache/incubator-trafodion","forks_url":"https://api.github.com/repos/apache/incubator-trafodion/forks","keys_url":"https://api.github.com/repos/apache/incubator-trafodion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/incubator-trafodion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/incubator-trafodion/teams","hooks_url":"https://api.github.com/repos/apache/incubator-trafodion/hooks","issue_events_url":"https://api.github.com/repos/apache/incubator-trafodion/issues/events{/number}","events_url":"https://api.github.com/repos/apache/incubator-trafodion/events","assignees_url":"https://api.github.com/repos/apache/incubator-trafodion/assignees{/user}","branches_url":"https://api.github.com/repos/apache/incubator-trafodion/branches{/branch}","tags_url":"https://api.github.com/repos/apache/incubator-trafodion/tags","blobs_url":"https://api.github.com/repos/apache/incubator-trafodion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/incubator-trafodion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/incubator-trafodion/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/incubator-trafodion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/incubator-trafodion/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/incubator-trafodion/languages","stargazers_url":"https://api.github.com/repos/apache/incubator-trafodion/stargazers","contributors_url":"https://api.github.com/repos/apache/incubator-trafodion/contributors","subscribers_url":"https://api.github.com/repos/apache/incubator-trafodion/subscribers","subscription_url":"https://api.github.com/repos/apache/incubator-trafodion/subscription","commits_url":"https://api.github.com/repos/apache/incubator-trafodion/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/incubator-trafodion/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/incubator-trafodion/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/incubator-trafodion/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/incubator-trafodion/contents/{+path}","compare_url":"https://api.github.com/repos/apache/incubator-trafodion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/incubator-trafodion/merges","archive_url":"https://api.github.com/repos/apache/incubator-trafodion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/incubator-trafodion/downloads","issues_url":"https://api.github.com/repos/apache/incubator-trafodion/issues{/number}","pulls_url":"https://api.github.com/repos/apache/incubator-trafodion/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/incubator-trafodion/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/incubator-trafodion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/incubator-trafodion/labels{/name}","releases_url":"https://api.github.com/repos/apache/incubator-trafodion/releases{/id}","deployments_url":"https://api.github.com/repos/apache/incubator-trafodion/deployments","created_at":"2015-05-27T07:00:05Z","updated_at":"2016-11-01T10:48:04Z","pushed_at":"2016-11-03T17:50:55Z","git_url":"git://github.com/apache/incubator-trafodion.git","ssh_url":"git@github.com:apache/incubator-trafodion.git","clone_url":"https://github.com/apache/incubator-trafodion.git","svn_url":"https://github.com/apache/incubator-trafodion","homepage":null,"size":79573,"stargazers_count":80,"watchers_count":80,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":80,"mirror_url":"git://git.apache.org/incubator-trafodion.git","open_issues_count":15,"forks":80,"open_issues":15,"watchers":80,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/813"},"html":{"href":"https://github.com/apache/incubator-trafodion/pull/813"},"issue":{"href":"https://api.github.com/repos/apache/incubator-trafodion/issues/813"},"comments":{"href":"https://api.github.com/repos/apache/incubator-trafodion/issues/813/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/813/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/incubator-trafodion/pulls/813/commits"},"statuses":{"href":"https://api.github.com/repos/apache/incubator-trafodion/statuses/ece38ae9b9b17384457adbd9af5d235fe6f24f59"}}}}
{"actor":{"display_login":"DaveBirdsall"}}