Is there a way to view MonetDB Function signatures

烈酒焚心 提交于 2019-12-12 03:38:02

问题


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:


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).



来源:https://stackoverflow.com/questions/37733504/is-there-a-way-to-view-monetdb-function-signatures

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!