Is there a way to view MonetDB Function signatures

2019-09-08 15:37发布

I have tried to locate a source for MonetDB function signatures. Some can be found by querying the sys.functions table, but date and time functions are missing the signatures. for instance if you look at the "month" function in that table there are 4 listed in the table.

| id   | name       | func  | mod   | lang | type | side_e | varres | vararg |>
:      :            :       :       : uage :      : ffect  :        :        :>
+======+============+=======+=======+======+======+========+========+========    +
|  901 | month      | month | mtime |    0 |    1 | false  | false  | false  |
|  910 | month      | month | mtime |    0 |    1 | false  | false  | false  |
|  916 | month      | month | mtime |    0 |    1 | false  | false  | false  |
|  922 | month      | month | mtime |    0 |    1 | false  | false  | false  |
|  930 | dayofmonth | day   | mtime |    0 |    1 | false  | false  | false  |
+------+------------+-------+-------+------+------+--------+--------+--------

I took a guess that "month" could be used like: SELECT "month"(now());

And I was right - but I cannot find a list of the parameter the "month" functions take or what exactly they return.

This question is not only about "month" I would like a source to find the function utilization for all functions in the sys.function table.

Other RDBMS vendor have fleshed-out explanations for these types of functions - I find nothing like this for MonetDB, I can only assume I am looking in the wrong place. I read their documentation on the website and searched their website for this info, but I cannot find it.

Thank you

1条回答
你好瞎i
2楼-- · 2019-09-08 16:21

You can find the parameters/return types of functions in the sys.args table. You can join this table together with the sys.functions table to get the parameters/return types of a specific function.

For example, to get the valid parameters of the month function as well as its return type the following query can be used.

SELECT functions.id, functions.name,args.name,args.type 
FROM functions 
INNER JOIN args 
ON args.func_id=functions.id 
WHERE functions.name='month';


+------+-------+-------+----------------+
| id   | name  | name  | type           |
+======+=======+=======+================+
| 1157 | month | res_0 | int            |
| 1157 | month | arg_1 | date           |
| 1166 | month | res_0 | int            |
| 1166 | month | arg_1 | timestamp      |
| 1172 | month | res_0 | int            |
| 1172 | month | arg_1 | timestamptz    |
| 1178 | month | res_0 | int            |
| 1178 | month | arg_1 | month_interval |
+------+-------+-------+----------------+

We can see that there are four functions called month. They all return an integer (res_0), and take either a date, timestamp, timestamptz or month_interval as parameter (arg_1).

查看更多
登录 后发表回答