I was looking inside the create_vlabel
function and noted that to get the graph_name
and label_name
it is used graph_name = PG_GETARG_NAME(0)
and label_name = PG_GETARG_NAME(1)
. Since these two variables are also passed as parameters, I was thinking that, if I wanted to add one more parameter to this function, then I would need to use PG_GETARG_NAME(2)
to get this parameter and use it in the function's logic. Is my assumption correct or do I need to do more tweaks to do this?
CodePudding user response:
You are correct, but you also need to change the function signature in the "age--1.2.0.sql" file, updating the arguments:
CREATE FUNCTION ag_catalog.create_vlabel(graph_name name, label_name name, type new_argument)
RETURNS void
LANGUAGE c
AS 'MODULE_PATHNAME';
Note that all arguments come as a "Datum" struct, and PG_GETARG_NAME
automatically converts it to a "Name" struct. If you need an argument as int32, for example, you should use PG_GETARG_INT32(index_of_the_argument)
, for strings, PG_GETARG_CSTRING(n)
, and so on.
CodePudding user response:
Yes, your assumption is correct. If you want to add an additional parameter to the create_vlabel
function in PostgreSQL, you can retrieve the value of the third argument using PG_GETARG_NAME(2)
. Keep in mind that you may need to make additional modifications to the function's logic to handle the new parameter correctly.