[
https://issues.apache.org/jira/browse/TRAFODION-2229?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15687311#comment-15687311
]
ASF GitHub Bot commented on TRAFODION-2229:
-------------------------------------------
Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/849#discussion_r89163492
--- Diff: core/sql/optimizer/SynthType.cpp ---
@@ -1034,6 +1033,37 @@ const NAType *BuiltinFunction::synthesizeType()
}
}
break;
+
+ case ITM_SHA2:
+ {
+ ValueId vid1 = child(0)->getValueId();
+ SQLChar c1(ComSqlId::MAX_QUERY_ID_LEN);
+ vid1.coerceType(c1, NA_CHARACTER_TYPE);
+
+ const NAType &typ1 = child(0)->getValueId().getType();
+
+ if (typ1.getTypeQualifier() != NA_CHARACTER_TYPE)
+ {
+ *CmpCommon::diags() << DgSqlCode(-4067) << DgString0("SHA2");
+ return NULL;
+ }
+
+ // type cast any params
+ ValueId vid = child(0)->getValueId();
+ vid.coerceType(NA_NUMERIC_TYPE);
+ const NAType &typ2 = child(1)->getValueId().getType();
+
+ if (typ2.getTypeQualifier() != NA_NUMERIC_TYPE)
+ {
+ *CmpCommon::diags() << DgSqlCode(-4045) << DgString0("SHA2");
+ return NULL;
+ }
+
+ retType = new HEAP
+ SQLVarChar(1024, typ1.supportsSQLnull());
--- End diff --
Should we make the output length depend on the function? And make it fixed
length? For example, https://en.wikipedia.org/wiki/SHA-2 shows that SHA224
results in 224 bits (which gives a hex string of 56 characters), SHA512 results
in 512 bits (128 characters) and so on. Oh, but you made the number of bits an
operand to the function and that could be an expression. In that case a VarChar
is warranted.
> add Hashing functions to Trafodion
> ----------------------------------
>
> Key: TRAFODION-2229
> URL: https://issues.apache.org/jira/browse/TRAFODION-2229
> Project: Apache Trafodion
> Issue Type: Sub-task
> Reporter: liu ming
> Assignee: liu ming
> Fix For: 2.1-incubating
>
>
> CRC32() Compute a cyclic redundancy check value
> MD5() Calculate MD5 checksum
> SHA1(), SHA() Calculate an SHA-1 160-bit checksum
> SHA2() Calculate an SHA-2 checksum
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)