Fw:how are user defined function arguments passed ?
357416268 at qq.com
Wed Jul 10 09:59:55 CEST 2013
Could anyone explain this question to me, please?
I am still wondering on it....
------------------ Original ------------------
From: "integrity"<357416268 at qq.com>;
Date: Fri, Jul 5, 2013 03:42 PM
To: "users-list"<users-list at monetdb.org>;
Subject: how are user defined function arguments passed ?
In thesection about how to extend SQL with a simple scalar function to reverse a string
step 3. Extension starts with a definitin of the MAL signatures. See the example given, or browse through the files in monetdb5/modules/mal/*.mal to get a glimpse on how to write them. The MonetDB kernel documentation provides more details. The file contains the MAL snippet:
comment "Reverse a string";
step 4. The signature says that it expects a command body implementation under the name UDFreverse, shown below. The C-signature is a direct mapping, where arguments are passed by reference and the return value(s) references are the first in the arguments list. The body should return a (malloced) string to denote an exception being raised or MAL_SUCCEED upon access.
reverse(const char *src)
str ret, new;
/* The scalar function returns the new space */
len = strlen(src);
ret = new = GDKmalloc(len + 1);
if (new == NULL)
new[len] = 0;
while (len > 0)
*new++ = src[--len];
UDFreverse(str *ret, str *src)
if (*src == 0 || strcmp(*src, str_nil) == 0)
*ret = GDKstrdup(str_nil);
*ret = reverse(*src);
I don't know why the argument name of "command reverse(ra1:str):str" different from function definition UDFreverse(str *ret, str *src)?
how does ret come from? is it according to the naming rules that the first argument is the result, must it be a string type?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the users-list