skip to Main Content

AGE’s functions can be found in the age–1.3.0.sql file. Although there are no examples of function overloading, is there any possibility to create multiple functions with the same name but with different parameters for AGE? If yes, then how? If not, then why? Thanks in advance.

2

Answers


  1. It’s possible to create multiple functions with the same name, you can see some examples here. However, remember that when overloading C-language functions, you need to the use different C names for each function in the family of overloaded functions. Read the documentation provided to learn more.

    Another alternative if you need to process different argument types is using "any" as the parameter for your function and then handle the type in the function implementation in C. You can add a variant and use variant "any" to handle multiple arguments with different types.

    Login or Signup to reply.
  2. Rather than creating two functions with the same name, it is preferred to use a single function with varying numbers of arguments of different types. This behavior is found in many AGE functions, such as agtype_build_map.

    CREATE FUNCTION ag_catalog.agtype_build_map(VARIADIC "any")
    

    In this case, you create a function with a VARIADIC "ANY" datatype, where "variadic" indicates a variable number of parameters, and "any" indicates that the parameters can be of any datatype.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search