Github user cwelton commented on a diff in the pull request:
https://github.com/apache/incubator-madlib/pull/10#discussion_r49812120
--- Diff: methods/array_ops/src/pg_gp/array_ops.c ---
@@ -824,6 +836,25 @@ array_fill(PG_FUNCTION_ARGS){
}
/*
+ * This function apply cos function to each element.
+ */
+PG_FUNCTION_INFO_V1(array_cos);
+Datum
+array_cos(PG_FUNCTION_ARGS){
+ if (PG_ARGISNULL(0)) { PG_RETURN_NULL(); }
+
+ ArrayType *v1 = PG_GETARG_ARRAYTYPE_P(0);
+ Oid element_type = ARR_ELEMTYPE(v1);
+ Datum v2 = float8_datum_cast(0, element_type);
+
+ ArrayType *res = General_Array_to_Array(v1, v2, element_cos);
+
+ PG_FREE_IF_COPY(v1, 0);
--- End diff --
Hmm, taking a closer look at the PG_FREE_IF_COPY macro I see I misread how
it examines the second parameter.
Ignore my previous comment, this looks safe.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---