[
https://issues.apache.org/jira/browse/TRAFODION-2208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15492892#comment-15492892
]
ASF GitHub Bot commented on TRAFODION-2208:
-------------------------------------------
Github user traflm commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/703#discussion_r78926677
--- Diff: core/sql/optimizer/SynthType.cpp ---
@@ -1010,7 +1010,81 @@ const NAType *BuiltinFunction::synthesizeType()
SQLChar(maxLength, typ1.supportsSQLnull());
}
break;
+
+ case ITM_ISIPV4:
+ case ITM_ISIPV6:
+ {
+ // type cast any params
+ ValueId vid1 = child(0)->getValueId();
+ SQLChar c1(ComSqlId::MAX_QUERY_ID_LEN);
+ vid1.coerceType(c1, NA_CHARACTER_TYPE);
+ //input type must be string
+ const NAType &typ1 = child(0)->getValueId().getType();
+
+ if (typ1.getTypeQualifier() != NA_CHARACTER_TYPE)
+ {
+ *CmpCommon::diags() << DgSqlCode(-4045) << DgString0("IS_IP");
+ return NULL;
+ }
+ retType = new HEAP
+ SQLSmall(TRUE, FALSE);
+ if (typ1.supportsSQLnull())
+ {
+ retType->setNullable(TRUE);
+ }
+ }
+ break;
+ case ITM_INET_ATON:
+ {
+ // type cast any params
+ ValueId vid1 = child(0)->getValueId();
+ SQLChar c1(ComSqlId::MAX_QUERY_ID_LEN);
+ vid1.coerceType(c1, NA_CHARACTER_TYPE);
+
+ //input type must be string
+ const NAType &typ1 = child(0)->getValueId().getType();
+
+ if (typ1.getTypeQualifier() != NA_CHARACTER_TYPE)
+ {
+ *CmpCommon::diags() << DgSqlCode(-4045) << DgString0("INET_ATON");
+ return NULL;
+ }
+ retType = new HEAP
+ SQLInt(FALSE, FALSE);
+ if (typ1.supportsSQLnull())
+ {
+ retType->setNullable(TRUE);
+ }
+ }
+ break;
+ case ITM_INET_NTOA:
+ {
+ // type cast any params
+ ValueId vid = child(0)->getValueId();
+ vid.coerceType(NA_NUMERIC_TYPE);
+
+ const NAType &typ1 = child(0)->getValueId().getType();
+ if (typ1.getTypeQualifier() != NA_NUMERIC_TYPE)
+ {
+ *CmpCommon::diags() << DgSqlCode(-4045) << DgString0("INET_NTOA");
+ return NULL;
+ }
+ const NumericType &ntyp1 = (NumericType &) typ1;
+ if (NOT ntyp1.isExact() || ntyp1.getScale() != 0)
+ {
+ *CmpCommon::diags() << DgSqlCode(-4046) << DgString0("INET_NTOA");
+ return NULL;
+ }
+ retType = new HEAP
+ SQLVarChar(15, FALSE);
+ SQLInt(FALSE, FALSE);
--- End diff --
oops, sorry about this.
> function support: log2,IS_IPV4,IS_IPV6 etc
> ------------------------------------------
>
> Key: TRAFODION-2208
> URL: https://issues.apache.org/jira/browse/TRAFODION-2208
> Project: Apache Trafodion
> Issue Type: Sub-task
> Reporter: liu ming
> Assignee: liu ming
>
> add built-in function
> IS_IPV4
> IS_IPV6
> LOG2
> Also try to enhance the least to accept multiple input arguments which is
> required in both Oracle/MySQL.
> This will be an example about how to add new built-in functions, so start
> with some very simple functions.
> One of the important goal is to guide the following developing works.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)